File r38/packages/odesolve/misc.rlg artifact e561142b7f part of check-in d58ccc1261


REDUCE Development Version, Wed Sep 13 20:40:41 2000 ...







ODESolve 1.065

% Miscellaneous ODESolve 1+ tests

% Check for a problem in 1.03, spotted by David Hartley
% <DHartley@physics.adelaide.edu.au>, caused by the reval in
% `get_k_list' with caching enabled.  The following should all give
% the same result:

odesolve(df(u,x,x)=df(u,x));


*** Dependent var(s) assumed to be u 

*** Independent var assumed to be x 

*** depend u , x

    x
{u=e *arbconst(2) + arbconst(1)}

odesolve(df(u,x,2)=df(u,x));


*** Dependent var(s) assumed to be u 

*** Independent var assumed to be x 

    x
{u=e *arbconst(4) + arbconst(3)}

odesolve(df(u,x,x)=df(u,x), u, x);


    x
{u=e *arbconst(6) + arbconst(5)}



% Linear first-order ODE:
odesolve(df(y,t) = -w*y*tan(w*t - d));


*** Dependent var(s) assumed to be y 

*** Independent var assumed to be t 

*** depend y , t

{y=arbconst(7)*cos(d - t*w)}

% The solution, by inspection, is y = A cos(w t - d)


% Variation of parameters:
depend y, x;



ode := df(y,x,2) + y - csc(x)$


odesolve(ode, y, x);


{y=arbconst(9)*sin(x) + arbconst(8)*cos(x) - cos(x)*x + log(sin(x))*sin(x)}

sub(ws, ode);


       2                         2
 cos(x)  - csc(x)*sin(x) + sin(x)
-----------------------------------
              sin(x)

trigsimp ws;


0


ode := 2*df(y,x,2) + y - csc(x)$


odesolve(ode, y, x);


                           x                               x
{y=(2*arbconst(11)*sin(---------) + 2*arbconst(10)*cos(---------)
                        sqrt(2)                         sqrt(2)

                                           x
                                   sin(---------)
                       x                sqrt(2)
     - sqrt(2)*cos(---------)*int(----------------,x)
                    sqrt(2)            sin(x)

                            x
                    cos(---------)
                         sqrt(2)               x
     + sqrt(2)*int(----------------,x)*sin(---------))/2}
                        sin(x)              sqrt(2)

sub(ws, ode);


         x     2                           x     2
 cos(---------)  - csc(x)*sin(x) + sin(---------)
      sqrt(2)                           sqrt(2)
---------------------------------------------------
                      sin(x)

trigsimp ws;


0



% Bernoulli:
ode := df(y,x)*y*x^2 - y^2*x - x^3 + 1;


                2      3      2
ode := df(y,x)*x *y - x  - x*y  + 1

odesolve(ode, y, x, explicit);


                         3             3
    sqrt(3*arbconst(13)*x  + 6*log(x)*x  + 2)*plus_or_minus(tag_1)
{y=----------------------------------------------------------------}
                           sqrt(x)*sqrt(3)

sub(ws, ode);


0



% Implicit dependence:

% (NB: Wierd constants need to be mopped up by the arbconst
% simplification code!)

% These should all behave equivalently:
operator f, g;


depend {y, ff}, x, {gg}, y;



odesolve(df(y,x) = f(x), y, x);


{y=arbconst(14) + int(f(x),x)}

odesolve(df(y,x) = ff, y, x);


{y=arbconst(15) + int(ff,x)}

odesolve(df(y,x) = g(y), y, x);


                      1
{arbconst(16) + int(------,y) - x=0}
                     g(y)

odesolve(df(y,x) = gg, y, x);


                     1
{arbconst(17) + int(----,y) - x=0}
                     gg

odesolve(df(y,x) = f(x)*g(y), y, x);


                                         1
{arbconst(18)*f(0) - int(f(x),x) + int(------,y)=0}
                                        g(y)

odesolve(df(y,x) = ff*gg, y, x);


                         1
{arbconst(19)*ff! + int(----,y) - int(ff,x)=0}
                         gg

odesolve(df(y,x) = 1/f(x)*g(y), y, x);


                           1                    1
{arbconst(20) - f(0)*int(------,x) + f(0)*int(------,y)=0}
                          f(x)                 g(y)

odesolve(df(y,x) = 1/ff*gg, y, x);


                     1                 1
{arbconst(21) - int(----,x)*ff! + int(----,y)*ff!=0}
                     ff                gg

odesolve(df(y,x) = f(x)/g(y), y, x);


{arbconst(22)*f(0) - int(f(x),x) + int(g(y),y)=0}

odesolve(df(y,x) = ff/gg, y, x);


{arbconst(23)*ff! - int(ff,x) + int(gg,y)=0}


% These should all fail (they are too implicit):
depend {ff}, y, {gg}, x;



odesolve(df(y,x) = ff, y, x);


{df(y,x) - ff=0}

odesolve(df(y,x) = gg, y, x);


{df(y,x) - gg=0}

odesolve(df(y,x) = ff*gg, y, x);


{df(y,x) - ff*gg=0}

odesolve(df(y,x) = 1/ff*gg, y, x);


{df(y,x)*ff - gg=0}

odesolve(df(y,x) = ff/gg, y, x);


{df(y,x)*gg - ff=0}



% NONlinear ODEs:
odesolve(df(y,x) + y**(5/3)*arbconst(-1)=0);


*** Dependent var(s) assumed to be y 

*** Independent var assumed to be x 

    2/3                                2/3
{2*y   *arbconst(24)*arbconst(-1) - 2*y   *arbconst(-1)*x + 3=0}


% Do not re-evaluate the solution without turning the algint switch on!
odesolve(df(y,x,2) + c/(y^2 + k^2)^(3/2) = 0, y, x, algint);


{2*arbconst(26)*plus_or_minus(tag_2)*c + sqrt(k)*sqrt(c)*sqrt(2)*arbconst(25)*

                         2                 2         2    2             2    2
      sqrt(arbconst(25)*k  + arbconst(25)*y  - sqrt(k  + y )*k*y)*sqrt(k  + y )
 int(---------------------------------------------------------------------------
                                 2  2               2  2    2  2
                     arbconst(25) *k  + arbconst(25) *y  - k *y

     ,y)*k + sqrt(k)*sqrt(c)*sqrt(2)

                          2                 2         2    2
       sqrt(arbconst(25)*k  + arbconst(25)*y  - sqrt(k  + y )*k*y)*y      2
 *int(---------------------------------------------------------------,y)*k
                            2  2               2  2    2  2
                arbconst(25) *k  + arbconst(25) *y  - k *y

  - 2*plus_or_minus(tag_2)*c*x=0}


% Good test of ODESolve!-Alg!-Solve.  Takes forever with fullroots on,
% but with fullroots off ODESolve solves it.  (Slightly tidier with
% algint, but not necessary.  However, the explicit option misses the
% non-trivial solution that can fairly easily be found by hand!)
odesolve(df(y,x,3) = 6*df(y,x)*df(y,x,2)/y - 6*df(y,x)^3/(y^2), y, x, algint);


{sqrt(y)*arbconst(30)*arbconst(29)*arbconst(28)

  - sqrt(y)*arbconst(29)*arbconst(28)*x - 2*sqrt(arbconst(28) + y)=0,

 y=arbconst(31)}


% Hangs with algint option!
% off odesolve_plus_or_minus;
odesolve(a*tan(asin((df(y,x) - y)/(2*y))/2)^2 + a -
   2*sqrt(3)*tan(asin((df(y,x) - y)/(2*y))/2)*y + 4*sqrt(3)*y +
   tan(asin((df(y,x) - y)/(2*y))/2)^2*y -
   4*tan(asin((df(y,x) - y)/(2*y))/2)*y + 7*y, y, x);


     x
{ - e *arbconst(32) - sqrt( - 4*sqrt(3)*y - a - 8*y) - sqrt(a)*sqrt(3)=0,

     x
  - e *arbconst(33) - sqrt( - 4*sqrt(3)*y - a - 8*y) + sqrt(a)*sqrt(3)=0}

% on odesolve_plus_or_minus;

% From: K Sudhakar <ks@maths.qmw.ac.uk>
odesolve(2*df(f,x,3)*df(f,x)*f^2*x^2 - 3*df(f,x,2)^2*x^2*f^2 +
   df(f,x)^4*x^2 - df(f,x)^2*f^2, f, x);


*** depend f , x

{arbconst(37)*arbconst(36)*arbconst(35)*log(f) + arbconst(37)*arbconst(36)

  - arbconst(36)*arbconst(35)*log(f)*log(x) - arbconst(36)*log(x) + log(f)=0,

 f=arbconst(38)}


% Related intermediate problem:
odesolve(2*df(y,x)*x*y + x^2 - 2*x*y - y^2, y, x, explicit);


             - (2*x)/(x - y_)               2      2              2
{y=root_of(e                 *arbconst(39)*e *x + x  - 2*x*y_ + y_ ,y_,tag_19)}



% Anharmonic oscillator problem (which apparently Maple V R5.1 solves
% in terms of a root of an expression involving unevaluated integrals
% but Maple 6 cannot!).

% General solution:
odesolve(M*L*df(phi(tt),tt,2) = -M*g*sin(phi(tt)));


*** phi declared operator 

*** Dependent var(s) assumed to be phi(tt) 

*** Independent var assumed to be tt 

{2*arbconst(41)*plus_or_minus(tag_20)*g + sqrt(l)*sqrt(g)*sqrt(2)

       sqrt(arbconst(40)*sin(1) + cos(phi(tt)))
 *int(------------------------------------------,phi(tt))
          arbconst(40)*sin(1) + cos(phi(tt))

  - 2*plus_or_minus(tag_20)*g*tt=0}


% Use of `t' as independent variable:
odesolve(M*L*df(phi(t),t,2) = -M*g*sin(phi(t)));


*** Dependent var(s) assumed to be phi(t) 

*** Independent var assumed to be t 

{2*arbconst(43)*plus_or_minus(tag_21)*g + sqrt(l)*sqrt(g)*sqrt(2)

       sqrt(arbconst(42)*sin(1) + cos(phi(t)))
 *int(-----------------------------------------,phi(t))
          arbconst(42)*sin(1) + cos(phi(t))

  - 2*plus_or_minus(tag_21)*g*t=0}


% Conditional (eigenvalue) solution:
%% odesolve(M*L*df(phi(t),t,2) = -M*g*sin(phi(t)),
%%    {t=0, phi(t)=0, df(phi(t),t)=Pi});
%%
%% Conditional solutions need more work!  This fails with
%% ***** 0 invalid as kernel

% Try setting
%% L:=1;  g:=10;  ws;

end;



Time for test: 24198 ms, plus GC time: 1520 ms



REDUCE Historical
REDUCE Sourceforge Project | Historical SVN Repository | GitHub Mirror | SourceHut Mirror | NotABug Mirror | Chisel Mirror | Chisel RSS ]