how to find a function written as a series

5 views (last 30 days)
i tried to solve the following u(n+1)=-int((x-t)*u(n),t,0,x)
where n from 0 to in but matlab say to not use inf so i want to try it up to100 at least is it possible ?
wha i try asfollows but still have something missed
is any way to use index like sum(ui)=u0+u1+u3+.....
and how to find the answer using taylor seires
(this is to solve an integral equation using Adomiandecomposition method)
syms x t u
a=0;
b=x;
f=(x-t);
u0=-2+3*x-x^2;
for k=1:inf %or k=1:100 at least
u = -1*int(f*u,t,a,b);
end
u=u0+u

Accepted Answer

Paul
Paul on 24 Nov 2024
Edited: Paul on 24 Nov 2024
Would be nice to see the actual mathematical equation to be solved. Assuming the equation and solution follows the exposition at Adomian decomposition method, the first n terms of the solution would be constructed as
syms x t
a = 0;
b = x;
f = (x-t);
u0 =-2 + 3*x - x^2;
u(1) = u0;
for k=2:10 %or k=1:100 at least
u(k) = -1*int(f*subs(u(k-1),x,t),t,a,b);
end
u,disp(char(u))
[3*x - x^2 - 2, (x^2*(x^2 - 6*x + 12))/12, -(x^4*(x^2 - 9*x + 30))/360, (x^6*(x^2 - 12*x + 56))/20160, -(x^8*(x^2 - 15*x + 90))/1814400, (x^10*(x^2 - 18*x + 132))/239500800, -(x^12*(x^2 - 21*x + 182))/43589145600, (x^14*(x^2 - 24*x + 240))/10461394944000, -(x^16*(x^2 - 27*x + 306))/3201186852864000, (x^18*(x^2 - 30*x + 380))/1216451004088320000]
temp = u; % save for later
Summing the u(k) together yields a series-like expression
u = simplify(sum(u)),disp(char(u))
3*x - x^3/2 + x^5/40 - x^7/1680 + x^9/120960 - x^11/13305600 + x^13/2075673600 - x^15/435891456000 + x^17/118562476032000 - x^19/40548366802944000 + x^20/1216451004088320000 - 2
figure
hax = gca;
fplot(u,[0,10])
We can also get a closed form expression for u(x)
syms k n integer
term0(n) = (-1)^(n+1);
term1(n) = x^(2*n);
term2(n) = 3*(n+1);
term3(n) = simplify(symsum(2 + 8*k,k,0,n));
term4(n) = piecewise(n==0,1,symprod(term3(k),k,1,n));
u(n) = term0(n)*term1(n)*(x^2 - term2(n)*x + term3(n))/term4(n);
u(n) = simplify(u(n)),disp(char(u(n)))
(2*(-1)^(n + 1)*x^(2*n)*(6*n - 3*x - 3*n*x + 4*n^2 + x^2 + 2))/factorial(2*n + 2)
% verify against previous solution
double(simplify(temp-u(0:9)))
ans = 1×10
0 0 0 0 0 0 0 0 0 0
<mw-icon class=""></mw-icon>
<mw-icon class=""></mw-icon>
Closed for expression for u(x)
u(x) = symsum(u(n),n,0,inf),disp(char(u(x)))
2*x^2*(cosh(x*1i)/x^2 - 1/x^2) + (4*cosh(x*1i))/x^2 + (x^2*hypergeom(2, [5/2, 3], -x^2/4))/2 - (x^3*hypergeom(2, [5/2, 3], -x^2/4))/4 + (x^2*hypergeom([2, 2], [1, 5/2, 3], -x^2/4))/3 - 4/x^2 - 6*x*(cosh(x*1i)/x^2 - 1/x^2)
figure
fplot([sum(temp),u(x)],[0,10])
It would be nice to know the actual equation that the OP is trying to solve.
  2 Comments
Aya
Aya on 25 Nov 2024
Edited: Aya on 25 Nov 2024
the actual equation
Torsten
Torsten on 25 Nov 2024
For comparison: solution is
u(x) = 3*sin(x)-2
syms u(x) v(x) t
eqns = [diff(u,x)==3-2*x-v,diff(v,x)==u];
conds = [u(0)==-2,v(0)==0];
sol = dsolve(eqns,conds);
usol(x) = simplify(sol.u)
ucomp = -2+3*x-x^2-int((x-t)*usol(t),t,0,x)

Sign in to comment.

More Answers (0)

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!