You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
how can I use summation and index for the series
1 view (last 30 days)
Show older comments
how can I use summation and index for the following series by using matlab
Edit:
the pervious Equation solution for
My trying to write the following code, but i don't know if it is right ot no
u0=0;
alpha=0.5;%[0.1 0.3 0.5 0.6 0.66 0.9 1]; matrix
a=0; b=1;n=100;
h=(b-a)/n;
t=a:h:b;
f=@(t,u) (-u.^4) + ( gamma(2*alpha+1)./gamma(alpha+1) ).*(t.^alpha) - ( 2./gamma(3-alpha) ).*(t.^(2-alpha)) + (t.^(2*alpha)-t.^2).^4;
exact=@(t) t.^(2*alpha)-t.^2;
%-----a'ks---------------------------------------
a_kth=@(k) (k+1).^(1-alpha)-(k).^(1-alpha);
u_p=zeros(1,n); z_p=zeros(1,n); u=zeros(1,n);
s=0;
for i=1
u_p(i)=a_kth(i-1)*u0; %s=s+q^keval(subs(fun,xq^k));
z_p(i)=gamma(2-alpha)*( h.^alpha ) * f(t(i),u_p(i));
u(i)=u_p(i)+gamma(2-alpha)*( h.^alpha ) * f(t(i),u_p(i)+z_p(i));
end
%--------------------------------------
for i=2:n
for k=1:i-1
s=s+(a_kth(i-1-k)-a_kth(i-k))*u(k);
u_p(i)=a_kth(i-1)*u0+s; %s=s+q^keval(subs(fun,xq^k));
z_p(i)=gamma(2-alpha)*( h.^alpha ) * f(t(i),u_p(i));
u(i)=u_p(i)+gamma(2-alpha)*( h.^alpha ) * f(t(i),u_p(i)+z_p(i));
end
end
u1=[ u0 u];
plot(t,u1)
exact1=exact(t);
error=exact1-u1;
17 Comments
Walter Roberson
on 24 May 2022
I suspect that in practice you are going to need to use a loop or arrayfun()
work wolf
on 24 May 2022
@Walter Roberson thank you for your comment, please can you guid me about code?
Torsten
on 24 May 2022
Be careful with the 0-indices for u and a, but check whether
sum(-diff(a).*u(n:-1:1))
works for
sum_{k=1}^(n-1)(a_{n-1-k}-a_{n-k})*u_{k}
Torsten
on 24 May 2022
Then supply a, n alpha, h, f and t.
Is it correct that f depends on u_n and thus the equation above must be solved for u_n by a root finder ?
work wolf
on 25 May 2022
u0=0;
alpha=[0.1 0.3 0.5 0.6 0.66 0.9 1]; %multi values (matrix)
a=0; b=1;n=100;
h=(b-a)/n;
t=a:h:b;
f=@(t,u) (-u.^4) + ( gamma(2*alpha+1)./gamma(alpha+1) ).*(t.^alpha) - ( 2./gamma(3-alpha) ).*(t.^(2-alpha)) + (t.^(2*alpha)-t.^2).^4;
exact=@(t) t.^(2*alpha)-t.^2;
%-----a'ks---------------------------------------
a_kth=@(k) (k+1).^(1-alpha)-(k).^(1-alpha);
%----------------------------------------------
Torsten
on 25 May 2022
In f, how do you want to evaluate t^alpha ? t and alpha have a different number of elements.
You should explain the background of your question so that we are able to understand what you are trying to do in your code.
work wolf
on 25 May 2022
the code for each alpha, i.e the code run for o.1 then repeate all steps for another value as 0.3. in same time, can you evaluate for one element as alpha= 0.1 then change alpha to 0.3, manually. i hope understand me :)
Torsten
on 25 May 2022
Again my question:
Is it correct that f depends on u_n and thus the equation above must be solved for u_n by a root finder ?
work wolf
on 25 May 2022
Edited: work wolf
on 25 May 2022
Note: i am trying to write the folowing code , but i don't know if it right or wrong?!
u0=0;
alpha=0.5;%[0.1 0.3 0.5 0.6 0.66 0.9 1]; matrix
a=0; b=1;n=100;
h=(b-a)/n;
t=a:h:b;
f=@(t,u) (-u.^4) + ( gamma(2*alpha+1)./gamma(alpha+1) ).*(t.^alpha) - ( 2./gamma(3-alpha) ).*(t.^(2-alpha)) + (t.^(2*alpha)-t.^2).^4;
exact=@(t) t.^(2*alpha)-t.^2;
%-----a'ks---------------------------------------
a_kth=@(k) (k+1).^(1-alpha)-(k).^(1-alpha);
u_p=zeros(1,n); z_p=zeros(1,n); u=zeros(1,n);
s=0;
for i=1
u_p(i)=a_kth(i-1)*u0; %s=s+q^keval(subs(fun,xq^k));
z_p(i)=gamma(2-alpha)*( h.^alpha ) * f(t(i),u_p(i));
u(i)=u_p(i)+gamma(2-alpha)*( h.^alpha ) * f(t(i),u_p(i)+z_p(i));
end
%--------------------------------------
for i=2:n
for k=1:i-1
s=s+(a_kth(i-1-k)-a_kth(i-k))*u(k);
u_p(i)=a_kth(i-1)*u0+s; %s=s+q^keval(subs(fun,xq^k));
z_p(i)=gamma(2-alpha)*( h.^alpha ) * f(t(i),u_p(i));
u(i)=u_p(i)+gamma(2-alpha)*( h.^alpha ) * f(t(i),u_p(i)+z_p(i));
end
end
u1=[ u0 u];
plot(t,u1)
exact1=exact(t);
error=exact1-u1;
Torsten
on 25 May 2022
But then - starting from u(1) - you will have to solve a nonlinear equation for u(i). Is that true ?
Torsten
on 25 May 2022
I have no experience with fractional order differential equations, but since your computations diverge, something must be wrong with the implementation.
Torsten
on 25 May 2022
You should include a link where the forum can find the discretization used in your code.
Answers (0)
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Select a Web Site
Choose a web site to get translated content where available and see local events and offers. Based on your location, we recommend that you select: .
You can also select a web site from the following list
How to Get Best Site Performance
Select the China site (in Chinese or English) for best site performance. Other MathWorks country sites are not optimized for visits from your location.
Americas
- América Latina (Español)
- Canada (English)
- United States (English)
Europe
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom(English)
Asia Pacific
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)