PHP uses the string truncation method to find the root and root algorithms of a single-dimensional equation multiple times, and PHP to find the root of the equation.
$ X2) {$ mv = $ x2; $ x2 = $ x1; $ x1 = $ mv;} $ y1 = constructequ ($ equation ['n'], $ equation ['modulus'], $ x1); if ($ y1 = 0) if (! In_array ($ x1, $ roots) $ roots [] = $ x1; $ y2 = constructequ ($ equation ['n'], $ equation ['modulus'], $ x2); if ($ y2 = 0) if (! In_array ($ x2, $ roots) $ roots [] = $ x2; $ mx = ($ x1 + $ x2)/2; if ($ x2-$ mx> $ equation ['intervalprecision ']) {solveequation ($ x1, $ mx, $ equation); solveequation ($ mx, $ x2, $ equation);} else {if ($ y1 * $ y2 <0) {$ x = ($ x1 * $ y2-$ x2 * $ y1) /($ y2-$ y1); $ y = constructequ ($ equation ['n'], $ equation ['modulus'], $ x ); if ($ y * $ y1> 0) {$ x1 = $ x; $ x2 = $ x2;} if ($ y * $ y2> 0) {$ x1 = $ x1; $ x2 = $ x;} while ($ y> $ equation ['presition ']) {solveequation ($ x1, $ x2, $ equation );} $ Roots [] = number_format ($ x, $ equation ['rootprecision ']) ;}}$ x1 =-20; $ x2 = 10; $ equation = array ('n' => 3, 'modulus' => array (180,-0.001, 8, 1), 'presition '=>, 'intervalprecision '=> 0.001, 'rootprecision' => 2); $ roots = array (); solveequation ($ x1, $ x2, $ equation ); var_dump ($ roots);?>