home *** CD-ROM | disk | FTP | other *** search
/ Simtel MSDOS - Coast to Coast / simteldosarchivecoasttocoast2.iso / calculat / sm30a.zip / PSOLVE.(X) < prev    next >
Text File  |  1993-11-06  |  364b  |  9 lines

  1. #    psolve() is polynomial solver
  2. #    e.g. psolve(x^2+5*x+6, x) gives [-2, -3]
  3.  
  4. psolve(y_, x1_) := if(order(y,x1) == 1,
  5.     -coef(y,x1,0)/coef(y,x1,1) )
  6. psolve(y_, x2_) := if(order(y,x2) == 2,
  7.     [(-coef(y,x2,1)+sqrt(coef(y,x2,1)^2-4*coef(y,x2,2)*coef(y,x2,0)))/2*coef(y,x2,2),
  8.      (-coef(y,x2,1)-sqrt(coef(y,x2,1)^2-4*coef(y,x2,2)*coef(y,x2,0)))/2*coef(y,x2,2)])
  9.