多项式系数的计算

时间:2013-11-26 18:44:20

标签: java algorithm polynomial-math

我需要数学库来解决3个方程的简单系统,如(ax 2 + bx + c = y)并获得a, b, c,其中我知道3对(x,y)

我正在寻找一些东西,但我找不到对我有用的东西。

2 个答案:

答案 0 :(得分:4)

这是一个由3个方程组成的线性系统,而不是二阶方程! x和y值是已知的!要解决线性系统,请参阅: https://code.google.com/p/efficient-java-matrix-library/wiki/SolvingLinearSystems

答案 1 :(得分:0)

问题解决了,感谢 Zong Zheng Li Pavlos Fragkiadoulakis

RealMatrix coefficients = new Array2DRowRealMatrix(new double[][] { { px1*px1, px1, 1 }, { px2*px2, px2, 1 },
            { x*x, x, 1 } }, false);
DecompositionSolver solver = new LUDecomposition(coefficients).getSolver();
RealVector constants = new ArrayRealVector(new double[] { py1, py2, y }, false);
RealVector solution = solver.solve(constants);
double a = solution.getEntry(0);
double b = solution.getEntry(1);
double c = solution.getEntry(2);
相关问题