kill(all)$

math:solve differential equations with infinite sums( example),version 1.0
peter.vlasschert@gmail.com,18/04/2020

load ,packages
=============

load(simplify_sum)$

load(lrats)$

load(contrib_ode)$

example : ode (1)
===========

p1:'diff(y,x) + 2*x*y =0;

1e) We assume form 
=================

y=a0+a1*x+a2*x^2+a3*x^3+......... (2)

Mathematical : representation 'Maxima'
==============================

p1a:y=sum (a[i]*x^i, i, 0, inf);

needed later :check sequence,final solution,rhs(infinite to finite integer)

1e) step : find  y'
-----------------------

p1b:'diff(y,x) =diff(rhs(p1a),x);

2e) write differential equation (1)
---------------------------------------------

p1c:rhs(p1b)+2*x*rhs(p1a)=rhs(p1);

p1d:intosum(lhs(p1c))=0;

show :sumcontract works when sum ranges are the same
============================================
rule :sumcontract

p1e:sumcontract(lhs(p1d))=0;

lhs :ode (two sums)
======

first sum : 
=======

p1da:part(p1d,1,1);

power (x): i→n-1

p1da1:changevar(%,i=n-1,n,i);

p1da2:intosum(p1da1);

second sum : 
==========

p1db:part(p1d,1,2);

p1db1:changevar(%,i=n+1,n,i),sumexpand;

check : n=-1 no contribution:summation
------------------------------------------------------

p1db1a:args(p1db1);

p1db2a:part(p1db1a[1],1);

p1b3a:subst([p1db1a[2]=p1db1a[3]],p1db2a);

symbol : n , inside

p1db2:sum(p1db1a[1],n,p1b3a,p1db1a[4]);

because :first       sum :x^n  :start value:  n=1
                 second sum:x^n : start  value : n=0

sum((n+1)*a[n+1]*x^n,n,0,inf) =
sum((n+1)*a[n+1]*x^n,n,0,0) +sum((n+1)*a[n+1]*x^n,n,1,inf) 

modification :

p2:sum((n+1)*a[n+1]*x^n,n,0,inf) =sum((n+1)*a[n+1]*x^n,n,0,0) +sum((n+1)*a[n+1]*x^n,n,1,inf);

combination : first & second sum
---------------------------------------------

p3:p1da2+rhs(p2) =0;

p3a:sumcontract(lhs(p3)) =0;

p3b:factor(lhs(p3a))=0;

math :a[1]=0, ? How to find factor from x^n

p3c:subst([a[1]=0],p3b);

p3c1:args(lhs(p3c));

math: factor before x^n =0

p3c2:p3c1[1]/x^n=0;

solve :a[n+1]?
--------------------
use :p3c2

p3c3:solve(p3c2,a[n+1]);

p3c3a:p3c3[1];

We need to find : a[n]
------------------------------

p4:subst([n=n-1],p3c3a);

p4a:makelist(ev(p4,nouns),n,2,10);

we need to put a[1] =0
--------------------------------

p4b:subst([a[1] =0],p4a);

view eyes : odd terms are zero, only list even terms.
-----------------------------------------------------------------------
odd terms    =0
even terms   ≠ 0
a[0]:arbitrary

p4b1:makelist(p4b[i],i,1,10,2);

p4b1a:[first(p4b1)];

p4b2:makelist(subst([p4b1[q]],p4b1[q+1]),q,1,length(p4b1)-1);

p4b2a:[first(p4b2)];

→ a[0] needed rhs

p4b3:subst([first(p4b1)],p4b2);

p4b3a:[second(p4b3)];

p4b4:subst([first(p4b3)],p4b3);

p4b4a:[p4b4[3]];

rem : 5! =120

p4b5:subst([p4b4[2]],p4b4[4]);

p4b5a:[p4b5];

p4b55:[p4b1a,p4b2a,p4b3a,p4b4a,p4b5a],flatten;

p4b55a:flatten(p4b55);

first we write:finite sequence ricognition pattern
==========
y =solution

p5:sum (a[i]*x^i, i, 0,10);

p5a:args(p5);

p5b:reverse(p5a);

remove:odd index
--------------------------

p5c:makelist(p5b[i],i,1,11,2);

p5c1:lhs(p1a)=sum(p5c[i],i,1,length(p5c));

p5c2:subst(p4b55a,p5c1);

p5c3:lhs(p5c2)=factorout(rhs(p5c2),a[0]);

1! =1,2!=2,3!=6,4!=24,5!=120,

y=CC*a[0]

p5c4:y=CC*a[0];

find :CC
------------

p5c5:rhs(p5c3) = rhs(p5c4);

p5c6:solve(p5c5,CC),expand;

sign =infinite +,-,+,-
→   infinite series 

general term
==========

p5d:(-1)^n*x^(2*n)/n!;

check :true sequences

p5d1:subst([n=5],p5d);

infinite sum : simplify_sum

p5d2:sum(p5d,n,0,inf),simplify_sum;

final solution
==========
use:p5c4

p5d3:subst([CC=p5d2],p5c4);

method 1 :check by subst,'p1'
-----------------------------------------

p6a:subst([p5d3],p1);

p6b:ev(p6a,diff);

p6c:is(p6b);

method 2:ode2 'Maxima'
------------------------------------

p7a:ode2(p1,y,x);

p7b:[rhs(p5d3)=rhs(p7a)]/p5d2;

method 3:contrib_ode 'Maxima'
--------------------------------------------
needed :packages

p8a:contrib_ode(p1,y,x);

====================================================================