1 (load("contrib_ode"),0);
4 /* Test cases for symtest() function */
9 /* E. S. Cheb-Terrab, A. D. Roche, Symmetries and First Order ODE Patterns
11 phi: (y*x^2)/(3*y*(x^2+y^2)*atan(x/y)+y^2*(1-3*x)+x^2*(1-2*x));
12 x^2*y/(3*atan(x/y)*y*(y^2+x^2)+(1-3*x)*y^2+(1-2*x)*x^2);
13 symtest(phi,xi:1/x^2+1/y^2,eta:0,y,x);
16 /* E. S. Cheb-Terrab, A. D. Roche, Symmetries and First Order ODE Patterns
18 symtest(phi:y^2/(sin(y-x)-x^2+2*x*y),xi:y^2,eta:y^2,y,x);
21 /* Above, with change of variables */
22 symtest(ev(phi,x=t,y=u),u^2,u^2,u,t);
25 /* E. S. Cheb-Terrab, T. Koloknikov, First Order ODEs,
26 Symmetries and Linear Transformations, Equation 41 */
27 sym:lie_FxHx(phi:u*t+a*b*t^(a+1)*exp(u)-a/t+a*t*(log(t)+c),u,t);
29 symtest(phi,xi:sym[1],eta:sym[2],u,t);
32 sym:ode1_a(phi:b*exp(a*x*y)*x^a+(x^2-1)*y/x-1/x^2+log(x)+c,y,x);
34 symtest(phi,xi:sym[1],eta:sym[2],y,x);
38 E. S. Cheb-Terrab, T. Koloknikov, First Order ODEs,
39 Symmetries and Linear Transformations, Equation 55 */
40 sym:lie_FxHx(phi:f(a*x+b*y),y,x);
42 symtest(phi,xi:sym[1],eta:sym[2],y,x);
45 /* E. S. Cheb-Terrab, T. Koloknikov, First Order ODEs,
46 Symmetries and Linear Transformations, Equation 59 */
47 sym:lie_FxHx(phi:(-y^2+2*x*y-sin(y-x))/x^2,y,x);
49 symtest(phi,xi:sym[1],eta:sym[2],y,x);
53 E. S. Cheb-Terrab, A. D. Roche, Symmetries and First Order ODE Patterns
55 (Need to load pdiff) */
56 symtest(phi:-x^(a-1)*y^(1-b)*H(x^a/a+y^b/b),xi:x^(1-a),eta:-y^(1-b),y,x);
60 symtest(phi:y*(x*log(x^2/y)+2)/x,xi:1,eta:2*y/x,y,x);
64 E. S. Cheb-Terrab, T. Koloknikov, First Order ODEs,
65 Symmetries and Linear Transformations, Equation 28 */
66 sym:ode1_a(phi:(f(x)*g(x^a*y)-a*y)/x,y,x);
67 [x^(1-a)/f(x),-(a*y/(x^a*f(x)))];
68 symtest(phi,xi:sym[1],eta:sym[2],y,x);
72 E. S. Cheb-Terrab, A. D. Roche, Symmetries and First Order ODE Patterns
74 symtest(phi:-(a*y^n-b*x^(n*(m+1)))/x^(n*(m+1)-m),xi:x,eta:(m+1)*y,y,x);
77 /* From Maple odetools docs */
78 sym:ode1_a(phi:f((y-x*log(x))/x)+log(x),y,x);
80 symtest(phi,xi:sym[1],eta:sym[2],y,x);
83 /* Zwillinger p261. This tests case 2.
84 Expected [xi=x,eta=y/2] but this answer is OK */
85 sym:ode1_a(phi:-(y*(y^2-x))/x^2, y, x);
87 symtest(phi,xi:sym[1],eta:sym[2],y,x);
89 symtest(phi,x,y/2,y,x);
90 0; /* The expected answer is OK too */
91 mu:lie_integrating_factor(phi,xi,eta);
93 ans:lie_exact(phi,mu,y,x);
94 -((2*x*y^2-x^2)/(2*y^2))=%c;
95 ans:first(solve(ans,y));
96 y=-x/(sqrt(2)*sqrt(x+%c));
97 ode_check('diff(y,x)=phi,ans);
99 /* and the whole thing in one go */
101 -((2*x*y^2-x^2)/(2*y^2))=%c;
103 /* This is a subcase of the case above. It seems OK */
104 sym:lie_FxHx(phi:(x-%e^(2*u))/x^2,u,x);
106 symtest(phi,xi:sym[1],eta:sym[2],u,x);
109 /* and this is a typo that returns false via case 3 (probably OK) */
110 sym:ode1_a(phi:x^2/(y*(y^2-x)), y, x);
113 /* Murphy 180 - exact - can be solved by ode2() */
114 ode1_lie(phi:y*(1+2*x*y)/x,y,x);
115 false; /* Investigate me */
116 ode1_a(phi:y*(1+2*x*y)/x,y,x);
119 /* Unit tests for lie_symgen_separable
121 solve 'diff(y,x) = phi(x,y) = f(x)*g(y)
123 This is using a sledge hammer to crack walnuts, but educational
126 s:lie_symgen_separable(f:cos(x),g:exp(y),y,x);
128 symtest(phi:f*g,xi:s[1],eta:s[2],y,x);
130 mu:lie_integrating_factor(phi,xi,eta);
132 ans:lie_exact(phi,mu,y,x);
133 %e^-y*(sin(x)*%e^y+1) = %c;
135 [y = -log(%c-sin(x))];
136 ode_check('diff(y,x)=phi,%[1]);
139 s:lie_symgen_separable(f:cos(x),g:tan(y),y,x);
141 symtest(phi:f*g,xi:s[1],eta:s[2],y,x);
143 mu:lie_integrating_factor(phi,xi,eta);
145 ans:lie_exact(phi,mu,y,x);
146 sin(x)-log(sin(y)) = %c;
148 [y = asin(%e^(sin(x)-%c))];
149 ode_check('diff(y,x)=phi,%[1]);
153 /* Unit tests for lie_symgen_linear
155 solve 'diff(y,x) = phi(x,y) = f(x)*y + g(x)
158 s:lie_symgen_linear(f:2,g:1,y,x);
160 symtest(phi:f*y+g,xi:s[1],eta:s[2],y,x);
162 mu:lie_integrating_factor(phi,xi,eta);
163 -2/(2*y-2*%c*%e^(2*x)+1);
164 ans:lie_exact(phi,mu,y,x);
165 2*x-log(-2*y+2*%c*%e^(2*x)-1) = %c;
167 [y = -((%e^(2*x-%c)-2*%c*%e^(2*x)+1)/2)];
168 ode_check('diff(y,x)=phi,%[1]);
171 s:lie_symgen_linear(f:1,g:sin(x)+x,y,x);
172 [1,(sin(x)-cos(x)+2*%c*%e^x-2)/2];
173 symtest(phi:f*y+g,xi:s[1],eta:s[2],y,x);
175 mu:lie_integrating_factor(phi,xi,eta);
176 -2/(2*y+sin(x)+cos(x)-2*%c*%e^x+2*x+2);
177 ans:lie_exact(phi,mu,y,x);
178 x-log(2*y+sin(x)+cos(x)-2*%c*%e^x+2*x+2) = %c;
180 [y = -((sin(x)+cos(x)-%e^(x-%c)-2*%c*%e^x+2*x+2)/2)];
181 ode_check('diff(y,x)=phi,%[1]);
187 kill(ans,eta,f,g,mu,phi,s,sym,xi);