Hi, I have to solve one equation on Matlab. The equation is: (p-c)*psi'-psi=0 I have to find p. Where psi is:(adsbygoogle = window.adsbygoogle || []).push({});

and psi' is the derivative of psi. I've written this code:

I've calculated the derivatives by myself, and I hope they are ok. What do you think about the code? It works only if rho>eta. Moreover for different values of sigma it give me some strange results.Code (Matlab M):

rho = 0.04; %In the image is lambda

c = 25;

eta = 0.02;

mu = 40;

sigma = 0.57;

alpha = -rho/eta;

syms p t

F = t^(-alpha-1)*exp(-t^2/2+((p-mu)/sigma*sqrt(2*eta))*t); %Funzione integranda non derivata

F_d = t^(-alpha-1)*(t*sqrt(2*eta))/sigma*exp(-t^2/2+((p-mu)/sigma*sqrt(2*eta))*t); %Funzione integranda derivata

D = (exp(((p-mu)/sigma*sqrt(2*eta))^2/4)/gamma(-alpha))*int(F,t,0,inf); %Funzione cilindrica non derivata

D_d = (exp((((p-mu)/sigma*sqrt(2*eta))^2)/4)/gamma(-alpha))*int(F_d,t,0,inf)+((eta*(p-mu))/(4*(sigma)^2))*(exp((((p-mu)/sigma*sqrt(2*eta))^2)/4)/gamma(-alpha))*int(F,t,0,inf); %Funzione cilindrica derivata

psi = exp((eta*(p-mu)^2)/(2*(sigma)^2))*D;

psi_d = (eta*(p-mu))/(sigma^2)*exp((eta*(p-mu)^2)/(2*(sigma)^2))*D + exp((eta*(p-mu)^2)/(2*(sigma)^2))*D_d; %Derivata di psi

Theta = (p-c)*psi_d-psi;

FreeBoundary = solve(Theta,p)

Do you think the code is right and the derivatives are correct?

**Physics Forums | Science Articles, Homework Help, Discussion**

Join Physics Forums Today!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

The friendliest, high quality science and math community on the planet! Everyone who loves science is here!

# Matlab Code

**Physics Forums | Science Articles, Homework Help, Discussion**