kill(all)$

maxima : appendix : 'ortho collocation method :sum,legendre',version 1.0
peter.vlasschaert@gmail.com, 08/11/2020

ref :https://math.tntech.edu/machida/1911/maxima/help/maxima_6.html

load packages,option.
=================
use :load ("lrats") loads fullratsubst and lratsubst. 

load(lrats),ratprint:false $

need : packages  ' load(orthopoly)' use :shifted_legendre_p (n, x) := legendre_p (n, 2*x - 1)$

definition : legendre polynomials
---------------------------------------------
see :https://en.wikipedia.org/wiki/Legendre_polynomials
see :http://maxima-online.blogspot.com/2013/01/legendrep.html

p(n,x) := if n=0 then 1 elseif n=1 then x else
expand( ( (2*n-1)/n )*x*p(n-1,x) - ((n-1)/n)*p(n-2,x) )$

p(2,x);

→ shifted legendre : p(n,2*x-1);

get :error  

p(n,2*x-1);

no :error

p(2,2*x-1);

allroots(%);

declare(n,integer);

assume(n>0);

sum
===

see:https://stackoverflow.com/questions/42017107/maxima-how-to-factor-out-a-finite-sum

definition : u(j)
--------------------

p1:u(j):=lratsubst([zz=z[j]],sum(α[i]*(zz)^i,i,0,n));

p1a:declare(sum,linear)$

sumexpand:true; /* default :false */

p2:diff(u(1),z[1]);

p2a:ev(p2,n=5,fullexpand);

→ change variable: i to j 

p2b:changevar(p2, i=j-1, j, i);

p2c:expand(intosum(p2b));

p2d:intosum(part(p2c,1))+intosum(part(p2c,2));

properties(sum);

Function: remove
    remove (a_1, p_1, …, a_n, p_n)
    remove ([a_1, …, a_m], [p_1, …, p_n], …)
    remove ("a", operator)
    remove (a, transfun)
    remove (all, p)

remove(sum,linear)$

p2e:sumcontract(intosum(p2c));

p2e1:intosum(p2d);

p2e2:sumcontract(p2e1);

p2e3:factorsum(p2e2);

→ lost property : sum , remove(sum,linear);

check : properties
-------------------------

properties(sum);

commands: sum : linear, intosum, sumcontract
===================================
simplification : 1e) ratsimp → 2e) intosum → 3e) sumcontract