I need math library to solve simple system of 3 equations like (ax2 + bx + c = y) and get a, b, c, where I know 3 couples (x,y).

I searching for something but I didn't find anything useful for me.

有帮助吗?

解决方案

This is a linear system of 3 equations, not a 2nd order equation! x and y are values are known! To solve a linear system see : https://code.google.com/p/efficient-java-matrix-library/wiki/SolvingLinearSystems

其他提示

Question solved, thanks to Zong Zheng Li and 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);
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top