Take the 2-minute tour ×
Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. It's 100% free, no registration required.

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?

share|improve this question
add comment

1 Answer

up vote 2 down vote accepted

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
share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.