From: thomas@arnold.fkp.physik.th-darmstadt.de (Thomas Traexler)
Subject: mma: Bug in FindRoot
Date: Fri, 16 Oct 1992 12:07:05 GMT
Organization: TH Darmstadt

I have a big problem with the FindRoot-command! Every time I use the
FindRoot-command the time to evaluate the command is increased. So the  
first evaluation needs 2.62 seconds and the 21th  80.3 seconds. Is this a  
known bug? Any comments?

By 
   Thomas



Mathematica 2.0 for NeXT
Copyright 1988-91 Wolfram Research, Inc.
 -- NeXT graphics initialized -- 

In[1]:= $Version

Out[1]= NeXT 2.0 (November 14, 1991)

In[2]:= $ReleaseNumber

Out[2]= 4

In[3]:= xp = omega*y - (-(h*x*y) - y*(mu -
        (2*(1 + mu)*(x^2 + y^2))/(1 + x^2 + y^2)) -
     gamma*((h*(-1 + x^2 - y^2))/2 +
        x*(mu - (2*(1 + mu)*(x^2 + y^2))/(1 + x^2 + y^2))))

General::spell1: 
   Possible spelling error: new symbol name "gamma"
     is similar to existing symbol "Gamma".

                                               2    2
                                  2 (1 + mu) (x  + y )
Out[3]= omega y + h x y + y (mu - --------------------) + 
                                           2    2
                                      1 + x  + y
 
                     2    2                         2    2
            h (-1 + x  - y )           2 (1 + mu) (x  + y )
>    gamma (---------------- + x (mu - --------------------))
                   2                            2    2
                                           1 + x  + y

In[4]:= yp = -(omega*x) - ((h*(-1 + x^2 - y^2))/2 +
     x*(mu - (2*(1 + mu)*(x^2 + y^2))/(1 + x^2 + y^2)) -
     gamma*(h*x*y + y*(mu - (2*(1 + mu)*(x^2 + y^2))/(1 + x^2 + y^2))))

                              2    2                         2    2
                     h (-1 + x  - y )           2 (1 + mu) (x  + y )
Out[4]= -(omega x) - ---------------- - x (mu - --------------------) + 
                            2                            2    2
                                                    1 + x  + y
 
                                         2    2
                            2 (1 + mu) (x  + y )
>    gamma (h x y + y (mu - --------------------))
                                     2    2
                                1 + x  + y

In[5]:= sp = -(-(h*y) - y*((4*(1 + mu)*x*(x^2 + y^2))/(1 + x^2 + y^2)^2 -
         (4*(1 + mu)*x)/(1 + x^2 + y^2)) -
      gamma*(mu + h*x - (2*(1 + mu)*(x^2 + y^2))/(1 + x^2 + y^2) +
         x*((4*(1 + mu)*x*(x^2 + y^2))/(1 + x^2 + y^2)^2 -
            (4*(1 + mu)*x)/(1 + x^2 + y^2)))) -
   (-(h*y) + x*((4*(1 + mu)*y*(x^2 + y^2))/(1 + x^2 + y^2)^2 -
        (4*(1 + mu)*y)/(1 + x^2 + y^2)) -
     gamma*(mu + h*x - (2*(1 + mu)*(x^2 + y^2))/(1 + x^2 + y^2) +
        y*((4*(1 + mu)*y*(x^2 + y^2))/(1 + x^2 + y^2)^2 -
           (4*(1 + mu)*y)/(1 + x^2 + y^2))))

                                  2    2
                   4 (1 + mu) x (x  + y )   4 (1 + mu) x
Out[5]= 2 h y + y (---------------------- - ------------) - 
                             2    2 2            2    2
                       (1 + x  + y )        1 + x  + y
 
                       2    2
        4 (1 + mu) y (x  + y )   4 (1 + mu) y
>    x (---------------------- - ------------) + 
                  2    2 2            2    2
            (1 + x  + y )        1 + x  + y
 
                                    2    2
                       2 (1 + mu) (x  + y )
>    gamma (mu + h x - -------------------- + 
                                2    2
                           1 + x  + y
 
                          2    2
           4 (1 + mu) x (x  + y )   4 (1 + mu) x
>       x (---------------------- - ------------)) + 
                     2    2 2            2    2
               (1 + x  + y )        1 + x  + y
 
                                    2    2
                       2 (1 + mu) (x  + y )
>    gamma (mu + h x - -------------------- + 
                                2    2
                           1 + x  + y
 
                          2    2
           4 (1 + mu) y (x  + y )   4 (1 + mu) y
>       y (---------------------- - ------------))
                     2    2 2            2    2
               (1 + x  + y )        1 + x  + y

In[6]:= det = (-(h*y) - y*((4*(1 + mu)*x*(x^2 + y^2))/(1 + x^2 + y^2)^2 -
         (4*(1 + mu)*x)/(1 + x^2 + y^2)) -
      gamma*(mu + h*x - (2*(1 + mu)*(x^2 + y^2))/(1 + x^2 + y^2) +
         x*((4*(1 + mu)*x*(x^2 + y^2))/(1 + x^2 + y^2)^2 -
            (4*(1 + mu)*x)/(1 + x^2 + y^2))))*
    (-(h*y) + x*((4*(1 + mu)*y*(x^2 + y^2))/(1 + x^2 + y^2)^2 -
         (4*(1 + mu)*y)/(1 + x^2 + y^2)) -
      gamma*(mu + h*x - (2*(1 + mu)*(x^2 + y^2))/(1 + x^2 + y^2) +
         y*((4*(1 + mu)*y*(x^2 + y^2))/(1 + x^2 + y^2)^2 -
            (4*(1 + mu)*y)/(1 + x^2 + y^2)))) -
   (-omega - (mu + h*x - (2*(1 + mu)*(x^2 + y^2))/(1 + x^2 + y^2) +
        x*((4*(1 + mu)*x*(x^2 + y^2))/(1 + x^2 + y^2)^2 -
           (4*(1 + mu)*x)/(1 + x^2 + y^2)) -
        gamma*(h*y + y*((4*(1 + mu)*x*(x^2 + y^2))/(1 + x^2 + y^2)^2 - 
              (4*(1 + mu)*x)/(1 + x^2 + y^2)))))*
    (omega - (-(h*x) - y*((4*(1 + mu)*y*(x^2 + y^2))/(1 + x^2 + y^2)^2 -
           (4*(1 + mu)*y)/(1 + x^2 + y^2)) -
        (mu - (2*(1 + mu)*(x^2 + y^2))/(1 + x^2 + y^2)) -
        gamma*(-(h*y) + x*((4*(1 + mu)*y*(x^2 + y^2))/(1 + x^2 + y^2)^2 -
              (4*(1 + mu)*y)/(1 + x^2 + y^2)))))

General::spell1: 
   Possible spelling error: new symbol name "det"
     is similar to existing symbol "Det".

                                            2    2
                               2 (1 + mu) (x  + y )
Out[6]= -((-mu - omega - h x + -------------------- - 
                                        2    2
                                   1 + x  + y
 
                            2    2
             4 (1 + mu) x (x  + y )   4 (1 + mu) x
>         x (---------------------- - ------------) + 
                       2    2 2            2    2
                 (1 + x  + y )        1 + x  + y
 
                                         2    2
                          4 (1 + mu) x (x  + y )   4 (1 + mu) x
>         gamma (h y + y (---------------------- - ------------))) 
                                    2    2 2            2    2
                              (1 + x  + y )        1 + x  + y
 
                                         2    2
                            2 (1 + mu) (x  + y )
>       (mu + omega + h x - -------------------- + 
                                     2    2
                                1 + x  + y
 
                            2    2
             4 (1 + mu) y (x  + y )   4 (1 + mu) y
>         y (---------------------- - ------------) + 
                       2    2 2            2    2
                 (1 + x  + y )        1 + x  + y
 
                                            2    2
                             4 (1 + mu) y (x  + y )   4 (1 + mu) y
>         gamma (-(h y) + x (---------------------- - ------------)))) + 
                                       2    2 2            2    2
                                 (1 + x  + y )        1 + x  + y
 
                                 2    2
                  4 (1 + mu) x (x  + y )   4 (1 + mu) x
>    (-(h y) - y (---------------------- - ------------) - 
                            2    2 2            2    2
                      (1 + x  + y )        1 + x  + y
 
                                       2    2
                          2 (1 + mu) (x  + y )
>       gamma (mu + h x - -------------------- + 
                                   2    2
                              1 + x  + y
 
                             2    2
              4 (1 + mu) x (x  + y )   4 (1 + mu) x
>          x (---------------------- - ------------))) 
                        2    2 2            2    2
                  (1 + x  + y )        1 + x  + y
 
                                  2    2
                   4 (1 + mu) y (x  + y )   4 (1 + mu) y
>     (-(h y) + x (---------------------- - ------------) - 
                             2    2 2            2    2
                       (1 + x  + y )        1 + x  + y
 
                                       2    2
                          2 (1 + mu) (x  + y )
>       gamma (mu + h x - -------------------- + 
                                   2    2
                              1 + x  + y
 
                             2    2
              4 (1 + mu) y (x  + y )   4 (1 + mu) y
>          y (---------------------- - ------------)))
                        2    2 2            2    2
                  (1 + x  + y )        1 + x  + y

In[7]:= x0=1;y0=0;h0=0.5;omega=1;gamma=0.1;mu=.1

Out[7]= 0.1

In[8]:=  
Do[{a=Timing[root=FindRoot[{xp==0,yp==0,sp==0},{x,x0},{y,y0},{h,h0}];];
   Print[i,a,root]},{i,0,20}] 
   
0{2.61667 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
1{5.76667 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
2{8.8 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
3{12.1167 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
4{15.5667 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
5{18.85 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
6{22.2667 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
7{25.8667 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
8{29.1667 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
9{33.3833 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
10{37.2333 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
11{41.1833 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
12{45. Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
13{49.2 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
14{53.1167 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
15{57.3667 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
16{62.05 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
17{66.5833 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
18{71.0667 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
19{75.4833 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}
20{80.3 Second, Null}{x -> 0.966982, y -> 0.168485, h -> 0.576706}




Thomas Traexler
TH-Darmstadt Germany
Email: thomas@arnold.fkp.physik.th-darmstadt.de