1
$\begingroup$

I have a quadratic expression, which I process using the solve function in MAPLE, like so

   quadformula := solve(p,x); 

This displays the quadratic form of the expression. However, what I would like to do is convert the output of the above operation into a function, with variables a,b,c, so I can evaluate it.

 > q := convert(quadformula,'polynom');  
 > quadroot := unapply(q,a,b,c);

The code above does not produce the right output. How do I accomplish this please?

1 Answers 1

2

What you're looking for is the unapply command.

p:=a*x^2+b*x+c:

quadformula:=[solve(p,x)]:

qfunc:=unapply(quadformula,[a,b,c]):

qfunc(3,1,12);

             [  1   1       (1/2)    1   1       (1/2)]
             [- - + - (-143)     , - - - - (-143)     ]
             [  6   6                6   6            ]

qfunc(3,1,12.0);

     [-0.1666666666 + 1.993043456 I, -0.1666666666 - 1.993043456 I]

fsolve(eval(p,[a=3,b=1,c=12]),x,complex);

    -0.1666666667 - 1.993043457 I, -0.1666666667 + 1.993043457 I