2.3 Systems of non-linear equations in many variables

#                                             WORKSHEET#14
# Systems of non-linear equations in many variables
>  f:=exp(y^2-z^3)-2;

                                    2         2           3
                 f := exp(sin(theta)  sin(phi)  - cos(phi) ) - 2
> g:=sin(x+2*y+3*z^2)+x^4;

                                                                        2
       g := sin(cos(theta) sin(phi) + 2 sin(theta) sin(phi) + 3 cos(phi) )

                        4         4
            + cos(theta)  sin(phi)
> h:=x^2+y^2+z^2-1;

                      2         2             2         2           2
       h := cos(theta)  sin(phi)  + sin(theta)  sin(phi)  + cos(phi)  - 1
# We want to find all simultaneous solutions of f(x,y,z)=0, g(x,y,z)=0, h(x,y,z)=0.  Each of 
# these equations defines a surface in 3-space.  We want the common intersection of these 
# surfaces.  Notice that h=0 is just the unit sphere centered at the origin.  The equation f=0 
# is equivalent to y^2-z^3=ln(2), a cylinder in the x direction.
> fsolve({f,g,h},{x,y,z});
Error, (in fsolve) should use exactly all the indeterminates

# There is no error in the command itself, rather Maple can not find a solution this way.  
# We have to be more artful.  The third equation h=0 is much more suited to spherical 
# coordinates.
> x:=cos(theta)*sin(phi);y:=sin(theta)*sin(phi);z:=cos(phi);

                            x := cos(theta) sin(phi)

                            y := sin(theta) sin(phi)

                                  z := cos(phi)
> f;

                                 2         2           3
                   exp(sin(theta)  sin(phi)  - cos(phi) ) - 2
> g;

                                                                     2
         sin(cos(theta) sin(phi) + 2 sin(theta) sin(phi) + 3 cos(phi) )

                          4         4
              + cos(theta)  sin(phi)
> h;

                    2         2             2         2           2
          cos(theta)  sin(phi)  + sin(theta)  sin(phi)  + cos(phi)  - 1
> simplify(");

                                        0
# In other words the equation h=0 is automatically satisfied when we convert to spherical 
# coordinates.
> F:=simplify(f);

                       2             2             2         2           3
  F := exp(1 - cos(phi)  - cos(theta)  + cos(theta)  cos(phi)  - cos(phi) ) - 2
> G:=simplify(g);

                                                                       2
      G := sin(cos(theta) sin(phi) + 2 sin(theta) sin(phi) + 3 cos(phi) )

                       4               4         2             4         4
           + cos(theta)  - 2 cos(theta)  cos(phi)  + cos(theta)  cos(phi)
# I don't know if I would agree that these expressions are simpler.  In any case the original 
# problem is now down to 2 equations, namely F(theta,phi)=0, G(theta,phi)=0.
> fsolve({F,G},{theta,phi});

                    {theta = .5806816709, phi = -9.984737488}
> assign(");
# This actually assigns the above values to theta and phi.  We can now work out the 
# corresponding values of x, y, z and at the same time check that we do have a solution.
> print([x,y,z],[f,g,h]);

                                                                -9
           [.4440902047, .2913867500, -.8472766089], [0, -.47*10  , 0]
# Now we'll look for other solutions.  First we have to unassign values.
> theta:='theta':phi:='phi':
> with(plots):
> graphF:=implicitplot(F,theta=0..2*Pi,phi=0..Pi,title=`F(theta,phi)=0`):
> graphF;
# 

   ** Maple V Graphics **

> graphG:=implicitplot(G,theta=0..2*Pi,phi=0..Pi,title=`G(theta,phi)=0`):
> graphG;
# 

   ** Maple V Graphics **

> display([graphF,graphG],title=`points of intersection`);
# 

   ** Maple V Graphics **

# There are clearly 2 points of intersection and possibly 2 more in the upper left hand 
# corner.  By using the mouse and clicking on the possible intersection point we come up 
# with theta=0.74 and phi=2.51.
> zoomF:=implicitplot(F,theta=0..2,phi=2.3..3):
> zoomG:=implicitplot(G,theta=0..2,phi=2.3..3):
> display([zoomF,zoomG],title=`upper left hand corner`);
# 

   ** Maple V Graphics **

# 
# 
--------------------------------------------------------------------------------
# Yes indeed, there are 2 more points of intersection.  We can find approximate coordinates 
# by using the mouse in the plot window.  They seem to be (theta,phi)=(0.59, 2.57) and
# (0.85,2.46).  Armed with this approximation we can use Maple to find them to 10 places.
--------------------------------------------------------------------------------
> fsolve({F,G},{theta,phi},{theta=0.55..0.65,phi=2.5..2.7});

                    {theta = .5806816709, phi = 2.581633126}
> assign(");
--------------------------------------------------------------------------------
> print([x,y,z],[f,g,h]);

                                                               -9
           [.4440902049, .2913867502, -.8472766087], [0, .61*10  , 0]
--------------------------------------------------------------------------------
# x,y, and z are functions of the spherical coordinates theta, phi.  The values of f,g and h are 
# zero at these solutions.  We save these values for future use.
--------------------------------------------------------------------------------
> sol[1]:=[x,y,z];

               sol[1] := [.4440902049, .2913867502, -.8472766087]
--------------------------------------------------------------------------------
> theta:='theta':phi:='phi':
--------------------------------------------------------------------------------
> fsolve({F,G},{theta,phi},{theta=0.7..1.0,phi=2.4..2.7});\


                    {theta = .8545096410, phi = 2.458305107}
--------------------------------------------------------------------------------
> assign(");
--------------------------------------------------------------------------------
> print([x,y,z],[f,g,h]);

                                                                -8
          [.4145344389, .4761920619, -.7755013341], [0, -.101*10  , 0]
--------------------------------------------------------------------------------
> sol[2]:=[x,y,z];

               sol[2] := [.4145344389, .4761920619, -.7755013341]
--------------------------------------------------------------------------------
> theta:='theta':phi:='phi':
--------------------------------------------------------------------------------
# In the same way we can find the other solutions to 10 places.
--------------------------------------------------------------------------------
> fsolve({F,G},{theta,phi},{theta=3.9..4.2,phi=2.0..2.5});

                    {theta = 4.103188417, phi = 2.364619685}
--------------------------------------------------------------------------------
> assign(");
--------------------------------------------------------------------------------
> print([x,y,z],[f,g,h]);

                                                              -8        -9
      [-.4011917196, -.5749960069, -.7130391266], [0, -.100*10  , -.1*10  ]
--------------------------------------------------------------------------------
> sol[3]:=[x,y,z];

              sol[3] := [-.4011917196, -.5749960069, -.7130391266]
--------------------------------------------------------------------------------
> theta:='theta':phi:='phi':
--------------------------------------------------------------------------------
> fsolve({F,G},{theta,phi},{theta=5.0..5.4,phi=2.0..2.5});

                    {phi = 2.181034644, theta = 5.233829826}
--------------------------------------------------------------------------------
> assign(");
--------------------------------------------------------------------------------
> print([x,y,z],[f,g,h]);

                                                             -8        -9
       [.4082232611, -.7106003231, -.5730627801], [0, .184*10  , -.1*10  ]
--------------------------------------------------------------------------------
> theta:='theta':phi:='phi':
--------------------------------------------------------------------------------
>