/* Test cases for contrib_ode utility functions */

(load('contrib_ode), done);
done;

bessel_simplify(4*bessel_j(n,x^2)*(x^2-n^2/x^2)
  +x*((bessel_j(n-2,x^2)-bessel_j(n,x^2))*x
  -(bessel_j(n,x^2)-bessel_j(n+2,x^2))*x)
  -2*bessel_j(n+1,x^2)+2*bessel_j(n-1,x^2));
0;

bessel_simplify(((bessel_y(n-2,sqrt(x))-bessel_y(n,sqrt(x)))/(4*sqrt(x))
 -(bessel_y(n,sqrt(x))-bessel_y(n+2,sqrt(x)))/(4*sqrt(x)))
 /(4*sqrt(x))
 +bessel_y(n,sqrt(x))*(1-n^2/x)/(4*x)
 +(bessel_y(n-1,sqrt(x))-bessel_y(n+1,sqrt(x)))/(8*x^(3/2)));
0;

bessel_simplify(-(bessel_k(1,x)*%c-bessel_i(1,x))^2*x^2/(bessel_k(0,x)*%c+bessel_i(0,x))^2
 +x^2
 +x*((-(bessel_k(2,x)+bessel_k(0,x))*%c/2-(bessel_i(2,x)+bessel_i(0,x))/2)*x
    /(bessel_k(0,x)*%c+bessel_i(0,x))
    -(bessel_i(1,x)-bessel_k(1,x)*%c)*(bessel_k(1,x)*%c-bessel_i(1,x))*x
     /(bessel_k(0,x)*%c+bessel_i(0,x))^2
    +(bessel_k(1,x)*%c-bessel_i(1,x))/(bessel_k(0,x)*%c+bessel_i(0,x))));
0;

/* Check Struve H recurrence - integral of bessel_j(2,z)*z^2 dz */
bessel_simplify(diff(3*%pi*(struve_h(1,z)*bessel_j(2,z)-bessel_j(1,z)*struve_h(2,z))*z/2,z)-bessel_j(2,z)*z^2);
0;

/* Check Struve L recurrence - integral of z^v*struve_l(v-1,z) dz DLMF 11.7.3 */
bessel_simplify(diff(z^v*struve_l(v,z),z)-z^v*struve_l(v-1,z));
0;

expintegral_e_simplify(
 (%e^(2*x+2)+(%e*expintegral_e(1,-x-1)*x-%e*expintegral_e(2,-x-1)
 +%e*expintegral_e(1,-x-1))*%e^x)
 /(%e^2*%c^2*x^2+(2*%e^2*%c^2-2*%e*expintegral_e(2,-x-1)*%c)*x+%e^2*%c^2
   -2*%e*expintegral_e(2,-x-1)*%c+expintegral_e(2,-x-1)^2));
0;

expintegral_e_simplify(
 -((2*expintegral_e(1/4,(2*x-1)/4)-2*expintegral_e(-3/4,(2*x-1)/4))*x*(2*x-1)^(3/4)*%e^((4*x-1)/4)+(expintegral_e(5/4,(2*x-1)/4)+2*expintegral_e(1/4,(2*x-1)/4)+expintegral_e(-3/4,(2*x-1)/4))*(2*x-1)^(3/4)*%e^((4*x-1)/4))/(8*x-4));
0;

expintegral_e_simplify(
%e^(-x-2)*(2*%e^(2*x+2)+(4*expintegral_e(2,-2*(x+1))-4*expintegral_e(1,-2*(x+1)))*x^2+(6*expintegral_e(2,-2*(x+1))-4*expintegral_e(3,-2*(x+1)))*x-2*expintegral_e(2,-2*(x+1))+4*expintegral_e(1,-2*(x+1))));
0;

expintegral_e_simplify(
-%e^(-3*x-5)*(x*((100*expintegral_e(2,5*(x-1))+300*expintegral_e(1,5*(x-1)))*%e^(5*x)-100*%e^5)+500*expintegral_e(1,5*(x-1))*x^2*%e^(5*x)+(160*expintegral_e(2,5*(x-1))-800*expintegral_e(1,5*(x-1)))*%e^(5*x)-160*%e^5));
0;

/* verify that ode1_lie doesn't trigger an error on this problem.
 * contrib_ode doesn't appear to be able to solve it, which is OK, I guess.
 */
block ([foo],
 declare (n, integer),
 foo : contrib_ode ('diff(x, t)^2 = alpha - beta*abs(x)^n, x, t),
 remove (n, integer),
 foo);
false;

/* Allow subscripted variables in ode_check */
ode_check('diff(y[2],x[1]),y[2]=%c);
0;

ode_check('diff(x[2],x[1],2)-x[2],x[2]=%e^-x[1]*%k2+%e^x[1]*%k1);
0;
