1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159
|
/* ODE tests */
kill(allbut(props));
done;
/* Trivial ode - bug 866510 */
ode2('diff(y,x),y,x);
y=%c;
/* Examples from "The Maxima Book" */
ode2(x^2*'diff(y,x)+3*x*y=sin(x)/x, y, x);
y = (%C-cos(x))/x^3;
ic1(%, x=1, y=1);
y = -(cos(x)-cos(1)-1)/x^3;
method;
linear;
soln:ode2('diff(y,x,2) + y = 4*x, y, x);
y = %K1*sin(x) + %K2*cos(x) + 4*x;
method;
variationofparameters;
ic2(soln, x=0, y=1, diff(y,x)=3);
y = -sin(x)+cos(x)+4*x;
bc2(soln, x=0, y=3, x=2, y=1);
y = -(3*cos(2)+7)*sin(x)/sin(2) + 3*cos(x) + 4*x;
ode2((3*x^2+4*x+2)=(2*y-1)*'diff(y,x), y, x);
y^2-y = x^3+2*x^2+2*x+%C;
method;
separable;
ode2(x^2*cos(x*y)*'diff(y,x) + (sin(x*y)+x*y*(cos(x*y)))=0, y, x);
x*sin(x*y)=%C;
method;
exact;
ode2( (2*x*y-exp(-2*y))*'diff(y,x)+y=0, y, x);
x*exp(2*y) - log(y) = %C;
method;
exact;
intfactor;
exp(2*y)/y;
ode2( 'diff(y,x)=(y/x)^2+2*(y/x), y, x);
-(x*y+x^2)/y = %C;
method;
exact;
ode2( 'diff(y,x)+(2/x)*y=(1/x^2)*y^3, y, x);
y = 1/(sqrt( 2/(5*x^5) + %C)*x^2);
method;
bernoulli;
odeindex;
3;
ode2( 'diff(y,x,2)-3*'diff(y,x)+2*y=0, y, x);
y = %K1*exp(2*x) + %K2*exp(x);
method;
constcoeff;
ode2( 'diff(y,x,2)-4*'diff(y,x)+4*y=0, y, x);
y = (%K2*x + %K1)*exp(2*x);
method;
constcoeff;
ode2(x^2*'diff(y,x,2)+x*'diff(y,x)-y=0, y, x);
y=%K2*x-%K1/(2*x);
method;
exact;
ode2( x^2*'diff(y,x,2)+4*x*'diff(y,x)+2*y=0, y, x);
y=%K1/x+%K2/x^2;
method;
exact; /*euler*/
ode2( x^2*'diff(y,x,2)+5*x*'diff(y,x)+4*y=0, y, x);
y=(%K2*log(x)+%K1)/x^2;
method;
euler;
ode2( x^2*'diff(y,x,2)+x*'diff(y,x)+(x^2-1/4)*y=0, y, x);
y=(%K1*sin(x)+%K2*cos(x))/sqrt(x);
method;
bessel;
ode2( x^2*'diff(y,x,2)+x*'diff(y,x)+(x^2-4)*y=0, y, x);
y=%K1*%J[2](x)+%K2*%Y[2](x);
method;
bessel;
ode2( (x-1)^2*'diff(y,x,2)+(x-1)*'diff(y,x)+((x-1)^2-4)*y=0, y, x);
y=%K1*%J[2](x-1)+%K2*%Y[2](x-1);
method;
bessel;
ode2( 'diff(y,x,2)+2*'diff(y,x)+y=exp(x), y, x);
y=exp(x)/4+(%K2*x+%K1)*exp(-x);
method;
variationofparameters;
yp;
exp(x)/4;
ode2( x*'diff(y,x,2)+('diff(y,x))^2=0, y, x);
y='integrate(1/(log(x)+%K1),x)+%K2;
method;
freeofy;
ode2( y*'diff(y,x,2)+('diff(y,x))^2=0, y, x);
y^2/(2*%K1)=x+%K2;
method;
freeofx;
eq: 'diff(y,x,2)+x*'diff(y,x)+exp(-x^2)*y=0;
'diff(y,x,2)+x*'diff(y,x,1)+%e^-x^2*y = 0;
ans:ode2(eq,y,x);
y = %k1*sin(sqrt(2)*sqrt(%pi)*erf(x/sqrt(2))/2)+%k2*cos(sqrt(2)*sqrt(%pi)*erf(x/sqrt(2))/2);
is(ratsimp(ev(eq,ans,diff)));
true;
method;
xformtoconstcoeff;
eq:x*'diff(y,x,2)+(x^2-1)*'diff(y,x,1)+x^3*y=0;
x*'diff(y,x,2)+(x^2-1)*'diff(y,x,1)+x^3*y=0;
ans:ode2(eq,y,x);
y=%e^-(x^2/4)*(%k1*sin(sqrt(3)*x^2/4)+%k2*cos(sqrt(3)*x^2/4));
is(ratsimp(ev(eq,ans,diff)));
true;
method;
xformtoconstcoeff;
/* Tests of desolve */
eqn1:'diff(f(x),x) = sin(x)+'diff(g(x),x);
'diff(f(x),x,1) = 'diff(g(x),x,1)+sin(x);
eqn2:'diff(g(x),x,2) = 'diff(f(x),x)-cos(x);
'diff(g(x),x,2) = 'diff(f(x),x,1)-cos(x);
desolve([eqn1,eqn2],[f(x),g(x)]);
[f(x)=%e^x*(at('diff(g(x),x,1),x = 0))-at('diff(g(x),x,1),x = 0)+f(0),g(x)=%e^x*(at('diff(g(x),x,1),x=0))-at('diff(g(x),x,1),x = 0)+cos(x)+g(0)-1];
atvalue('diff(g(x),x),x = 0,a);
a;
atvalue(f(x),x = 0,1);
1;
desolve([eqn1,eqn2],[f(x),g(x)]);
[f(x) = a*%e^x-a+1,g(x) = cos(x)+a*%e^x-a+g(0)-1];
remove(f,atvalue,g,atvalue);
done;
atvalue('diff(g(x),x),x = 0,a);
a;
atvalue(f(x),x = 0,1);
1;
desolve([eqn1,eqn2],[f(x),g(x)]);
[f(x) = a*%e^x-a+1,g(x) = cos(x)+a*%e^x-a+g(0)-1];
eqn3: 'diff(f(x),x,2)+f(x)=2*x;
'diff(f(x),x,2)+f(x)=2*x;
desolve(eqn3,f(x));
f(x) = sin(x)*(at('diff(f(x),x,1),x = 0)-2)+f(0)*cos(x)+2*x;
|