Advertisement
sauerCHAOS

Quadratic Equation Solver

Oct 13th, 2011
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C++ 0.54 KB | None | 0 0
  1. solvequad = [
  2.     if (>=f (-f (pow $arg2 2) (*f 4 (*f $arg1 $arg3)))) [
  3.         result (concat (divf (-f (sqrt (-f (pow $arg2 2) (*f 4 (*f $arg1 $arg3)))) $arg2) (*f 2 $arg1)) (divf (+f $arg2 (sqrt (-f (pow $arg2 2) (*f 4 (*f $arg1 $arg3))))) (*f -2 $arg1)))
  4.     ] [
  5.         sq_real = (divf $arg2 (*f -2 $arg1))
  6.         sq_im = (divf (sqrt (-f (*f 4 (*f $arg1 $arg3)) (pow $arg2 2))) (*f 2 $arg1))
  7.         result (concatword (? (=f $sq_real) "0.0" $sq_real) (? (>=f $sq_im) "+" "-") $sq_im "i " (? (=f $sq_real) "0.0" $sq_real) (? (<f $sq_im) "+" "-") $sq_im "i")
  8.     ]
  9. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement