I am solving non-linear fractional model using spectral method . So At last stage to find coefficient I have large number of nonlinear system equation how to solve using fsolv
I want to solve large number of nonlinear system of equation using fsolve . I am solving by assigning in f as f =@(c,d,e) []; likewaise but in these process i have to copy the equation in commaand window after running the code and put in f the we solve using fsolve but these is lengthy process for large value of N. pleases provide some code for shortcut.
clc;
close all
clear all
syms x k l p m h y k0 r
N=7;
size=3;gamma1=1;gamma2=1;gamma3=1;gamma4=1;
for i7=1:N
syms c(i7)
end
for i8 =1:N
syms d(i8)
end
for i9 =1:N
syms e(i8)
end
for i=1:N
symsX(i,:) = c(i);
end
for i=1:N
symsY(i,:) = d(i);
end
for i=1:N
symsZ(i,:) = e(i);
end
C1 = transpose(symsX)
%sym(‘c’, [1 N]);
C2 = transpose(symsY)
C3 = transpose(symsZ)
%A=c;
equations = sym(zeros(1,N));
D = [];L=1;
G = [];
Dv1 = [];
Dv2 = [];
v1 = 1;
v2 = 1;
for i=1:N
if i==1
n(i)=2
else
n(i)=1
end
end
for i=1:N
h(i) = (n(i)*pi)/2;
end
k1=1;k2=3;k3=5;k4=7;k5=9;k6=11;k7=13;k8=15;k9=17;k10=19;k11=21;k12=23;k14=25;k15=27;k16=29;
for i=1:N
for j=1:N
if(j==i-k1)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k2)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k3)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k4)
D(i,j)=((4*(i-1))/(n(j)*L)) ;
elseif(j==i-k5)
D(i,j)= ((4*(i-1))/(n(j)*L)) ;
elseif(j==i-k6)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k7)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k8)
D(i,j)= ((4*(i-1))/(n(j)*L))
elseif(j==i-k9)
D(i,j)= ((4*(i-1))/(n(j)*L))
elseif(j==i-k10)
D(i,j)= ((4*(i-1))/(n(j)*L))
else
D(i,j)=0;
end
end
end
for m=1:N
symT(m,:) = chebyshevT(m-1,2*x-1)
end
H(x) = symT
%% legender operational matrix for fractional derivatives
%% d^n(symT)/dx^n = (D^n)*symT
%B = D*symT
%% Dv is the COM derivative of oder v>0 the caputo sense
Dv1=[];
t=ceil(v1)
for i=1:N
for j=1:N
if(i<=t)
Dv=zeros(t,j);
elseif (j==1)
Dv1(i,j) = symsum(((((i-1)*(-1)^(i-1-k)*factorial(i-1+k-1)*2^(2*k)*factorial(k)*gamma(k-v1+1/2))/(L^(v1)*factorial(i-1-k)*factorial(2*k)*sqrt(pi)*(gamma(k-v1+1)^(2))))),k,t,i-1);
else
Dv1(i,j) = (i-1)*symsum(((((-1)^((i-1)-k0)*(j-1)*factorial(i-1+k0-1)*(2^(2*k0+1))*factorial(k0))/(L^(v1)*factorial((i-1)-k0)*factorial(2*k0)*sqrt(pi)*(gamma(k0-v1+1))))*symsum((((-1)^(j-1-r)*factorial(j-1+r-1)*(2^(2*r))*gamma(k0+r-v1+1/2))/(factorial(j-1-r)*factorial(2*r)*gamma(k0+r-v1+1))),r,0,j-1)),k0,t,i-1)
%Dv(i,j)= symsum(((((-1)^((i-1)-k)*(2*(i-1))*factorial((i-1)+k-1)*gamma(k-v+(1/2)))/(n(j)*L^(v)*gamma(k+(1/2))*factorial((i-1)-k)*gamma(k-v-(j-1)+1)*gamma(k+(j-1)-v+1)))),k,t,i-1)
% Dv(i,j)=symsum(((2*(j-1)+1)*symsum((((-1)^((i-1)+(j-1)+k+l)*factorial((i-1)+k)*factorial(l+(j-1)))/(factorial((i-1)-k)*factorial(k)*gamma(k-v+1)*factorial((j-1)-l)*(factorial(l))^(2)*(k+l-v+1))),l,0,j-1)),k,t,i-1);
end
end
end
Dv2=[];
t=ceil(v2)
for i=1:N
for j=1:N
if(i<=t)
Dv2=zeros(t,j);
elseif (j==1)
Dv2(i,j) = symsum(((((i-1)*(-1)^(i-1-k)*factorial(i-1+k-1)*2^(2*k)*factorial(k)*gamma(k-v2+1/2))/(L^(v2)*factorial(i-1-k)*factorial(2*k)*sqrt(pi)*(gamma(k-v2+1)^(2))))),k,t,i-1);
else
Dv2(i,j) = (i-1)*symsum(((((-1)^((i-1)-k0)*(j-1)*factorial(i-1+k0-1)*(2^(2*k0+1))*factorial(k0))/(L^(v2)*factorial((i-1)-k0)*factorial(2*k0)*sqrt(pi)*(gamma(k0-v2+1))))*symsum((((-1)^(j-1-r)*factorial(j-1+r-1)*(2^(2*r))*gamma(k0+r-v2+1/2))/(factorial(j-1-r)*factorial(2*r)*gamma(k0+r-v2+1))),r,0,j-1)),k0,t,i-1)
%Dv(i,j)= symsum(((((-1)^((i-1)-k)*(2*(i-1))*factorial((i-1)+k-1)*gamma(k-v+(1/2)))/(n(j)*L^(v)*gamma(k+(1/2))*factorial((i-1)-k)*gamma(k-v-(j-1)+1)*gamma(k+(j-1)-v+1)))),k,t,i-1)
% Dv(i,j)=symsum(((2*(j-1)+1)*symsum((((-1)^((i-1)+(j-1)+k+l)*factorial((i-1)+k)*factorial(l+(j-1)))/(factorial((i-1)-k)*factorial(k)*gamma(k-v+1)*factorial((j-1)-l)*(factorial(l))^(2)*(k+l-v+1))),l,0,j-1)),k,t,i-1);
end
end
end
y(1) = C1*H;y(2)=C2*H;y(3)=C3*H
g=zeros(N,1);a=1;b=1;c=1;d=1;
% xmin=0;xmax=1;
% for i = 1:N
% f = @(x) (1+x) .* (1 ./ sqrt(L.*x – x.^2)); % Define f(x) inside the loop
% func = @(x) f(x) .* chebyshevT(i-1, (2*x/L) – 1); % Define the function to integrate
% g(i) = (1 / h(i)) .* integral(func, xmin, xmax);
% end
%% solve system of fractional order D^(1.5)y1 = y2 $ D^(0.5) = -y2-y1+1+x
z1=1:N-1
R(z1)=vpa(solve(chebyshevT(N-1,2*x-1),x),5)
%D1 = sort(R,’descend’)
%G = transpose(g);
H1(x) = diff(H(x));
R1 = (C1*Dv1*H-gamma1*((C1*H)-(C2*H)));
R2 = (C2*Dv1*H+(4*gamma1*(C2*H))-((C1*H)*(C3*H))-(gamma2*(C1*H)^(3)));
R3 = (C3*Dv1*H+(gamma1*gamma4*(C3*H))-(((C1*H)^(3))*(C2*H))-(gamma3*(C3*H)^(2)));
% R1 = ((C1*Dv1*H)-a.*(y(1))+b.*((y(1)).*(y(2))));
% R2 = ((C2*Dv1*H)-c.*(((y(1)).*(y(2))))+d.*((y(2))));
t1=ceil(v1);t2=ceil(v2);
for i = 1:N-t1
eqn0(i) = R1(R(i))
%eqn0(i) = int((R1*chebyshevT(i-1,2*x-1)),x,0,1)
end
for i=1:N-t1
eqn1(i) = R2(R(i))
end
for i=1:N-t1
eqn2(i) = R3(R(i))
end
eqn3=(C1)*H(0)-2.6;
eqn4=(C2)*(H(0))-1.8;
eqn5 = (C3)*(H(0))-2.5;
equations1 = [eqn0,eqn1,eqn2,eqn3,eqn4,eqn5];
f =@(c,d,e) [2.7071067811865532348747365176678*c(2) – c(1) – 5.6568542494924420306571438691514*c(3) + 5.292893218813663426931852838572*c(4) + 0.99999999999963452967090203902407*c(5) – 10.707106781186253043585270572838*c(6) + 16.970562748477326091971431589745*c(7) + d(1) – 0.70710678118655323487473651766777*d(2) + 0.000000000000016151659251727809284198242756759*d(3) + 0.70710678118653039297916789513938*d(4) – 0.99999999999999999999999999947825*d(5) + 0.70710678118657607677030513945829*d(6) – 0.000000000000048454977755183427852594727351922*d(7); 1.2928932188133330782875418663025*c(2) – c(1) + 5.6568542494929976671048748761924*c(3) + 6.7071067811902418116034852470151*c(4) + 1.0000000000076414279432830892593*c(5) – 9.2928932188061013571452785519551*c(6) – 16.970562748478993001314616886895*c(7) + d(1) + 0.70710678118666692171245813369751*d(2) + 0.00000000000033770659479019338766497999870797*d(3) – 0.70710678118618933246600292636309*d(4) – 0.99999999999999999999999977190851*d(5) – 0.70710678118714451095891301846186*d(6) – 0.0000000000010131197843705801629949407484403*d(7);
2.2588190451025411675800569355488*c(2) – c(1) – 1.2045269570359118189265060549051*c(3) – 5.0994116265996025979660812602431*c(4) + 6.6726037773448918964171398156432*c(5) + 3.6454177505992816039159838845192*c(6) – 12.423314164921193664470552934672*c(7) + d(1) – 0.25881904510254116758005693554878*d(2) – 0.86602540378441752171394942948519*d(3) + 0.70710678118659233739868810642085*d(4) + 0.49999999999992682068095891830983*d(5) – 0.96592582628909562457579410802636*d(6) + 0.00000000000012675029864244296874022498106152*d(7); 1.741180954897572519257664680481*c(2) – c(1) + 2.9365777646039550649277513046591*c(3) – 3.6851980642280799640942290841422*c(4) – 7.6726037773429774645179663364753*c(5) + 1.7135660980270430271605604380751*c(6) + 12.42331416492125455483396912414*c(7) + d(1) + 0.25881904510242748074233531951904*d(2) – 0.8660254037845352189890687485068*d(3) – 0.70710678118634266377459589793939*d(4) + 0.50000000000033453600179708174969*d(5) + 0.96592582628894331309400622678268*d(6) – 0.00000000000057943335207356344385823017649482*d(7);
2.9659258262890944024547934532166*c(2) – c(1) – 8.5934320140972947697379899486242*c(3) + 17.099411626601236173895770571656*c(4) – 27.268521719614045141886628745433*c(5) + 37.579327120800789878210967353833*c(6) – 46.364439661893342936680399633656*c(7) + d(1) – 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) – 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) – 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449564958666*d(7); 1.0340741737109055975452065467834*c(2) – c(1) + 6.8613812065282156695387053028407*c(3) + 15.685198064227713028495645177746*c(4) + 26.268521719613346063068768060046*c(5) + 37.061689030594773702131939269591*c(6) + 46.364439661892132096649369596372*c(7) + d(1) + 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) + 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) + 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449492408624*d(7);
4*d(1) – 0.82842712474621293949894607067108*d(2) – 5.656854249492361272360885230105*d(3) + 8.8284271247463153918276923142689*d(4) – 4.0000000000003654703290979583672*d(5) – 7.1715728752533726597337448755461*d(6) + 16.970562748477083817082655672606*d(7) – (c(1) – 0.70710678118655323487473651766777*c(2) + 0.000000000000016151659251727809284198242756759*c(3) + 0.70710678118653039297916789513938*c(4) – 0.99999999999999999999999999947825*c(5) + 0.70710678118657607677030513945829*c(6) – 0.000000000000048454977755183427852594727351922*c(7))*(e(1) – 0.70710678118655323487473651766777*e(2) + 0.000000000000016151659251727809284198242756759*e(3) + 0.70710678118653039297916789513938*e(4) – 0.99999999999999999999999999947825*e(5) + 0.70710678118657607677030513945829*e(6) – 0.000000000000048454977755183427852594727351922*e(7)) – (c(1) – 0.70710678118655323487473651766777*c(2) + 0.000000000000016151659251727809284198242756759*c(3) + 0.70710678118653039297916789513938*c(4) – 0.99999999999999999999999999947825*c(5) + 0.70710678118657607677030513945829*c(6) – 0.000000000000048454977755183427852594727351922*c(7))^3;
4*d(1) + 4.82842712474666768684983253479*d(2) + 5.6568542494946862000788258431307*d(3) + 3.1715728752592951492734706151996*d(4) – 3.9999999999923585720567157702833*d(5) – 12.828427124741823911939843644264*d(6) – 16.97056274848405860023646978771*d(7) + (0.70710678118618933246600292636309*c(4) – 0.70710678118666692171245813369751*c(2) – 0.00000000000033770659479019338766497999870797*c(3) – c(1) + 0.99999999999999999999999977190851*c(5) + 0.70710678118714451095891301846186*c(6) + 0.0000000000010131197843705801629949407484403*c(7))^3 – (0.70710678118618933246600292636309*c(4) – 0.70710678118666692171245813369751*c(2) – 0.00000000000033770659479019338766497999870797*c(3) – c(1) + 0.99999999999999999999999977190851*c(5) + 0.70710678118714451095891301846186*c(6) + 0.0000000000010131197843705801629949407484403*c(7))*(0.70710678118618933246600292636309*e(4) – 0.70710678118666692171245813369751*e(2) – 0.00000000000033770659479019338766497999870797*e(3) – e(1) + 0.99999999999999999999999977190851*e(5) + 0.70710678118714451095891301846186*e(6) + 0.0000000000010131197843705801629949407484403*e(7));
4*d(1) + 0.96472381958983532967977225780487*d(2) – 5.534653975957999427496253202331*d(3) – 1.5638777206666409109726407281389*d(4) + 9.1726037773445259998219344071924*d(5) – 1.1842113808461965189629866556126*d(6) – 12.423314164920559912977340719828*d(7) – (c(1) – 0.25881904510254116758005693554878*c(2) – 0.86602540378441752171394942948519*c(3) + 0.70710678118659233739868810642085*c(4) + 0.49999999999992682068095891830983*c(5) – 0.96592582628909562457579410802636*c(6) + 0.00000000000012675029864244296874022498106152*c(7))*(e(1) – 0.25881904510254116758005693554878*e(2) – 0.86602540378441752171394942948519*e(3) + 0.70710678118659233739868810642085*e(4) + 0.49999999999992682068095891830983*e(5) – 0.96592582628909562457579410802636*e(6) + 0.00000000000012675029864244296874022498106152*e(7)) – (c(1) – 0.25881904510254116758005693554878*c(2) – 0.86602540378441752171394942948519*c(3) + 0.70710678118659233739868810642085*c(4) + 0.49999999999992682068095891830983*c(5) – 0.96592582628909562457579410802636*c(6) + 0.00000000000012675029864244296874022498106152*c(7))^3;
4*d(1) + 3.0352761804097099229693412780762*d(2) – 1.3935492543187210300175924378749*d(3) – 7.2207319701597932829672085738392*d(4) – 5.1726037773413047845089809277269*d(5) + 6.5431952294717595926305915719885*d(6) + 12.423314164918357388073601306921*d(7) – (c(1) + 0.25881904510242748074233531951904*c(2) – 0.8660254037845352189890687485068*c(3) – 0.70710678118634266377459589793939*c(4) + 0.50000000000033453600179708174969*c(5) + 0.96592582628894331309400622678268*c(6) – 0.00000000000057943335207356344385823017649482*c(7))*(e(1) + 0.25881904510242748074233531951904*e(2) – 0.8660254037845352189890687485068*e(3) – 0.70710678118634266377459589793939*e(4) + 0.50000000000033453600179708174969*e(5) + 0.96592582628894331309400622678268*e(6) – 0.00000000000057943335207356344385823017649482*e(7)) – (c(1) + 0.25881904510242748074233531951904*c(2) – 0.8660254037845352189890687485068*c(3) – 0.70710678118634266377459589793939*c(4) + 0.50000000000033453600179708174969*c(5) + 0.96592582628894331309400622678268*c(6) – 0.00000000000057943335207356344385823017649482*c(7))^3;
4*d(1) – 1.8637033051563776098191738128662*d(2) – 4.2633049951745970192397783341654*d(3) + 13.563877720667428310395457086882*d(4) – 24.768521719612297444841977031964*d(5) + 36.285231895285749438013397143228*d(6) – 46.364439661890315836602824540446*d(7) – (c(1) – 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) – 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) – 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449564958666*c(7))*(e(1) – 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) – 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) – 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449564958666*e(7)) – (c(1) – 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) – 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) – 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449564958666*c(7))^3;
4*d(1) + 5.8637033051563776098191738128662*d(2) + 11.191508225450913420036916917299*d(3) + 19.22073197016152089199595866252*d(4) + 28.768521719615093760113419773515*d(5) + 38.355784256109814142329509480196*d(6) + 46.364439661895159196726944689582*d(7) – (c(1) + 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) + 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) + 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449492408624*c(7))*(e(1) + 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) + 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) + 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449492408624*e(7)) – (c(1) + 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) + 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) + 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449492408624*c(7))^3;
e(1) + 1.2928932188134467651252634823322*e(2) – 5.6568542494924097273386404135329*e(3) + 6.7071067811867242128901886288508*e(4) – 1.0000000000003654703290979599324*e(5) – 9.292893218813100890044660293921*e(6) + 16.97056274847722918201592122289*e(7) – (c(1) – 0.70710678118655323487473651766777*c(2) + 0.000000000000016151659251727809284198242756759*c(3) + 0.70710678118653039297916789513938*c(4) – 0.99999999999999999999999999947825*c(5) + 0.70710678118657607677030513945829*c(6) – 0.000000000000048454977755183427852594727351922*c(7))^3*(d(1) – 0.70710678118655323487473651766777*d(2) + 0.000000000000016151659251727809284198242756759*d(3) + 0.70710678118653039297916789513938*d(4) – 0.99999999999999999999999999947825*d(5) + 0.70710678118657607677030513945829*d(6) – 0.000000000000048454977755183427852594727351922*d(7)) – (e(1) – 0.70710678118655323487473651766777*e(2) + 0.000000000000016151659251727809284198242756759*e(3) + 0.70710678118653039297916789513938*e(4) – 0.99999999999999999999999999947825*e(5) + 0.70710678118657607677030513945829*e(6) – 0.000000000000048454977755183427852594727351922*e(7))^2;
e(1) + 2.7071067811866669217124581336975*e(2) + 5.6568542494936730802944552629677*e(3) + 5.2928932188178631466714793942889*e(4) – 0.99999999999235857205671645455777*e(5) – 10.707106781180390379063104588879*e(6) – 16.970562748481019240883358047221*e(7) – (0.70710678118618933246600292636309*c(4) – 0.70710678118666692171245813369751*c(2) – 0.00000000000033770659479019338766497999870797*c(3) – c(1) + 0.99999999999999999999999977190851*c(5) + 0.70710678118714451095891301846186*c(6) + 0.0000000000010131197843705801629949407484403*c(7))^3*(0.70710678118618933246600292636309*d(4) – 0.70710678118666692171245813369751*d(2) – 0.00000000000033770659479019338766497999870797*d(3) – d(1) + 0.99999999999999999999999977190851*d(5) + 0.70710678118714451095891301846186*d(6) + 0.0000000000010131197843705801629949407484403*d(7)) – (0.70710678118618933246600292636309*e(4) – 0.70710678118666692171245813369751*e(2) – 0.00000000000033770659479019338766497999870797*e(3) – e(1) + 0.99999999999999999999999977190851*e(5) + 0.70710678118714451095891301846186*e(6) + 0.0000000000010131197843705801629949407484403*e(7))^2;
e(1) + 1.7411809548974588324199430644512*e(2) – 2.9365777646047468623544049138754*e(3) – 3.6851980642264179231687050474014*e(4) + 7.6726037773447455377790576522629*e(5) + 1.7135660980210903547643956684664*e(6) – 12.423314164920940163873268048734*e(7) – (c(1) – 0.25881904510254116758005693554878*c(2) – 0.86602540378441752171394942948519*c(3) + 0.70710678118659233739868810642085*c(4) + 0.49999999999992682068095891830983*c(5) – 0.96592582628909562457579410802636*c(6) + 0.00000000000012675029864244296874022498106152*c(7))^3*(d(1) – 0.25881904510254116758005693554878*d(2) – 0.86602540378441752171394942948519*d(3) + 0.70710678118659233739868810642085*d(4) + 0.49999999999992682068095891830983*d(5) – 0.96592582628909562457579410802636*d(6) + 0.00000000000012675029864244296874022498106152*d(7)) – (e(1) – 0.25881904510254116758005693554878*e(2) – 0.86602540378441752171394942948519*e(3) + 0.70710678118659233739868810642085*e(4) + 0.49999999999992682068095891830983*e(5) – 0.96592582628909562457579410802636*e(6) + 0.00000000000012675029864244296874022498106152*e(7))^2;
e(1) + 2.258819045102427480742335319519*e(2) + 1.2045269570348846269496138076455*e(3) – 5.099411626600765291643420880021*e(4) – 6.6726037773423083925143721729759*e(5) + 3.6454177506049296533485728916404*e(6) + 12.423314164920095688129821997252*e(7) – (c(1) + 0.25881904510242748074233531951904*c(2) – 0.8660254037845352189890687485068*c(3) – 0.70710678118634266377459589793939*c(4) + 0.50000000000033453600179708174969*c(5) + 0.96592582628894331309400622678268*c(6) – 0.00000000000057943335207356344385823017649482*c(7))^3*(d(1) + 0.25881904510242748074233531951904*d(2) – 0.8660254037845352189890687485068*d(3) – 0.70710678118634266377459589793939*d(4) + 0.50000000000033453600179708174969*d(5) + 0.96592582628894331309400622678268*d(6) – 0.00000000000057943335207356344385823017649482*d(7)) – (e(1) + 0.25881904510242748074233531951904*e(2) – 0.8660254037845352189890687485068*e(3) – 0.70710678118634266377459589793939*e(4) + 0.50000000000033453600179708174969*e(5) + 0.96592582628894331309400622678268*e(6) – 0.00000000000057943335207356344385823017649482*e(7))^2;
e(1) + 1.0340741737109055975452065467834*e(2) – 6.8613812065282156695387053028407*e(3) + 15.685198064227713028495645177746*e(4) – 26.268521719613346063068768060046*e(5) + 37.061689030594773702131939269591*e(6) – 46.364439661892132096649369596372*e(7) – (c(1) – 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) – 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) – 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449564958666*c(7))^3*(d(1) – 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) – 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) – 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449564958666*d(7)) – (e(1) – 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) – 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) – 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449564958666*e(7))^2;
e(1) + 2.9659258262890944024547934532166*e(2) + 8.5934320140972947697379899486242*e(3) + 17.099411626601236173895770571656*e(4) + 27.268521719614045141886628745433*e(5) + 37.579327120800789878210967353833*e(6) + 46.364439661893342936680399633656*e(7) – (c(1) + 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) + 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) + 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449492408624*c(7))^3*(d(1) + 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) + 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) + 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449492408624*d(7)) – (e(1) + 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) + 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) + 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449492408624*e(7))^2;
c(1) – c(2) + c(3) – c(4) + c(5) – c(6) + c(7) – 1; d(1) – d(2) + d(3) – d(4) + d(5) – d(6) + d(7) – 1; e(1) – e(2) + e(3) – e(4) + e(5) – e(6) + e(7) – 1]
% 2*c(2) – c(1) + 1.0*c(3) – 6.0*c(4) + d(1) – 1.0*d(3);
% 2.8660254037844197227968834340572*c(2) – c(1) – 7.4282032302752922278309731279771*c(3) + 11.999999999999099801669829449778*c(4) + d(1) – 0.86602540378441972279688343405724*d(2) + 0.49999999999993444545590565551924*d(3) + 0.00000000000011354380103841645254673828148123*d(4);
% 1.133974596215466590365394949913*c(2) – c(1) + 6.4282032302759390088627633740404*c(3) + 12.000000000003370641343632950538*c(4) + d(1) + 0.86602540378453340963460505008698*d(2) + 0.50000000000032826821407702665543*d(3) + 0.00000000000056857722529136932714864072658515*d(4);
% 4*d(1) + 2*d(2) – 4.0*d(3) – 6.0*d(4) – (c(1) – 1.0*c(3))^3 – (c(1) – 1.0*c(3))*(e(1) – 1.0*e(3));
% 4*d(1) – 1.4641016151376788911875337362289*d(2) – 4.9282032302756200005514448503809*d(3) + 11.999999999999667520675021532041*d(4) – (c(1) – 0.86602540378441972279688343405724*c(2) + 0.49999999999993444545590565551924*c(3) + 0.00000000000011354380103841645254673828148123*c(4))*(e(1) – 0.86602540378441972279688343405724*e(2) + 0.49999999999993444545590565551924*e(3) + 0.00000000000011354380103841645254673828148123*e(4)) – (c(1) – 0.86602540378441972279688343405724*c(2) + 0.49999999999993444545590565551924*c(3) + 0.00000000000011354380103841645254673828148123*c(4))^3;
% 4*d(1) + 5.4641016151381336385384202003479*d(2) + 8.9282032302775803499331485073175*d(3) + 12.000000000006213527470089797174*d(4) – (c(1) + 0.86602540378453340963460505008698*c(2) + 0.50000000000032826821407702665543*c(3) + 0.00000000000056857722529136932714864072658515*c(4))^3 – (c(1) + 0.86602540378453340963460505008698*c(2) + 0.50000000000032826821407702665543*c(3) + 0.00000000000056857722529136932714864072658515*c(4))*(e(1) + 0.86602540378453340963460505008698*e(2) + 0.50000000000032826821407702665543*e(3) + 0.00000000000056857722529136932714864072658515*e(4));
% e(1) + 2*e(2) – 1.0*e(3) – 6.0*e(4) – (e(1) – 1.0*e(3))^2 – (c(1) – 1.0*c(3))^3*(d(1) – 1.0*d(3));
% e(1) + 1.1339745962155802772031165659428*e(2) – 6.4282032302754233369191618169386*e(3) + 11.999999999999326889271906282683*e(4) – (c(1) – 0.86602540378441972279688343405724*c(2) + 0.49999999999993444545590565551924*c(3) + 0.00000000000011354380103841645254673828148123*c(4))^3*(d(1) – 0.86602540378441972279688343405724*d(2) + 0.49999999999993444545590565551924*d(3) + 0.00000000000011354380103841645254673828148123*d(4)) – (e(1) – 0.86602540378441972279688343405724*e(2) + 0.49999999999993444545590565551924*e(3) + 0.00000000000011354380103841645254673828148123*e(4))^2;
% e(1) + 2.866025403784533409634605050087*e(2) + 7.4282032302765955452909174273512*e(3) + 12.000000000004507795794215689192*e(4) – (e(1) + 0.86602540378453340963460505008698*e(2) + 0.50000000000032826821407702665543*e(3) + 0.00000000000056857722529136932714864072658515*e(4))^2 – (c(1) + 0.86602540378453340963460505008698*c(2) + 0.50000000000032826821407702665543*c(3) + 0.00000000000056857722529136932714864072658515*c(4))^3*(d(1) + 0.86602540378453340963460505008698*d(2) + 0.50000000000032826821407702665543*d(3) + 0.00000000000056857722529136932714864072658515*d(4));
% c(1) – c(2) + c(3) – c(4) – 1; d(1) – d(2) + d(3) – d(4) – 1; e(1) – e(2) + e(3) – e(4) – 1]
intial = zeros(1,N);
solution1 = fsolve(@(vars) f(vars(1:7),vars(8:14),vars(15:21)),[intial;intial;intial])
X1 = reshape(solution1,N,size);
approxsol1(x) = transpose(X1(:,1))*H
%approxsolA1(x) = transpose(X3(:,1))*H
approxsol2(x) = transpose(X1(:,2))*H
%approxsolA2(x) =transpose(X3(:,2))*H
approxsol3(x) = transpose(X1(:,3))*H
y0 = [1;1;1];
tspan = 0:0.1:1;
[t, y] = ode45(@myODEs, tspan, y0);
% figure(1)
% plot(t, y(:,1))
x1=0:0.1:1
figure(1)
plot(x1,approxsol2(x1))
hold on
plot(t,y(:,2),’o’ )
% figure(2)
% plot(x1,approxsol2(x1))
% figure(3)
% plot(x1I want to solve large number of nonlinear system of equation using fsolve . I am solving by assigning in f as f =@(c,d,e) []; likewaise but in these process i have to copy the equation in commaand window after running the code and put in f the we solve using fsolve but these is lengthy process for large value of N. pleases provide some code for shortcut.
clc;
close all
clear all
syms x k l p m h y k0 r
N=7;
size=3;gamma1=1;gamma2=1;gamma3=1;gamma4=1;
for i7=1:N
syms c(i7)
end
for i8 =1:N
syms d(i8)
end
for i9 =1:N
syms e(i8)
end
for i=1:N
symsX(i,:) = c(i);
end
for i=1:N
symsY(i,:) = d(i);
end
for i=1:N
symsZ(i,:) = e(i);
end
C1 = transpose(symsX)
%sym(‘c’, [1 N]);
C2 = transpose(symsY)
C3 = transpose(symsZ)
%A=c;
equations = sym(zeros(1,N));
D = [];L=1;
G = [];
Dv1 = [];
Dv2 = [];
v1 = 1;
v2 = 1;
for i=1:N
if i==1
n(i)=2
else
n(i)=1
end
end
for i=1:N
h(i) = (n(i)*pi)/2;
end
k1=1;k2=3;k3=5;k4=7;k5=9;k6=11;k7=13;k8=15;k9=17;k10=19;k11=21;k12=23;k14=25;k15=27;k16=29;
for i=1:N
for j=1:N
if(j==i-k1)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k2)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k3)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k4)
D(i,j)=((4*(i-1))/(n(j)*L)) ;
elseif(j==i-k5)
D(i,j)= ((4*(i-1))/(n(j)*L)) ;
elseif(j==i-k6)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k7)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k8)
D(i,j)= ((4*(i-1))/(n(j)*L))
elseif(j==i-k9)
D(i,j)= ((4*(i-1))/(n(j)*L))
elseif(j==i-k10)
D(i,j)= ((4*(i-1))/(n(j)*L))
else
D(i,j)=0;
end
end
end
for m=1:N
symT(m,:) = chebyshevT(m-1,2*x-1)
end
H(x) = symT
%% legender operational matrix for fractional derivatives
%% d^n(symT)/dx^n = (D^n)*symT
%B = D*symT
%% Dv is the COM derivative of oder v>0 the caputo sense
Dv1=[];
t=ceil(v1)
for i=1:N
for j=1:N
if(i<=t)
Dv=zeros(t,j);
elseif (j==1)
Dv1(i,j) = symsum(((((i-1)*(-1)^(i-1-k)*factorial(i-1+k-1)*2^(2*k)*factorial(k)*gamma(k-v1+1/2))/(L^(v1)*factorial(i-1-k)*factorial(2*k)*sqrt(pi)*(gamma(k-v1+1)^(2))))),k,t,i-1);
else
Dv1(i,j) = (i-1)*symsum(((((-1)^((i-1)-k0)*(j-1)*factorial(i-1+k0-1)*(2^(2*k0+1))*factorial(k0))/(L^(v1)*factorial((i-1)-k0)*factorial(2*k0)*sqrt(pi)*(gamma(k0-v1+1))))*symsum((((-1)^(j-1-r)*factorial(j-1+r-1)*(2^(2*r))*gamma(k0+r-v1+1/2))/(factorial(j-1-r)*factorial(2*r)*gamma(k0+r-v1+1))),r,0,j-1)),k0,t,i-1)
%Dv(i,j)= symsum(((((-1)^((i-1)-k)*(2*(i-1))*factorial((i-1)+k-1)*gamma(k-v+(1/2)))/(n(j)*L^(v)*gamma(k+(1/2))*factorial((i-1)-k)*gamma(k-v-(j-1)+1)*gamma(k+(j-1)-v+1)))),k,t,i-1)
% Dv(i,j)=symsum(((2*(j-1)+1)*symsum((((-1)^((i-1)+(j-1)+k+l)*factorial((i-1)+k)*factorial(l+(j-1)))/(factorial((i-1)-k)*factorial(k)*gamma(k-v+1)*factorial((j-1)-l)*(factorial(l))^(2)*(k+l-v+1))),l,0,j-1)),k,t,i-1);
end
end
end
Dv2=[];
t=ceil(v2)
for i=1:N
for j=1:N
if(i<=t)
Dv2=zeros(t,j);
elseif (j==1)
Dv2(i,j) = symsum(((((i-1)*(-1)^(i-1-k)*factorial(i-1+k-1)*2^(2*k)*factorial(k)*gamma(k-v2+1/2))/(L^(v2)*factorial(i-1-k)*factorial(2*k)*sqrt(pi)*(gamma(k-v2+1)^(2))))),k,t,i-1);
else
Dv2(i,j) = (i-1)*symsum(((((-1)^((i-1)-k0)*(j-1)*factorial(i-1+k0-1)*(2^(2*k0+1))*factorial(k0))/(L^(v2)*factorial((i-1)-k0)*factorial(2*k0)*sqrt(pi)*(gamma(k0-v2+1))))*symsum((((-1)^(j-1-r)*factorial(j-1+r-1)*(2^(2*r))*gamma(k0+r-v2+1/2))/(factorial(j-1-r)*factorial(2*r)*gamma(k0+r-v2+1))),r,0,j-1)),k0,t,i-1)
%Dv(i,j)= symsum(((((-1)^((i-1)-k)*(2*(i-1))*factorial((i-1)+k-1)*gamma(k-v+(1/2)))/(n(j)*L^(v)*gamma(k+(1/2))*factorial((i-1)-k)*gamma(k-v-(j-1)+1)*gamma(k+(j-1)-v+1)))),k,t,i-1)
% Dv(i,j)=symsum(((2*(j-1)+1)*symsum((((-1)^((i-1)+(j-1)+k+l)*factorial((i-1)+k)*factorial(l+(j-1)))/(factorial((i-1)-k)*factorial(k)*gamma(k-v+1)*factorial((j-1)-l)*(factorial(l))^(2)*(k+l-v+1))),l,0,j-1)),k,t,i-1);
end
end
end
y(1) = C1*H;y(2)=C2*H;y(3)=C3*H
g=zeros(N,1);a=1;b=1;c=1;d=1;
% xmin=0;xmax=1;
% for i = 1:N
% f = @(x) (1+x) .* (1 ./ sqrt(L.*x – x.^2)); % Define f(x) inside the loop
% func = @(x) f(x) .* chebyshevT(i-1, (2*x/L) – 1); % Define the function to integrate
% g(i) = (1 / h(i)) .* integral(func, xmin, xmax);
% end
%% solve system of fractional order D^(1.5)y1 = y2 $ D^(0.5) = -y2-y1+1+x
z1=1:N-1
R(z1)=vpa(solve(chebyshevT(N-1,2*x-1),x),5)
%D1 = sort(R,’descend’)
%G = transpose(g);
H1(x) = diff(H(x));
R1 = (C1*Dv1*H-gamma1*((C1*H)-(C2*H)));
R2 = (C2*Dv1*H+(4*gamma1*(C2*H))-((C1*H)*(C3*H))-(gamma2*(C1*H)^(3)));
R3 = (C3*Dv1*H+(gamma1*gamma4*(C3*H))-(((C1*H)^(3))*(C2*H))-(gamma3*(C3*H)^(2)));
% R1 = ((C1*Dv1*H)-a.*(y(1))+b.*((y(1)).*(y(2))));
% R2 = ((C2*Dv1*H)-c.*(((y(1)).*(y(2))))+d.*((y(2))));
t1=ceil(v1);t2=ceil(v2);
for i = 1:N-t1
eqn0(i) = R1(R(i))
%eqn0(i) = int((R1*chebyshevT(i-1,2*x-1)),x,0,1)
end
for i=1:N-t1
eqn1(i) = R2(R(i))
end
for i=1:N-t1
eqn2(i) = R3(R(i))
end
eqn3=(C1)*H(0)-2.6;
eqn4=(C2)*(H(0))-1.8;
eqn5 = (C3)*(H(0))-2.5;
equations1 = [eqn0,eqn1,eqn2,eqn3,eqn4,eqn5];
f =@(c,d,e) [2.7071067811865532348747365176678*c(2) – c(1) – 5.6568542494924420306571438691514*c(3) + 5.292893218813663426931852838572*c(4) + 0.99999999999963452967090203902407*c(5) – 10.707106781186253043585270572838*c(6) + 16.970562748477326091971431589745*c(7) + d(1) – 0.70710678118655323487473651766777*d(2) + 0.000000000000016151659251727809284198242756759*d(3) + 0.70710678118653039297916789513938*d(4) – 0.99999999999999999999999999947825*d(5) + 0.70710678118657607677030513945829*d(6) – 0.000000000000048454977755183427852594727351922*d(7); 1.2928932188133330782875418663025*c(2) – c(1) + 5.6568542494929976671048748761924*c(3) + 6.7071067811902418116034852470151*c(4) + 1.0000000000076414279432830892593*c(5) – 9.2928932188061013571452785519551*c(6) – 16.970562748478993001314616886895*c(7) + d(1) + 0.70710678118666692171245813369751*d(2) + 0.00000000000033770659479019338766497999870797*d(3) – 0.70710678118618933246600292636309*d(4) – 0.99999999999999999999999977190851*d(5) – 0.70710678118714451095891301846186*d(6) – 0.0000000000010131197843705801629949407484403*d(7);
2.2588190451025411675800569355488*c(2) – c(1) – 1.2045269570359118189265060549051*c(3) – 5.0994116265996025979660812602431*c(4) + 6.6726037773448918964171398156432*c(5) + 3.6454177505992816039159838845192*c(6) – 12.423314164921193664470552934672*c(7) + d(1) – 0.25881904510254116758005693554878*d(2) – 0.86602540378441752171394942948519*d(3) + 0.70710678118659233739868810642085*d(4) + 0.49999999999992682068095891830983*d(5) – 0.96592582628909562457579410802636*d(6) + 0.00000000000012675029864244296874022498106152*d(7); 1.741180954897572519257664680481*c(2) – c(1) + 2.9365777646039550649277513046591*c(3) – 3.6851980642280799640942290841422*c(4) – 7.6726037773429774645179663364753*c(5) + 1.7135660980270430271605604380751*c(6) + 12.42331416492125455483396912414*c(7) + d(1) + 0.25881904510242748074233531951904*d(2) – 0.8660254037845352189890687485068*d(3) – 0.70710678118634266377459589793939*d(4) + 0.50000000000033453600179708174969*d(5) + 0.96592582628894331309400622678268*d(6) – 0.00000000000057943335207356344385823017649482*d(7);
2.9659258262890944024547934532166*c(2) – c(1) – 8.5934320140972947697379899486242*c(3) + 17.099411626601236173895770571656*c(4) – 27.268521719614045141886628745433*c(5) + 37.579327120800789878210967353833*c(6) – 46.364439661893342936680399633656*c(7) + d(1) – 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) – 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) – 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449564958666*d(7); 1.0340741737109055975452065467834*c(2) – c(1) + 6.8613812065282156695387053028407*c(3) + 15.685198064227713028495645177746*c(4) + 26.268521719613346063068768060046*c(5) + 37.061689030594773702131939269591*c(6) + 46.364439661892132096649369596372*c(7) + d(1) + 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) + 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) + 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449492408624*d(7);
4*d(1) – 0.82842712474621293949894607067108*d(2) – 5.656854249492361272360885230105*d(3) + 8.8284271247463153918276923142689*d(4) – 4.0000000000003654703290979583672*d(5) – 7.1715728752533726597337448755461*d(6) + 16.970562748477083817082655672606*d(7) – (c(1) – 0.70710678118655323487473651766777*c(2) + 0.000000000000016151659251727809284198242756759*c(3) + 0.70710678118653039297916789513938*c(4) – 0.99999999999999999999999999947825*c(5) + 0.70710678118657607677030513945829*c(6) – 0.000000000000048454977755183427852594727351922*c(7))*(e(1) – 0.70710678118655323487473651766777*e(2) + 0.000000000000016151659251727809284198242756759*e(3) + 0.70710678118653039297916789513938*e(4) – 0.99999999999999999999999999947825*e(5) + 0.70710678118657607677030513945829*e(6) – 0.000000000000048454977755183427852594727351922*e(7)) – (c(1) – 0.70710678118655323487473651766777*c(2) + 0.000000000000016151659251727809284198242756759*c(3) + 0.70710678118653039297916789513938*c(4) – 0.99999999999999999999999999947825*c(5) + 0.70710678118657607677030513945829*c(6) – 0.000000000000048454977755183427852594727351922*c(7))^3;
4*d(1) + 4.82842712474666768684983253479*d(2) + 5.6568542494946862000788258431307*d(3) + 3.1715728752592951492734706151996*d(4) – 3.9999999999923585720567157702833*d(5) – 12.828427124741823911939843644264*d(6) – 16.97056274848405860023646978771*d(7) + (0.70710678118618933246600292636309*c(4) – 0.70710678118666692171245813369751*c(2) – 0.00000000000033770659479019338766497999870797*c(3) – c(1) + 0.99999999999999999999999977190851*c(5) + 0.70710678118714451095891301846186*c(6) + 0.0000000000010131197843705801629949407484403*c(7))^3 – (0.70710678118618933246600292636309*c(4) – 0.70710678118666692171245813369751*c(2) – 0.00000000000033770659479019338766497999870797*c(3) – c(1) + 0.99999999999999999999999977190851*c(5) + 0.70710678118714451095891301846186*c(6) + 0.0000000000010131197843705801629949407484403*c(7))*(0.70710678118618933246600292636309*e(4) – 0.70710678118666692171245813369751*e(2) – 0.00000000000033770659479019338766497999870797*e(3) – e(1) + 0.99999999999999999999999977190851*e(5) + 0.70710678118714451095891301846186*e(6) + 0.0000000000010131197843705801629949407484403*e(7));
4*d(1) + 0.96472381958983532967977225780487*d(2) – 5.534653975957999427496253202331*d(3) – 1.5638777206666409109726407281389*d(4) + 9.1726037773445259998219344071924*d(5) – 1.1842113808461965189629866556126*d(6) – 12.423314164920559912977340719828*d(7) – (c(1) – 0.25881904510254116758005693554878*c(2) – 0.86602540378441752171394942948519*c(3) + 0.70710678118659233739868810642085*c(4) + 0.49999999999992682068095891830983*c(5) – 0.96592582628909562457579410802636*c(6) + 0.00000000000012675029864244296874022498106152*c(7))*(e(1) – 0.25881904510254116758005693554878*e(2) – 0.86602540378441752171394942948519*e(3) + 0.70710678118659233739868810642085*e(4) + 0.49999999999992682068095891830983*e(5) – 0.96592582628909562457579410802636*e(6) + 0.00000000000012675029864244296874022498106152*e(7)) – (c(1) – 0.25881904510254116758005693554878*c(2) – 0.86602540378441752171394942948519*c(3) + 0.70710678118659233739868810642085*c(4) + 0.49999999999992682068095891830983*c(5) – 0.96592582628909562457579410802636*c(6) + 0.00000000000012675029864244296874022498106152*c(7))^3;
4*d(1) + 3.0352761804097099229693412780762*d(2) – 1.3935492543187210300175924378749*d(3) – 7.2207319701597932829672085738392*d(4) – 5.1726037773413047845089809277269*d(5) + 6.5431952294717595926305915719885*d(6) + 12.423314164918357388073601306921*d(7) – (c(1) + 0.25881904510242748074233531951904*c(2) – 0.8660254037845352189890687485068*c(3) – 0.70710678118634266377459589793939*c(4) + 0.50000000000033453600179708174969*c(5) + 0.96592582628894331309400622678268*c(6) – 0.00000000000057943335207356344385823017649482*c(7))*(e(1) + 0.25881904510242748074233531951904*e(2) – 0.8660254037845352189890687485068*e(3) – 0.70710678118634266377459589793939*e(4) + 0.50000000000033453600179708174969*e(5) + 0.96592582628894331309400622678268*e(6) – 0.00000000000057943335207356344385823017649482*e(7)) – (c(1) + 0.25881904510242748074233531951904*c(2) – 0.8660254037845352189890687485068*c(3) – 0.70710678118634266377459589793939*c(4) + 0.50000000000033453600179708174969*c(5) + 0.96592582628894331309400622678268*c(6) – 0.00000000000057943335207356344385823017649482*c(7))^3;
4*d(1) – 1.8637033051563776098191738128662*d(2) – 4.2633049951745970192397783341654*d(3) + 13.563877720667428310395457086882*d(4) – 24.768521719612297444841977031964*d(5) + 36.285231895285749438013397143228*d(6) – 46.364439661890315836602824540446*d(7) – (c(1) – 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) – 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) – 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449564958666*c(7))*(e(1) – 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) – 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) – 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449564958666*e(7)) – (c(1) – 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) – 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) – 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449564958666*c(7))^3;
4*d(1) + 5.8637033051563776098191738128662*d(2) + 11.191508225450913420036916917299*d(3) + 19.22073197016152089199595866252*d(4) + 28.768521719615093760113419773515*d(5) + 38.355784256109814142329509480196*d(6) + 46.364439661895159196726944689582*d(7) – (c(1) + 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) + 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) + 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449492408624*c(7))*(e(1) + 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) + 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) + 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449492408624*e(7)) – (c(1) + 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) + 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) + 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449492408624*c(7))^3;
e(1) + 1.2928932188134467651252634823322*e(2) – 5.6568542494924097273386404135329*e(3) + 6.7071067811867242128901886288508*e(4) – 1.0000000000003654703290979599324*e(5) – 9.292893218813100890044660293921*e(6) + 16.97056274847722918201592122289*e(7) – (c(1) – 0.70710678118655323487473651766777*c(2) + 0.000000000000016151659251727809284198242756759*c(3) + 0.70710678118653039297916789513938*c(4) – 0.99999999999999999999999999947825*c(5) + 0.70710678118657607677030513945829*c(6) – 0.000000000000048454977755183427852594727351922*c(7))^3*(d(1) – 0.70710678118655323487473651766777*d(2) + 0.000000000000016151659251727809284198242756759*d(3) + 0.70710678118653039297916789513938*d(4) – 0.99999999999999999999999999947825*d(5) + 0.70710678118657607677030513945829*d(6) – 0.000000000000048454977755183427852594727351922*d(7)) – (e(1) – 0.70710678118655323487473651766777*e(2) + 0.000000000000016151659251727809284198242756759*e(3) + 0.70710678118653039297916789513938*e(4) – 0.99999999999999999999999999947825*e(5) + 0.70710678118657607677030513945829*e(6) – 0.000000000000048454977755183427852594727351922*e(7))^2;
e(1) + 2.7071067811866669217124581336975*e(2) + 5.6568542494936730802944552629677*e(3) + 5.2928932188178631466714793942889*e(4) – 0.99999999999235857205671645455777*e(5) – 10.707106781180390379063104588879*e(6) – 16.970562748481019240883358047221*e(7) – (0.70710678118618933246600292636309*c(4) – 0.70710678118666692171245813369751*c(2) – 0.00000000000033770659479019338766497999870797*c(3) – c(1) + 0.99999999999999999999999977190851*c(5) + 0.70710678118714451095891301846186*c(6) + 0.0000000000010131197843705801629949407484403*c(7))^3*(0.70710678118618933246600292636309*d(4) – 0.70710678118666692171245813369751*d(2) – 0.00000000000033770659479019338766497999870797*d(3) – d(1) + 0.99999999999999999999999977190851*d(5) + 0.70710678118714451095891301846186*d(6) + 0.0000000000010131197843705801629949407484403*d(7)) – (0.70710678118618933246600292636309*e(4) – 0.70710678118666692171245813369751*e(2) – 0.00000000000033770659479019338766497999870797*e(3) – e(1) + 0.99999999999999999999999977190851*e(5) + 0.70710678118714451095891301846186*e(6) + 0.0000000000010131197843705801629949407484403*e(7))^2;
e(1) + 1.7411809548974588324199430644512*e(2) – 2.9365777646047468623544049138754*e(3) – 3.6851980642264179231687050474014*e(4) + 7.6726037773447455377790576522629*e(5) + 1.7135660980210903547643956684664*e(6) – 12.423314164920940163873268048734*e(7) – (c(1) – 0.25881904510254116758005693554878*c(2) – 0.86602540378441752171394942948519*c(3) + 0.70710678118659233739868810642085*c(4) + 0.49999999999992682068095891830983*c(5) – 0.96592582628909562457579410802636*c(6) + 0.00000000000012675029864244296874022498106152*c(7))^3*(d(1) – 0.25881904510254116758005693554878*d(2) – 0.86602540378441752171394942948519*d(3) + 0.70710678118659233739868810642085*d(4) + 0.49999999999992682068095891830983*d(5) – 0.96592582628909562457579410802636*d(6) + 0.00000000000012675029864244296874022498106152*d(7)) – (e(1) – 0.25881904510254116758005693554878*e(2) – 0.86602540378441752171394942948519*e(3) + 0.70710678118659233739868810642085*e(4) + 0.49999999999992682068095891830983*e(5) – 0.96592582628909562457579410802636*e(6) + 0.00000000000012675029864244296874022498106152*e(7))^2;
e(1) + 2.258819045102427480742335319519*e(2) + 1.2045269570348846269496138076455*e(3) – 5.099411626600765291643420880021*e(4) – 6.6726037773423083925143721729759*e(5) + 3.6454177506049296533485728916404*e(6) + 12.423314164920095688129821997252*e(7) – (c(1) + 0.25881904510242748074233531951904*c(2) – 0.8660254037845352189890687485068*c(3) – 0.70710678118634266377459589793939*c(4) + 0.50000000000033453600179708174969*c(5) + 0.96592582628894331309400622678268*c(6) – 0.00000000000057943335207356344385823017649482*c(7))^3*(d(1) + 0.25881904510242748074233531951904*d(2) – 0.8660254037845352189890687485068*d(3) – 0.70710678118634266377459589793939*d(4) + 0.50000000000033453600179708174969*d(5) + 0.96592582628894331309400622678268*d(6) – 0.00000000000057943335207356344385823017649482*d(7)) – (e(1) + 0.25881904510242748074233531951904*e(2) – 0.8660254037845352189890687485068*e(3) – 0.70710678118634266377459589793939*e(4) + 0.50000000000033453600179708174969*e(5) + 0.96592582628894331309400622678268*e(6) – 0.00000000000057943335207356344385823017649482*e(7))^2;
e(1) + 1.0340741737109055975452065467834*e(2) – 6.8613812065282156695387053028407*e(3) + 15.685198064227713028495645177746*e(4) – 26.268521719613346063068768060046*e(5) + 37.061689030594773702131939269591*e(6) – 46.364439661892132096649369596372*e(7) – (c(1) – 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) – 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) – 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449564958666*c(7))^3*(d(1) – 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) – 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) – 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449564958666*d(7)) – (e(1) – 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) – 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) – 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449564958666*e(7))^2;
e(1) + 2.9659258262890944024547934532166*e(2) + 8.5934320140972947697379899486242*e(3) + 17.099411626601236173895770571656*e(4) + 27.268521719614045141886628745433*e(5) + 37.579327120800789878210967353833*e(6) + 46.364439661893342936680399633656*e(7) – (c(1) + 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) + 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) + 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449492408624*c(7))^3*(d(1) + 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) + 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) + 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449492408624*d(7)) – (e(1) + 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) + 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) + 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449492408624*e(7))^2;
c(1) – c(2) + c(3) – c(4) + c(5) – c(6) + c(7) – 1; d(1) – d(2) + d(3) – d(4) + d(5) – d(6) + d(7) – 1; e(1) – e(2) + e(3) – e(4) + e(5) – e(6) + e(7) – 1]
% 2*c(2) – c(1) + 1.0*c(3) – 6.0*c(4) + d(1) – 1.0*d(3);
% 2.8660254037844197227968834340572*c(2) – c(1) – 7.4282032302752922278309731279771*c(3) + 11.999999999999099801669829449778*c(4) + d(1) – 0.86602540378441972279688343405724*d(2) + 0.49999999999993444545590565551924*d(3) + 0.00000000000011354380103841645254673828148123*d(4);
% 1.133974596215466590365394949913*c(2) – c(1) + 6.4282032302759390088627633740404*c(3) + 12.000000000003370641343632950538*c(4) + d(1) + 0.86602540378453340963460505008698*d(2) + 0.50000000000032826821407702665543*d(3) + 0.00000000000056857722529136932714864072658515*d(4);
% 4*d(1) + 2*d(2) – 4.0*d(3) – 6.0*d(4) – (c(1) – 1.0*c(3))^3 – (c(1) – 1.0*c(3))*(e(1) – 1.0*e(3));
% 4*d(1) – 1.4641016151376788911875337362289*d(2) – 4.9282032302756200005514448503809*d(3) + 11.999999999999667520675021532041*d(4) – (c(1) – 0.86602540378441972279688343405724*c(2) + 0.49999999999993444545590565551924*c(3) + 0.00000000000011354380103841645254673828148123*c(4))*(e(1) – 0.86602540378441972279688343405724*e(2) + 0.49999999999993444545590565551924*e(3) + 0.00000000000011354380103841645254673828148123*e(4)) – (c(1) – 0.86602540378441972279688343405724*c(2) + 0.49999999999993444545590565551924*c(3) + 0.00000000000011354380103841645254673828148123*c(4))^3;
% 4*d(1) + 5.4641016151381336385384202003479*d(2) + 8.9282032302775803499331485073175*d(3) + 12.000000000006213527470089797174*d(4) – (c(1) + 0.86602540378453340963460505008698*c(2) + 0.50000000000032826821407702665543*c(3) + 0.00000000000056857722529136932714864072658515*c(4))^3 – (c(1) + 0.86602540378453340963460505008698*c(2) + 0.50000000000032826821407702665543*c(3) + 0.00000000000056857722529136932714864072658515*c(4))*(e(1) + 0.86602540378453340963460505008698*e(2) + 0.50000000000032826821407702665543*e(3) + 0.00000000000056857722529136932714864072658515*e(4));
% e(1) + 2*e(2) – 1.0*e(3) – 6.0*e(4) – (e(1) – 1.0*e(3))^2 – (c(1) – 1.0*c(3))^3*(d(1) – 1.0*d(3));
% e(1) + 1.1339745962155802772031165659428*e(2) – 6.4282032302754233369191618169386*e(3) + 11.999999999999326889271906282683*e(4) – (c(1) – 0.86602540378441972279688343405724*c(2) + 0.49999999999993444545590565551924*c(3) + 0.00000000000011354380103841645254673828148123*c(4))^3*(d(1) – 0.86602540378441972279688343405724*d(2) + 0.49999999999993444545590565551924*d(3) + 0.00000000000011354380103841645254673828148123*d(4)) – (e(1) – 0.86602540378441972279688343405724*e(2) + 0.49999999999993444545590565551924*e(3) + 0.00000000000011354380103841645254673828148123*e(4))^2;
% e(1) + 2.866025403784533409634605050087*e(2) + 7.4282032302765955452909174273512*e(3) + 12.000000000004507795794215689192*e(4) – (e(1) + 0.86602540378453340963460505008698*e(2) + 0.50000000000032826821407702665543*e(3) + 0.00000000000056857722529136932714864072658515*e(4))^2 – (c(1) + 0.86602540378453340963460505008698*c(2) + 0.50000000000032826821407702665543*c(3) + 0.00000000000056857722529136932714864072658515*c(4))^3*(d(1) + 0.86602540378453340963460505008698*d(2) + 0.50000000000032826821407702665543*d(3) + 0.00000000000056857722529136932714864072658515*d(4));
% c(1) – c(2) + c(3) – c(4) – 1; d(1) – d(2) + d(3) – d(4) – 1; e(1) – e(2) + e(3) – e(4) – 1]
intial = zeros(1,N);
solution1 = fsolve(@(vars) f(vars(1:7),vars(8:14),vars(15:21)),[intial;intial;intial])
X1 = reshape(solution1,N,size);
approxsol1(x) = transpose(X1(:,1))*H
%approxsolA1(x) = transpose(X3(:,1))*H
approxsol2(x) = transpose(X1(:,2))*H
%approxsolA2(x) =transpose(X3(:,2))*H
approxsol3(x) = transpose(X1(:,3))*H
y0 = [1;1;1];
tspan = 0:0.1:1;
[t, y] = ode45(@myODEs, tspan, y0);
% figure(1)
% plot(t, y(:,1))
x1=0:0.1:1
figure(1)
plot(x1,approxsol2(x1))
hold on
plot(t,y(:,2),’o’ )
% figure(2)
% plot(x1,approxsol2(x1))
% figure(3)
% plot(x1 I want to solve large number of nonlinear system of equation using fsolve . I am solving by assigning in f as f =@(c,d,e) []; likewaise but in these process i have to copy the equation in commaand window after running the code and put in f the we solve using fsolve but these is lengthy process for large value of N. pleases provide some code for shortcut.
clc;
close all
clear all
syms x k l p m h y k0 r
N=7;
size=3;gamma1=1;gamma2=1;gamma3=1;gamma4=1;
for i7=1:N
syms c(i7)
end
for i8 =1:N
syms d(i8)
end
for i9 =1:N
syms e(i8)
end
for i=1:N
symsX(i,:) = c(i);
end
for i=1:N
symsY(i,:) = d(i);
end
for i=1:N
symsZ(i,:) = e(i);
end
C1 = transpose(symsX)
%sym(‘c’, [1 N]);
C2 = transpose(symsY)
C3 = transpose(symsZ)
%A=c;
equations = sym(zeros(1,N));
D = [];L=1;
G = [];
Dv1 = [];
Dv2 = [];
v1 = 1;
v2 = 1;
for i=1:N
if i==1
n(i)=2
else
n(i)=1
end
end
for i=1:N
h(i) = (n(i)*pi)/2;
end
k1=1;k2=3;k3=5;k4=7;k5=9;k6=11;k7=13;k8=15;k9=17;k10=19;k11=21;k12=23;k14=25;k15=27;k16=29;
for i=1:N
for j=1:N
if(j==i-k1)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k2)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k3)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k4)
D(i,j)=((4*(i-1))/(n(j)*L)) ;
elseif(j==i-k5)
D(i,j)= ((4*(i-1))/(n(j)*L)) ;
elseif(j==i-k6)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k7)
D(i,j)= ((4*(i-1))/(n(j)*L));
elseif(j==i-k8)
D(i,j)= ((4*(i-1))/(n(j)*L))
elseif(j==i-k9)
D(i,j)= ((4*(i-1))/(n(j)*L))
elseif(j==i-k10)
D(i,j)= ((4*(i-1))/(n(j)*L))
else
D(i,j)=0;
end
end
end
for m=1:N
symT(m,:) = chebyshevT(m-1,2*x-1)
end
H(x) = symT
%% legender operational matrix for fractional derivatives
%% d^n(symT)/dx^n = (D^n)*symT
%B = D*symT
%% Dv is the COM derivative of oder v>0 the caputo sense
Dv1=[];
t=ceil(v1)
for i=1:N
for j=1:N
if(i<=t)
Dv=zeros(t,j);
elseif (j==1)
Dv1(i,j) = symsum(((((i-1)*(-1)^(i-1-k)*factorial(i-1+k-1)*2^(2*k)*factorial(k)*gamma(k-v1+1/2))/(L^(v1)*factorial(i-1-k)*factorial(2*k)*sqrt(pi)*(gamma(k-v1+1)^(2))))),k,t,i-1);
else
Dv1(i,j) = (i-1)*symsum(((((-1)^((i-1)-k0)*(j-1)*factorial(i-1+k0-1)*(2^(2*k0+1))*factorial(k0))/(L^(v1)*factorial((i-1)-k0)*factorial(2*k0)*sqrt(pi)*(gamma(k0-v1+1))))*symsum((((-1)^(j-1-r)*factorial(j-1+r-1)*(2^(2*r))*gamma(k0+r-v1+1/2))/(factorial(j-1-r)*factorial(2*r)*gamma(k0+r-v1+1))),r,0,j-1)),k0,t,i-1)
%Dv(i,j)= symsum(((((-1)^((i-1)-k)*(2*(i-1))*factorial((i-1)+k-1)*gamma(k-v+(1/2)))/(n(j)*L^(v)*gamma(k+(1/2))*factorial((i-1)-k)*gamma(k-v-(j-1)+1)*gamma(k+(j-1)-v+1)))),k,t,i-1)
% Dv(i,j)=symsum(((2*(j-1)+1)*symsum((((-1)^((i-1)+(j-1)+k+l)*factorial((i-1)+k)*factorial(l+(j-1)))/(factorial((i-1)-k)*factorial(k)*gamma(k-v+1)*factorial((j-1)-l)*(factorial(l))^(2)*(k+l-v+1))),l,0,j-1)),k,t,i-1);
end
end
end
Dv2=[];
t=ceil(v2)
for i=1:N
for j=1:N
if(i<=t)
Dv2=zeros(t,j);
elseif (j==1)
Dv2(i,j) = symsum(((((i-1)*(-1)^(i-1-k)*factorial(i-1+k-1)*2^(2*k)*factorial(k)*gamma(k-v2+1/2))/(L^(v2)*factorial(i-1-k)*factorial(2*k)*sqrt(pi)*(gamma(k-v2+1)^(2))))),k,t,i-1);
else
Dv2(i,j) = (i-1)*symsum(((((-1)^((i-1)-k0)*(j-1)*factorial(i-1+k0-1)*(2^(2*k0+1))*factorial(k0))/(L^(v2)*factorial((i-1)-k0)*factorial(2*k0)*sqrt(pi)*(gamma(k0-v2+1))))*symsum((((-1)^(j-1-r)*factorial(j-1+r-1)*(2^(2*r))*gamma(k0+r-v2+1/2))/(factorial(j-1-r)*factorial(2*r)*gamma(k0+r-v2+1))),r,0,j-1)),k0,t,i-1)
%Dv(i,j)= symsum(((((-1)^((i-1)-k)*(2*(i-1))*factorial((i-1)+k-1)*gamma(k-v+(1/2)))/(n(j)*L^(v)*gamma(k+(1/2))*factorial((i-1)-k)*gamma(k-v-(j-1)+1)*gamma(k+(j-1)-v+1)))),k,t,i-1)
% Dv(i,j)=symsum(((2*(j-1)+1)*symsum((((-1)^((i-1)+(j-1)+k+l)*factorial((i-1)+k)*factorial(l+(j-1)))/(factorial((i-1)-k)*factorial(k)*gamma(k-v+1)*factorial((j-1)-l)*(factorial(l))^(2)*(k+l-v+1))),l,0,j-1)),k,t,i-1);
end
end
end
y(1) = C1*H;y(2)=C2*H;y(3)=C3*H
g=zeros(N,1);a=1;b=1;c=1;d=1;
% xmin=0;xmax=1;
% for i = 1:N
% f = @(x) (1+x) .* (1 ./ sqrt(L.*x – x.^2)); % Define f(x) inside the loop
% func = @(x) f(x) .* chebyshevT(i-1, (2*x/L) – 1); % Define the function to integrate
% g(i) = (1 / h(i)) .* integral(func, xmin, xmax);
% end
%% solve system of fractional order D^(1.5)y1 = y2 $ D^(0.5) = -y2-y1+1+x
z1=1:N-1
R(z1)=vpa(solve(chebyshevT(N-1,2*x-1),x),5)
%D1 = sort(R,’descend’)
%G = transpose(g);
H1(x) = diff(H(x));
R1 = (C1*Dv1*H-gamma1*((C1*H)-(C2*H)));
R2 = (C2*Dv1*H+(4*gamma1*(C2*H))-((C1*H)*(C3*H))-(gamma2*(C1*H)^(3)));
R3 = (C3*Dv1*H+(gamma1*gamma4*(C3*H))-(((C1*H)^(3))*(C2*H))-(gamma3*(C3*H)^(2)));
% R1 = ((C1*Dv1*H)-a.*(y(1))+b.*((y(1)).*(y(2))));
% R2 = ((C2*Dv1*H)-c.*(((y(1)).*(y(2))))+d.*((y(2))));
t1=ceil(v1);t2=ceil(v2);
for i = 1:N-t1
eqn0(i) = R1(R(i))
%eqn0(i) = int((R1*chebyshevT(i-1,2*x-1)),x,0,1)
end
for i=1:N-t1
eqn1(i) = R2(R(i))
end
for i=1:N-t1
eqn2(i) = R3(R(i))
end
eqn3=(C1)*H(0)-2.6;
eqn4=(C2)*(H(0))-1.8;
eqn5 = (C3)*(H(0))-2.5;
equations1 = [eqn0,eqn1,eqn2,eqn3,eqn4,eqn5];
f =@(c,d,e) [2.7071067811865532348747365176678*c(2) – c(1) – 5.6568542494924420306571438691514*c(3) + 5.292893218813663426931852838572*c(4) + 0.99999999999963452967090203902407*c(5) – 10.707106781186253043585270572838*c(6) + 16.970562748477326091971431589745*c(7) + d(1) – 0.70710678118655323487473651766777*d(2) + 0.000000000000016151659251727809284198242756759*d(3) + 0.70710678118653039297916789513938*d(4) – 0.99999999999999999999999999947825*d(5) + 0.70710678118657607677030513945829*d(6) – 0.000000000000048454977755183427852594727351922*d(7); 1.2928932188133330782875418663025*c(2) – c(1) + 5.6568542494929976671048748761924*c(3) + 6.7071067811902418116034852470151*c(4) + 1.0000000000076414279432830892593*c(5) – 9.2928932188061013571452785519551*c(6) – 16.970562748478993001314616886895*c(7) + d(1) + 0.70710678118666692171245813369751*d(2) + 0.00000000000033770659479019338766497999870797*d(3) – 0.70710678118618933246600292636309*d(4) – 0.99999999999999999999999977190851*d(5) – 0.70710678118714451095891301846186*d(6) – 0.0000000000010131197843705801629949407484403*d(7);
2.2588190451025411675800569355488*c(2) – c(1) – 1.2045269570359118189265060549051*c(3) – 5.0994116265996025979660812602431*c(4) + 6.6726037773448918964171398156432*c(5) + 3.6454177505992816039159838845192*c(6) – 12.423314164921193664470552934672*c(7) + d(1) – 0.25881904510254116758005693554878*d(2) – 0.86602540378441752171394942948519*d(3) + 0.70710678118659233739868810642085*d(4) + 0.49999999999992682068095891830983*d(5) – 0.96592582628909562457579410802636*d(6) + 0.00000000000012675029864244296874022498106152*d(7); 1.741180954897572519257664680481*c(2) – c(1) + 2.9365777646039550649277513046591*c(3) – 3.6851980642280799640942290841422*c(4) – 7.6726037773429774645179663364753*c(5) + 1.7135660980270430271605604380751*c(6) + 12.42331416492125455483396912414*c(7) + d(1) + 0.25881904510242748074233531951904*d(2) – 0.8660254037845352189890687485068*d(3) – 0.70710678118634266377459589793939*d(4) + 0.50000000000033453600179708174969*d(5) + 0.96592582628894331309400622678268*d(6) – 0.00000000000057943335207356344385823017649482*d(7);
2.9659258262890944024547934532166*c(2) – c(1) – 8.5934320140972947697379899486242*c(3) + 17.099411626601236173895770571656*c(4) – 27.268521719614045141886628745433*c(5) + 37.579327120800789878210967353833*c(6) – 46.364439661893342936680399633656*c(7) + d(1) – 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) – 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) – 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449564958666*d(7); 1.0340741737109055975452065467834*c(2) – c(1) + 6.8613812065282156695387053028407*c(3) + 15.685198064227713028495645177746*c(4) + 26.268521719613346063068768060046*c(5) + 37.061689030594773702131939269591*c(6) + 46.364439661892132096649369596372*c(7) + d(1) + 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) + 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) + 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449492408624*d(7);
4*d(1) – 0.82842712474621293949894607067108*d(2) – 5.656854249492361272360885230105*d(3) + 8.8284271247463153918276923142689*d(4) – 4.0000000000003654703290979583672*d(5) – 7.1715728752533726597337448755461*d(6) + 16.970562748477083817082655672606*d(7) – (c(1) – 0.70710678118655323487473651766777*c(2) + 0.000000000000016151659251727809284198242756759*c(3) + 0.70710678118653039297916789513938*c(4) – 0.99999999999999999999999999947825*c(5) + 0.70710678118657607677030513945829*c(6) – 0.000000000000048454977755183427852594727351922*c(7))*(e(1) – 0.70710678118655323487473651766777*e(2) + 0.000000000000016151659251727809284198242756759*e(3) + 0.70710678118653039297916789513938*e(4) – 0.99999999999999999999999999947825*e(5) + 0.70710678118657607677030513945829*e(6) – 0.000000000000048454977755183427852594727351922*e(7)) – (c(1) – 0.70710678118655323487473651766777*c(2) + 0.000000000000016151659251727809284198242756759*c(3) + 0.70710678118653039297916789513938*c(4) – 0.99999999999999999999999999947825*c(5) + 0.70710678118657607677030513945829*c(6) – 0.000000000000048454977755183427852594727351922*c(7))^3;
4*d(1) + 4.82842712474666768684983253479*d(2) + 5.6568542494946862000788258431307*d(3) + 3.1715728752592951492734706151996*d(4) – 3.9999999999923585720567157702833*d(5) – 12.828427124741823911939843644264*d(6) – 16.97056274848405860023646978771*d(7) + (0.70710678118618933246600292636309*c(4) – 0.70710678118666692171245813369751*c(2) – 0.00000000000033770659479019338766497999870797*c(3) – c(1) + 0.99999999999999999999999977190851*c(5) + 0.70710678118714451095891301846186*c(6) + 0.0000000000010131197843705801629949407484403*c(7))^3 – (0.70710678118618933246600292636309*c(4) – 0.70710678118666692171245813369751*c(2) – 0.00000000000033770659479019338766497999870797*c(3) – c(1) + 0.99999999999999999999999977190851*c(5) + 0.70710678118714451095891301846186*c(6) + 0.0000000000010131197843705801629949407484403*c(7))*(0.70710678118618933246600292636309*e(4) – 0.70710678118666692171245813369751*e(2) – 0.00000000000033770659479019338766497999870797*e(3) – e(1) + 0.99999999999999999999999977190851*e(5) + 0.70710678118714451095891301846186*e(6) + 0.0000000000010131197843705801629949407484403*e(7));
4*d(1) + 0.96472381958983532967977225780487*d(2) – 5.534653975957999427496253202331*d(3) – 1.5638777206666409109726407281389*d(4) + 9.1726037773445259998219344071924*d(5) – 1.1842113808461965189629866556126*d(6) – 12.423314164920559912977340719828*d(7) – (c(1) – 0.25881904510254116758005693554878*c(2) – 0.86602540378441752171394942948519*c(3) + 0.70710678118659233739868810642085*c(4) + 0.49999999999992682068095891830983*c(5) – 0.96592582628909562457579410802636*c(6) + 0.00000000000012675029864244296874022498106152*c(7))*(e(1) – 0.25881904510254116758005693554878*e(2) – 0.86602540378441752171394942948519*e(3) + 0.70710678118659233739868810642085*e(4) + 0.49999999999992682068095891830983*e(5) – 0.96592582628909562457579410802636*e(6) + 0.00000000000012675029864244296874022498106152*e(7)) – (c(1) – 0.25881904510254116758005693554878*c(2) – 0.86602540378441752171394942948519*c(3) + 0.70710678118659233739868810642085*c(4) + 0.49999999999992682068095891830983*c(5) – 0.96592582628909562457579410802636*c(6) + 0.00000000000012675029864244296874022498106152*c(7))^3;
4*d(1) + 3.0352761804097099229693412780762*d(2) – 1.3935492543187210300175924378749*d(3) – 7.2207319701597932829672085738392*d(4) – 5.1726037773413047845089809277269*d(5) + 6.5431952294717595926305915719885*d(6) + 12.423314164918357388073601306921*d(7) – (c(1) + 0.25881904510242748074233531951904*c(2) – 0.8660254037845352189890687485068*c(3) – 0.70710678118634266377459589793939*c(4) + 0.50000000000033453600179708174969*c(5) + 0.96592582628894331309400622678268*c(6) – 0.00000000000057943335207356344385823017649482*c(7))*(e(1) + 0.25881904510242748074233531951904*e(2) – 0.8660254037845352189890687485068*e(3) – 0.70710678118634266377459589793939*e(4) + 0.50000000000033453600179708174969*e(5) + 0.96592582628894331309400622678268*e(6) – 0.00000000000057943335207356344385823017649482*e(7)) – (c(1) + 0.25881904510242748074233531951904*c(2) – 0.8660254037845352189890687485068*c(3) – 0.70710678118634266377459589793939*c(4) + 0.50000000000033453600179708174969*c(5) + 0.96592582628894331309400622678268*c(6) – 0.00000000000057943335207356344385823017649482*c(7))^3;
4*d(1) – 1.8637033051563776098191738128662*d(2) – 4.2633049951745970192397783341654*d(3) + 13.563877720667428310395457086882*d(4) – 24.768521719612297444841977031964*d(5) + 36.285231895285749438013397143228*d(6) – 46.364439661890315836602824540446*d(7) – (c(1) – 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) – 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) – 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449564958666*c(7))*(e(1) – 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) – 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) – 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449564958666*e(7)) – (c(1) – 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) – 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) – 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449564958666*c(7))^3;
4*d(1) + 5.8637033051563776098191738128662*d(2) + 11.191508225450913420036916917299*d(3) + 19.22073197016152089199595866252*d(4) + 28.768521719615093760113419773515*d(5) + 38.355784256109814142329509480196*d(6) + 46.364439661895159196726944689582*d(7) – (c(1) + 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) + 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) + 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449492408624*c(7))*(e(1) + 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) + 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) + 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449492408624*e(7)) – (c(1) + 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) + 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) + 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449492408624*c(7))^3;
e(1) + 1.2928932188134467651252634823322*e(2) – 5.6568542494924097273386404135329*e(3) + 6.7071067811867242128901886288508*e(4) – 1.0000000000003654703290979599324*e(5) – 9.292893218813100890044660293921*e(6) + 16.97056274847722918201592122289*e(7) – (c(1) – 0.70710678118655323487473651766777*c(2) + 0.000000000000016151659251727809284198242756759*c(3) + 0.70710678118653039297916789513938*c(4) – 0.99999999999999999999999999947825*c(5) + 0.70710678118657607677030513945829*c(6) – 0.000000000000048454977755183427852594727351922*c(7))^3*(d(1) – 0.70710678118655323487473651766777*d(2) + 0.000000000000016151659251727809284198242756759*d(3) + 0.70710678118653039297916789513938*d(4) – 0.99999999999999999999999999947825*d(5) + 0.70710678118657607677030513945829*d(6) – 0.000000000000048454977755183427852594727351922*d(7)) – (e(1) – 0.70710678118655323487473651766777*e(2) + 0.000000000000016151659251727809284198242756759*e(3) + 0.70710678118653039297916789513938*e(4) – 0.99999999999999999999999999947825*e(5) + 0.70710678118657607677030513945829*e(6) – 0.000000000000048454977755183427852594727351922*e(7))^2;
e(1) + 2.7071067811866669217124581336975*e(2) + 5.6568542494936730802944552629677*e(3) + 5.2928932188178631466714793942889*e(4) – 0.99999999999235857205671645455777*e(5) – 10.707106781180390379063104588879*e(6) – 16.970562748481019240883358047221*e(7) – (0.70710678118618933246600292636309*c(4) – 0.70710678118666692171245813369751*c(2) – 0.00000000000033770659479019338766497999870797*c(3) – c(1) + 0.99999999999999999999999977190851*c(5) + 0.70710678118714451095891301846186*c(6) + 0.0000000000010131197843705801629949407484403*c(7))^3*(0.70710678118618933246600292636309*d(4) – 0.70710678118666692171245813369751*d(2) – 0.00000000000033770659479019338766497999870797*d(3) – d(1) + 0.99999999999999999999999977190851*d(5) + 0.70710678118714451095891301846186*d(6) + 0.0000000000010131197843705801629949407484403*d(7)) – (0.70710678118618933246600292636309*e(4) – 0.70710678118666692171245813369751*e(2) – 0.00000000000033770659479019338766497999870797*e(3) – e(1) + 0.99999999999999999999999977190851*e(5) + 0.70710678118714451095891301846186*e(6) + 0.0000000000010131197843705801629949407484403*e(7))^2;
e(1) + 1.7411809548974588324199430644512*e(2) – 2.9365777646047468623544049138754*e(3) – 3.6851980642264179231687050474014*e(4) + 7.6726037773447455377790576522629*e(5) + 1.7135660980210903547643956684664*e(6) – 12.423314164920940163873268048734*e(7) – (c(1) – 0.25881904510254116758005693554878*c(2) – 0.86602540378441752171394942948519*c(3) + 0.70710678118659233739868810642085*c(4) + 0.49999999999992682068095891830983*c(5) – 0.96592582628909562457579410802636*c(6) + 0.00000000000012675029864244296874022498106152*c(7))^3*(d(1) – 0.25881904510254116758005693554878*d(2) – 0.86602540378441752171394942948519*d(3) + 0.70710678118659233739868810642085*d(4) + 0.49999999999992682068095891830983*d(5) – 0.96592582628909562457579410802636*d(6) + 0.00000000000012675029864244296874022498106152*d(7)) – (e(1) – 0.25881904510254116758005693554878*e(2) – 0.86602540378441752171394942948519*e(3) + 0.70710678118659233739868810642085*e(4) + 0.49999999999992682068095891830983*e(5) – 0.96592582628909562457579410802636*e(6) + 0.00000000000012675029864244296874022498106152*e(7))^2;
e(1) + 2.258819045102427480742335319519*e(2) + 1.2045269570348846269496138076455*e(3) – 5.099411626600765291643420880021*e(4) – 6.6726037773423083925143721729759*e(5) + 3.6454177506049296533485728916404*e(6) + 12.423314164920095688129821997252*e(7) – (c(1) + 0.25881904510242748074233531951904*c(2) – 0.8660254037845352189890687485068*c(3) – 0.70710678118634266377459589793939*c(4) + 0.50000000000033453600179708174969*c(5) + 0.96592582628894331309400622678268*c(6) – 0.00000000000057943335207356344385823017649482*c(7))^3*(d(1) + 0.25881904510242748074233531951904*d(2) – 0.8660254037845352189890687485068*d(3) – 0.70710678118634266377459589793939*d(4) + 0.50000000000033453600179708174969*d(5) + 0.96592582628894331309400622678268*d(6) – 0.00000000000057943335207356344385823017649482*d(7)) – (e(1) + 0.25881904510242748074233531951904*e(2) – 0.8660254037845352189890687485068*e(3) – 0.70710678118634266377459589793939*e(4) + 0.50000000000033453600179708174969*e(5) + 0.96592582628894331309400622678268*e(6) – 0.00000000000057943335207356344385823017649482*e(7))^2;
e(1) + 1.0340741737109055975452065467834*e(2) – 6.8613812065282156695387053028407*e(3) + 15.685198064227713028495645177746*e(4) – 26.268521719613346063068768060046*e(5) + 37.061689030594773702131939269591*e(6) – 46.364439661892132096649369596372*e(7) – (c(1) – 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) – 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) – 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449564958666*c(7))^3*(d(1) – 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) – 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) – 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449564958666*d(7)) – (e(1) – 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) – 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) – 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449564958666*e(7))^2;
e(1) + 2.9659258262890944024547934532166*e(2) + 8.5934320140972947697379899486242*e(3) + 17.099411626601236173895770571656*e(4) + 27.268521719614045141886628745433*e(5) + 37.579327120800789878210967353833*e(6) + 46.364439661893342936680399633656*e(7) – (c(1) + 0.96592582628909440245479345321655*c(2) + 0.86602540378453955009964232289175*c(3) + 0.70710678118676157270006269695467*c(4) + 0.50000000000034953940893034269384*c(5) + 0.25881904510300808803951404212103*c(6) + 0.00000000000060542001551501864197449492408624*c(7))^3*(d(1) + 0.96592582628909440245479345321655*d(2) + 0.86602540378453955009964232289175*d(3) + 0.70710678118676157270006269695467*d(4) + 0.50000000000034953940893034269384*d(5) + 0.25881904510300808803951404212103*d(6) + 0.00000000000060542001551501864197449492408624*d(7)) – (e(1) + 0.96592582628909440245479345321655*e(2) + 0.86602540378453955009964232289175*e(3) + 0.70710678118676157270006269695467*e(4) + 0.50000000000034953940893034269384*e(5) + 0.25881904510300808803951404212103*e(6) + 0.00000000000060542001551501864197449492408624*e(7))^2;
c(1) – c(2) + c(3) – c(4) + c(5) – c(6) + c(7) – 1; d(1) – d(2) + d(3) – d(4) + d(5) – d(6) + d(7) – 1; e(1) – e(2) + e(3) – e(4) + e(5) – e(6) + e(7) – 1]
% 2*c(2) – c(1) + 1.0*c(3) – 6.0*c(4) + d(1) – 1.0*d(3);
% 2.8660254037844197227968834340572*c(2) – c(1) – 7.4282032302752922278309731279771*c(3) + 11.999999999999099801669829449778*c(4) + d(1) – 0.86602540378441972279688343405724*d(2) + 0.49999999999993444545590565551924*d(3) + 0.00000000000011354380103841645254673828148123*d(4);
% 1.133974596215466590365394949913*c(2) – c(1) + 6.4282032302759390088627633740404*c(3) + 12.000000000003370641343632950538*c(4) + d(1) + 0.86602540378453340963460505008698*d(2) + 0.50000000000032826821407702665543*d(3) + 0.00000000000056857722529136932714864072658515*d(4);
% 4*d(1) + 2*d(2) – 4.0*d(3) – 6.0*d(4) – (c(1) – 1.0*c(3))^3 – (c(1) – 1.0*c(3))*(e(1) – 1.0*e(3));
% 4*d(1) – 1.4641016151376788911875337362289*d(2) – 4.9282032302756200005514448503809*d(3) + 11.999999999999667520675021532041*d(4) – (c(1) – 0.86602540378441972279688343405724*c(2) + 0.49999999999993444545590565551924*c(3) + 0.00000000000011354380103841645254673828148123*c(4))*(e(1) – 0.86602540378441972279688343405724*e(2) + 0.49999999999993444545590565551924*e(3) + 0.00000000000011354380103841645254673828148123*e(4)) – (c(1) – 0.86602540378441972279688343405724*c(2) + 0.49999999999993444545590565551924*c(3) + 0.00000000000011354380103841645254673828148123*c(4))^3;
% 4*d(1) + 5.4641016151381336385384202003479*d(2) + 8.9282032302775803499331485073175*d(3) + 12.000000000006213527470089797174*d(4) – (c(1) + 0.86602540378453340963460505008698*c(2) + 0.50000000000032826821407702665543*c(3) + 0.00000000000056857722529136932714864072658515*c(4))^3 – (c(1) + 0.86602540378453340963460505008698*c(2) + 0.50000000000032826821407702665543*c(3) + 0.00000000000056857722529136932714864072658515*c(4))*(e(1) + 0.86602540378453340963460505008698*e(2) + 0.50000000000032826821407702665543*e(3) + 0.00000000000056857722529136932714864072658515*e(4));
% e(1) + 2*e(2) – 1.0*e(3) – 6.0*e(4) – (e(1) – 1.0*e(3))^2 – (c(1) – 1.0*c(3))^3*(d(1) – 1.0*d(3));
% e(1) + 1.1339745962155802772031165659428*e(2) – 6.4282032302754233369191618169386*e(3) + 11.999999999999326889271906282683*e(4) – (c(1) – 0.86602540378441972279688343405724*c(2) + 0.49999999999993444545590565551924*c(3) + 0.00000000000011354380103841645254673828148123*c(4))^3*(d(1) – 0.86602540378441972279688343405724*d(2) + 0.49999999999993444545590565551924*d(3) + 0.00000000000011354380103841645254673828148123*d(4)) – (e(1) – 0.86602540378441972279688343405724*e(2) + 0.49999999999993444545590565551924*e(3) + 0.00000000000011354380103841645254673828148123*e(4))^2;
% e(1) + 2.866025403784533409634605050087*e(2) + 7.4282032302765955452909174273512*e(3) + 12.000000000004507795794215689192*e(4) – (e(1) + 0.86602540378453340963460505008698*e(2) + 0.50000000000032826821407702665543*e(3) + 0.00000000000056857722529136932714864072658515*e(4))^2 – (c(1) + 0.86602540378453340963460505008698*c(2) + 0.50000000000032826821407702665543*c(3) + 0.00000000000056857722529136932714864072658515*c(4))^3*(d(1) + 0.86602540378453340963460505008698*d(2) + 0.50000000000032826821407702665543*d(3) + 0.00000000000056857722529136932714864072658515*d(4));
% c(1) – c(2) + c(3) – c(4) – 1; d(1) – d(2) + d(3) – d(4) – 1; e(1) – e(2) + e(3) – e(4) – 1]
intial = zeros(1,N);
solution1 = fsolve(@(vars) f(vars(1:7),vars(8:14),vars(15:21)),[intial;intial;intial])
X1 = reshape(solution1,N,size);
approxsol1(x) = transpose(X1(:,1))*H
%approxsolA1(x) = transpose(X3(:,1))*H
approxsol2(x) = transpose(X1(:,2))*H
%approxsolA2(x) =transpose(X3(:,2))*H
approxsol3(x) = transpose(X1(:,3))*H
y0 = [1;1;1];
tspan = 0:0.1:1;
[t, y] = ode45(@myODEs, tspan, y0);
% figure(1)
% plot(t, y(:,1))
x1=0:0.1:1
figure(1)
plot(x1,approxsol2(x1))
hold on
plot(t,y(:,2),’o’ )
% figure(2)
% plot(x1,approxsol2(x1))
% figure(3)
% plot(x1 fsolve, solve MATLAB Answers — New Questions