next up previous contents
Next: Example 4 Up: Examples presented in this Previous: Example 2   Contents


Example 3

In this example we will solve a trigonometric equation. This equation is derived from the previous example by subtracting the first equation to the second and third: this lead to a linear system in the unknowns x,y which are substituted in the first equation.

The following Maple program enable to get the equations of this example.

 
with(linalg):
xa1:=0:ya1:=0:xa2:=10:ya2:=0:xa3:=3:ya3:=10:
xb1:=0;yb1:=0:xb2:=4:yb2:=0:xb3:=2:yb3:=2:
for i from 1 to 3 do
      OA.i:=array([xa.i,ya.i]):
      CBr.i:=array([xb.i,yb.i])
od:

rot:=array([[cos(teta),-sin(teta)],[sin(teta),cos(teta)]]):
for i from 1 to 3 do CB.i:=multiply(rot,CBr.i): od:
OC:=array([x,y]):
for i from 1 to 3 do
      AB.i:=evalm(OC-OA.i):
      AB.i:=evalm(AB.i+CB.i):
      ro.i:=dotprod(AB.i,AB.i,'orthogonal'):
      ro.i:=simplify(ro.i):
od:

eq1:=ro1-50:eq2:=ro2-26:eq3:=ro3-25:

en1:=eq2-eq1:en2:=eq3-eq1:
sw:=solve({en1,en2},{x,y}):
assign(sw):
eq1:=numer(eq1):
eq1:=simplify(eq1,trig):
eq1:=convert(eq1,horner,[sin(teta),cos(teta)]):
This equation has 2 solutions 0, -0.8067834380 (or equivalently 5.47640187). Here we may use the general solving algorithm (section 2.3), the general solving algorithm with the gradient (section 2.4), the general solving algorithm with the gradient and Hessian (section 2.5) or the procedure devoted to trigonometric equation (section 2.13).

These algorithms are implemented in the test program Test_Solve_General2,
Test_Solve_Gradient_General2, Test_Solve_JH_General2, while for the the specific procedure devoted to solving trigonometric equations we may use the program Test_Solve_Trigo. In the later case we may use or not the procedure which compute bounds on the roots of the equation.

We may then investigate the computation time when we have a pretty good idea of the solution. For example we assume that we have a root in the range [5.3, 5.7]. We may now use Newton method (see section 2.9) implemented in the test program Test_Newton2, Brent's method (see section 2.8 and Ridder's method (see section 2.7) implemented in the test program Test_Ridder2. An interesting point is that although Newton is faster than the others methods we may encounter convergence problem in this example. For example if the initial guess is 5.85 (which is closer to the solution 5.476 than the second solution 0) Newton will converge toward the 0 solution.


next up previous contents
Next: Example 4 Up: Examples presented in this Previous: Example 2   Contents
Jean-Pierre Merlet 2012-12-20