hello, I want to convert this code into legendre differential equation, can someone help?
clc
clear all
syms x z rhs rhs2 t x1 z2 y k4 k5
%%%euler legender starts
f=input (‘enter the function f(x), which is coefficient of D terms:’);
z2=log(f);
a=diff(f,x)
a
k1=input(‘enter the constant k1’);
k2=input(‘enter the constant k2’);
k3=input(‘enter constant k3’);
rhs=input (‘enter the rhs function, which is coefficient of D terms:’);
eqn=f==exp(z);
x=solve(eqn,x);
x
rhs2=subs(rhs,x)
rhs2
a0=k1*a^2;
b0=(k2*a)-(k1*a*a)
c0=k3
a1=a0/a0;b1=b0/a0;c1=c0/a0;
eq=a1*x1^2+b1*x1+c1
r=solve(eq,’x1′)
if imag(r)~=0
y1=exp(real(r(1))*z)*cos(imag(r(1))*z);
y2=exp(real(r(1))*z)*sin(abs(imag(r(1)))*z)
else if r(1)==r(2)
y1=exp(r(1)*z)
y2=z*exp(r(1)*z)
else
y1=exp(r(1)*z);
y2=exp(r(2)*z)
end
end
y_h=k4*y1+k5*y2;
W=simplify(y1*diff(y2)-y2*diff(y1));
g=rhs2;
y_p=-y1*int(y2*g/W)+y2*int(y1*g/W);
y=simplify(y_h+y_p);
y
simplify(subs(y,z,log(f)))clc
clear all
syms x z rhs rhs2 t x1 z2 y k4 k5
%%%euler legender starts
f=input (‘enter the function f(x), which is coefficient of D terms:’);
z2=log(f);
a=diff(f,x)
a
k1=input(‘enter the constant k1’);
k2=input(‘enter the constant k2’);
k3=input(‘enter constant k3’);
rhs=input (‘enter the rhs function, which is coefficient of D terms:’);
eqn=f==exp(z);
x=solve(eqn,x);
x
rhs2=subs(rhs,x)
rhs2
a0=k1*a^2;
b0=(k2*a)-(k1*a*a)
c0=k3
a1=a0/a0;b1=b0/a0;c1=c0/a0;
eq=a1*x1^2+b1*x1+c1
r=solve(eq,’x1′)
if imag(r)~=0
y1=exp(real(r(1))*z)*cos(imag(r(1))*z);
y2=exp(real(r(1))*z)*sin(abs(imag(r(1)))*z)
else if r(1)==r(2)
y1=exp(r(1)*z)
y2=z*exp(r(1)*z)
else
y1=exp(r(1)*z);
y2=exp(r(2)*z)
end
end
y_h=k4*y1+k5*y2;
W=simplify(y1*diff(y2)-y2*diff(y1));
g=rhs2;
y_p=-y1*int(y2*g/W)+y2*int(y1*g/W);
y=simplify(y_h+y_p);
y
simplify(subs(y,z,log(f))) clc
clear all
syms x z rhs rhs2 t x1 z2 y k4 k5
%%%euler legender starts
f=input (‘enter the function f(x), which is coefficient of D terms:’);
z2=log(f);
a=diff(f,x)
a
k1=input(‘enter the constant k1’);
k2=input(‘enter the constant k2’);
k3=input(‘enter constant k3’);
rhs=input (‘enter the rhs function, which is coefficient of D terms:’);
eqn=f==exp(z);
x=solve(eqn,x);
x
rhs2=subs(rhs,x)
rhs2
a0=k1*a^2;
b0=(k2*a)-(k1*a*a)
c0=k3
a1=a0/a0;b1=b0/a0;c1=c0/a0;
eq=a1*x1^2+b1*x1+c1
r=solve(eq,’x1′)
if imag(r)~=0
y1=exp(real(r(1))*z)*cos(imag(r(1))*z);
y2=exp(real(r(1))*z)*sin(abs(imag(r(1)))*z)
else if r(1)==r(2)
y1=exp(r(1)*z)
y2=z*exp(r(1)*z)
else
y1=exp(r(1)*z);
y2=exp(r(2)*z)
end
end
y_h=k4*y1+k5*y2;
W=simplify(y1*diff(y2)-y2*diff(y1));
g=rhs2;
y_p=-y1*int(y2*g/W)+y2*int(y1*g/W);
y=simplify(y_h+y_p);
y
simplify(subs(y,z,log(f))) #matlab #lengendre_differential_equation MATLAB Answers — New Questions