Mathematics Stack Exchange is a question and answer site for people studying math at any level and professionals in related fields. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

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|cite|improve this question
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|cite|improve this answer

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.