MuPAD
Pro Computing Essentials - Examples
Example 5.0 - Quadratic Equation
This is the most classical example of a MuPAD
procedure. Use this example to produce solutions of
quadratic equations. Use it also to learn how to write
simple procedures in MuPAD.
- QuadEquation := proc(a,b,c)
begin
if a<>0 then
delta := b^2-4*a*c;
if delta >= 0 then
x1 := (-b + sqrt(delta))/(2*a);
x2 := (-b - sqrt(delta))/(2*a);
return(x1, x2)
else
print("No real solutions")
end
else
if b<>0 then
x1 := -c/b
else
print("No solutions")
end
end
end_proc:
- quadEquation(1000,-2,-1)

|