MAPLE HELPSHEETS: ZEROS

MAPLE: Solutions of Equations


This Help Sheet demonstrates how to use Maple to solve:

  1. a single equation for a single variable, and
  2. a system of equations for several variables.


  1. Plot a function to help determine the location of its zeros.

    > 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 ) ;

  2. To solve a function for its zeros, use solve (maple will try to find all zeros, whether real or complex)

    > f := x -> x^6 - 3*x^5 - 5*x^4 + 15*x^3 + 4*x^2 - 12*x ;

    > solve( f(x), x ) ;

  3. To solve a function for its real zeros, use fsolve

    > 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

  4. Example

    > 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


  5. Example:   Point of Intersection of Two Functions.

    > 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

  6. Example

    > 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

  7. Example:  (This function has infinitely many zeros)

    > 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.


  8. Solving a System of Equations for Several Unknowns.

    For example, to solve the two equations for two unknowns:

    x2 + y2 = 9

    x – y = 1

    > 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 xy–plane 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.


Go to the Maple Help Sheet Index

Written and maintained by

Prof. Kevin G. TeBeest
Applied Mathematics
Kettering University

Last modified: 01/22/2024

Maple® is a registered trademark of Waterloo Maple Software.

Copyright © 1997–2023 Dr. Kevin G. TeBeest. All rights reserved.