제 목표는 주어진 계수로 다항식을 생성 한 다음 주어진 다항식을 평가하여 포인트를주는 것입니다. 그런 다음 PolynomialFunctionLagrangeForm 클래스를 사용하여 동일한 다항식을 다시 만들고 동일한 계수를 검색합니다.다항식 Lagrange 정확한 계수를 얻는 함수
그러나 두 다항식의 차수가 같아도 계수는 달라집니다.
제 질문은 같은 계수를 얻는 방법입니다. 가능한 모든 다항식을 얻을 수있는 방법이 있습니까?
static double [] points= {1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16};
// Create polynomial using PolynomialFunction class
PolynomialFunction pf = new PolynomialFunction(coeffecient);
System.out.println("-------------------Encoding------------------ \nPolynomial degree: "+pf.degree());
System.out.println("Polynomial: "+pf);
System.out.println("Coffecients: ");
System.out.println(Arrays.toString(pf.getCoefficients()));
evaluatePolynomial(pf, points);
PolynomialFunctionLagrangeForm LF = new PolynomialFunctionLagrangeForm(points,polynomial_values);
System.out.print("-------------------Decoding------------------ \nDegree of Lagrange polynomial:");
System.out.println(LF.degree());
System.out.println("Polynomial: "+LF);
System.out.println("Coffecient of Lagrange polynomial:");
System.out.println(Arrays.toString(LF.getCoefficients()));
출력 :
-------------------Encoding------------------
Polynomial degree: 15
Polynomial: 40.0 x - 53.0 x^2 - 8.0 x^3 - 29.0 x^4 + 99.0 x^5 + 71.0 x^6 - 86.0 x^7 + 127.0 x^8 + 35.0 x^9 + 14.0 x^10 - 53.0 x^11 + 121.0 x^12 - x^13 + 22.0 x^14 - 27.0 x^15
Coffecients:
[0.0, 40.0, -53.0, -8.0, -29.0, 99.0, 71.0, -86.0, 127.0, 35.0, 14.0, -53.0, 121.0, -1.0, 22.0, -27.0]
-------------------Decoding------------------
Degree of Lagrange polynomial:15
Polynomial: org.apache.c[email protected]5f150435
Coffecient of Lagrange polynomial:
[241664.0, -196608.0, 819200.0, -360448.0, 24576.0, -81920.0, 24576.0, -256.0, 640.0, -28.0, 18.0, -52.921875, 121.021484375, -1.000274658203125, 22.000003814697266, -27.000000070780516]
업데이트
내가 다항식 012,351,641에 평가 한 후 다음과 같은 점points= {34121,51152,59804,40922,41678,33985,55244,61576,41866,37365,63178,45530,52928,35006,34671,43212};
P(x)= 37.0 + 79.0 x + 95.0 x^2 - 118.0 x^3 + 66.0 x^4 - 47.0 x^5 - 64.0 x^6 + 77.0 x^7 + 7.0 x^8 + 113.0 x^9 - 81.0 x^10 + 36.0 x^11 - 33.0 x^12 + 7.0 x^13 - 91.0 x^14 + 80.0 x^15
결과에 충실해야
-7.125711012263528E27, -1.7102522454360707E26, -3.9998444109905895E24, -1.1156590815779537E23, -1.3650590614545068E21, -8.762203435012037E19, 1.36909428672063078E18, -1.125899906842624E17, 7.0368744177664E14, -2.3089744183296E13, 3.95136991232E11, -3.3554432E9, 1.572864E7, -110592.0, 192.0, 79.38.
어떤 제안 솔루션 :
(points, P(points))= {(34121,7.914104306379832E69),(51152,3.435734636341671E72),(59804,3.5812547774323177E73),(40922,1.209012191911663E71),(41678, 1.5910403312602316E71),(33985,7.453917205941376E69),(55244, 1.0898275780150622E73),(61576,5.5495027051432293E73),(41866,1.702159385167097E71),(37365,3.0906623702059587E70),(63178,8.157747712897765E73),(45530,5.991614888661553E71),(52928,5.732748723914476E72),(35006,1.1620189256906411E70),(34671,1.005938101921578E70),(43212,2.736176231116627E71)};
그러나, 잘못된 계수를 생산 라그랑주 보간 (점, P (포인트))를 보내?
'computeCoefficients()'를 호출하기 전에 호출해야합니까? 그렇지 않은 경우 숫자 문제 일 가능성이 큽니다. 무슨 요점을 먹이고 있니? –
@ Nico Schertler 질문에 포인트 배열을 추가했습니다. 'getCoefficients()'메소드가 'computeCoefficients()'를 호출하기 때문에 'computeCoefficients()'를 호출하지 않았습니다. 또한, 'computeCoefficients()'는 보호되어 있으므로 호출 할 수 없습니다. –
주어진 다항식은 범위 끝에서 10^18 주변의 값을 반환합니다. 이것은 분명히 수치적인 문제입니다. 그것은 합리적인 입력에 대한 더 얻을 수 있습니다. –