This Help Sheet demonstrates how to use Maple to solve:
> f := x -> x^6 - 3*x^5 - 5*x^4 + 15*x^3 + 4*x^2 - 12*x ;
> plot( f(x), x = -4.0 .. 4.0, thickness = 5, color = blue ) ;
> f := x -> x^6 - 3*x^5 - 5*x^4 + 15*x^3 + 4*x^2 - 12*x ;
> solve( f(x), x ) ;
> f := x -> x^6 - 3*x^5 - 5*x^4 + 15*x^3 + 4*x^2 - 12*x ;
> fsolve( f(x), x ) ; tries to find all real zeros
> fsolve( f(x), x = 0.0 .. 4.0 ) ; tries to find all real zeros between x = 0 & x = 4
> f := x -> x^6 - x^5 + 6*x^4 - 4*x^3 - 29*x^2 + 45*x - 18 ;
> plot( f(x), x = -2.0 .. 2.0, thickness = 5, color = blue, size = [500, 300] ) ;
> solve( f(x), x ) ; result: -2, 3I, -3I, 1, 1, 1
> fsolve( f(x), x ) ; result: -2., 1., 1., 1.
> fsolve( f(x), x = 0.0 .. 2.0 ) ; result: 1., 1., 1.
NOTE: The complex number i is I
> f := x -> cos(x) ;
> g := x -> sqrt(x) ;
> plot( [ f(x), g(x) ], x = 0.0 .. 1.0, thickness = 5, color = [ blue, red ], size = [ 600, 450 ] ) ; plots f and g on a common graph
> fsolve( f(x) = g(x), x = 0.0 .. 1.0 ) ; determines where functions f and g intersect between x = 0 and x = 1
> f := x -> 2*x^4 - 15*x^3 + 60*x^2 - 115*x + 78 ;
> plot( f(x), x = 1.0 .. 3.0 , -2.0 .. 10.0, thickness = 5, color = blue, size = [ 600, 450 ] ) ;
> solve( f(x), x ) ; result: 2, 3/2, 2+3I, 2-3I
> fsolve( f(x), x ) ; result: 2.000000000, 1.500000000
> f := x -> exp(-x) - cos(x) ;
> solve( f(x), x ) ; result: 0
> fsolve( f(x), x ) ; result: 0
> fsolve( f(x), x = 1.0 .. 2.0 ) ; result: 1.292695719
> fsolve( f(x), x = -1.0 .. 1.0 ) ; result: 0
NOTE: The above example illustrates that maple might not find all zeros of a function. Thus, you should have a good idea of where the zeros are without trusting maple to find them correctly.
For example, to solve the two equations for two unknowns:
> eq1 := x^2 + y^2 = 9 ;
> eq2 := x - y = 1 ;
> with( plots, implicitplot ) ; loads the implicitplot command
> implicitplot( [ eq1, eq2 ], x = -4.0 .. 4.0 , y = -4.0 .. 4.0, thickness = 5, color = [ blue, red ], scaling = constrained ) ;
plots both equations in the xyplane on the
specified range
> solve( { eq1, eq2 }, {x,y} ) ;
tries to solve the system symbolically—it may not succeed
> fsolve( { eq1, eq2 } , {x,y} ) ;
tries to solve the system numerically, but
may give only one solution since no range is specified
> fsolve( { eq1, eq2 } , {x,y} ,
{ x = 0.0 .. 3.0 , y = 0.0 .. 3.0 } ) ;
solves the system numerically on the specified
range
> fsolve( { eq1, eq2 } , {x,y},
{ x = -3.0 .. 0.0 , y = -3.0 .. 0.0 } ) ;
solves the system numerically on the specified
range
> ?implicitplot for more help with the implicitplot command
> ?fsolve for more help with the fsolve command
Note: As the example shows, solve can have difficulty solving nonlinear equations (this shouldn't be surprising). You might have to use fsolve to approximate the solution using floating point arithmetic. To successfully use fsolve to solve a nonlinear system, you should give a range over which fsolve is to look for the solution.
Written and maintained by
Last modified: 01/22/2024
Copyright © 19972023 Dr. Kevin G. TeBeest. All rights reserved.
Prof. Kevin G. TeBeest
Maple® is a registered trademark of Waterloo Maple Software.
Applied Mathematics
Kettering University