I have an equation which includes continued fraction. I want to find particular root of this equation for all R which is a parameter of the equation.
For this I:
- input this continued fraction as a polynomial expression into MATLAB
- simplify this polynomium
- compute all roots of the expression
- and finally search the root that I'm interested in.
The problem I have is that higher R needs higher accuracy so more level of continued fraction, but my computer can not compute that much(I have i7 3rd gen 12gb ram laptop 2 cores).
Is there any chance to use parallel computing or GPU computing to compute this equation? Can optimize my code? Or use other computing programs to compute these roots.
%%
clear; close all; clc;
%%
syms R;
Z=1; E=1; P1=sqrt(2*E);
m=0;
c=m+1; d=c; a=-1i*Z/P1+m+1; t=-2*1i*P1*R;
n=20;
%A, B, C koeficientebis gansazgvra
for k=0:n
A(k+1)=(k+1)*(k+c);
B(k+1)=-k*( k-1+t+c+d );
C(k+1)=t*(k-1+a);
end
syms x;
for i=1:n
P(i)=x;
Q(i)=x;
end
% gantolebis chawera
for k=1:n-2
if k==1
P(k)=(-C(k+1));
Q(k)=(B(k+1)-x);
elseif k==2
P(k)=-C(k)*(B(k+1)-x);
Q(k)=(B(k)-x)*(B(k+1)-x)+(-A(k)*C(k+1));
else
P(k)=(B(k+1)-x)*P(k-1)+(-A(k)*C(k+1))*P(k-2);
Q(k)=(B(k+1)-x)*Q(k-1)+(-A(k)*C(k+1))*Q(k-2);
end
end
eqn(x)=-x*Q(n-2)+P(n-2);
eqn=simplify(eqn);
eqn(R)=eqn;
R=0.1:0.1:9;
R=double(R);
eqn=eqn(R);
ros(:,1)=R;
for i=1:length(R)
coef(i,:)=flip(double(coeffs(eqn(i))));
ros(i,2:n)=roots(coef(i,:));
end
for i=0:n-1
plot(R,real(ros(:,n-i)),R,imag(ros(:,n-i)));hold on;
end
My computer can compute when n=35 maximum and it need a little bit much time. But I need like n to be 50-60.
EDIT: The problem seems to be ram usage during:
eqn=simplify(eqn);