Solving One Equation on Matlab: Finding Parameter p

  • Context: MATLAB 
  • Thread starter Thread starter FrancescoMi
  • Start date Start date
  • Tags Tags
    Matlab Parameter
Click For Summary
SUMMARY

The discussion focuses on solving the equation (p-c)*psi'-psi=0 in MATLAB, where psi is defined through a series of symbolic computations. The user provided MATLAB code that calculates the derivatives of psi and attempts to solve for the parameter p. Key issues identified include the requirement that rho must be greater than eta for the code to function correctly, and the observation that varying sigma yields unexpected results. The community suggests separating mathematical inquiries from coding issues and emphasizes the need for clearer problem statements in future posts.

PREREQUISITES
  • Familiarity with MATLAB symbolic toolbox
  • Understanding of calculus, specifically derivatives and integrals
  • Knowledge of gamma functions and their applications
  • Basic understanding of parameter estimation in mathematical modeling
NEXT STEPS
  • Review MATLAB symbolic toolbox documentation for advanced functions
  • Learn about the gamma function and its properties in mathematical modeling
  • Explore techniques for debugging MATLAB code, particularly for symbolic equations
  • Investigate numerical methods for solving equations when symbolic solutions are not feasible
USEFUL FOR

Mathematics students, MATLAB users, and researchers involved in mathematical modeling and parameter estimation will benefit from this discussion.

FrancescoMi
Messages
5
Reaction score
0
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:

2pyp9u0.png


and psi' is the derivative of psi. I've written this code:
Matlab:
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)

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.
Do you think the code is right and the derivatives are correct?
 
I think the problem with this post is the question posed:

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

It is unreasonable to request that someone manually check all of your work and then debug your code on this scale. This could easily take a few hours, which is why nobody has responded.

Let's separate the math from the code: if you have a problem with the derivative or equations, post that in the Calculus forums. Once you nail down the expression you want to solve, I suggest you repost here with some updated code. The code you posted didn't run for me, so there is at least a little more work to be done:

Code:
Warning: Cannot solve symbolically. Returning a numeric
approximation instead. 
> In solve at 306 

FreeBoundary =

1.0

Any updates or other information you can provide?
 
  • Like
Likes   Reactions: Delong

Similar threads

  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 10 ·
Replies
10
Views
3K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 2 ·
Replies
2
Views
4K
  • · Replies 6 ·
Replies
6
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 4 ·
Replies
4
Views
2K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
2K
  • · Replies 8 ·
Replies
8
Views
2K