Matlab says "Unable to find explicit solution" when trying to solve following non linear equation
-log(y) = psi(1/2+ x/y) - psi(1/2)
Here psi is digamma function
What is wrong with my code, below?
I am using matlab version R2021a
syms x y
eqn = psi(1/2 + x/y)- psi(1/2)+ log(y)==0;
soly = solve(eqn,y)
Warning:
Unable to find explicit solution. For options, see help.
> In sym/solve (line 317)
soly =
Empty sym: 0-by-1

댓글 수: 2

Matt J
Matt J 2021년 4월 1일
It seems very plausible to me that an explicit solution does not exist. Do you have reason to think otherwise?
Tiku
Tiku 2021년 4월 1일
Thank you for the reply.
I see explicit solution doesn't exist.
That means in order to plot y vs x I should assigned the value of x and solve for y right?

댓글을 달려면 로그인하십시오.

 채택된 답변

Matt J
Matt J 2021년 4월 1일

1 개 추천

You can use fimplicit.

댓글 수: 9

Tiku
Tiku 2021년 4월 1일
Alright and thank you
Matt J
Matt J 2021년 4월 1일
You're welcome, but if fimplicit does what you need, please Accept-click this answer.
Tiku
Tiku 2021년 4월 1일
Actually I am interested in a plot of y versus x .
Like I said earlier, I took 6 x points and used them to find corresponding y solutions using vpasolve command but it turns out that plot didn't match with the one in the paper. The paper says they obtained plot from solving equation self consistently.
I used following code
syms x y nw;
nw=6;
x=[0.00 0.12 0.14 0.16 0.18 0.20];
gv=zeros(1,nw);
for i=1:nw
[gv(i)] = vpasolve(psi(1/2 + x(i)/y)- psi(1/2)+ log(y)==0,y);
end;
gv
plot(x,gv)
Could you please let me know where is my error?
If the idea is to generate a plot, I don't know why aren't using fimplicit like I suggested. It generates a reasonable looking plot for me quite readily:
f=@(x,y) psi(1/2+ x./y) - psi(1/2) + log(y);
fimplicit(f)
xlabel 'x', ylabel 'y'
axis([0,0.14,0, 1]);
Thank you for your constant help and now I used fimplicit like you suggested.
Running of following code gave me a plot which didn't match with the attached plot the one from the paper. I am trying to get first plot and interested in Ts and Tc for now.
f=@(x,y) psi(1/2+2.2*x./y) - psi(1/2) + log(y/3);
fimplicit(f)
figure(1);
%xlabel 'x', ylabel 'y'
axis([0,0.18,0, 3]);
hold on
g=@(x,y) psi(1/2+ x./y) - psi(1/2) + log(y);
fimplicit(g)
figure(2);
%xlabel 'x', ylabel 'y'
axis([0,0.14,0, 1]);
hold on
On varying x from 0 to 0.14 there should be only one phase then mixed phase for certain x and other phase after increasing x.So how can someone generate the plot like the first figure?
Here's what I get.
f=@(x,y) psi(1/2+2.2*x./y) - psi(1/2) + log(y/3);
g=@(x,y) psi(1/2+ x./y) - psi(1/2) + log(y);
fimplicit(f)
hold on
fimplicit(g)
hold on
axis([0.11,0.19,0, 2]);
Tiku
Tiku 2021년 4월 2일
편집: Tiku 2021년 4월 2일
Thank you for your help but I am still wondering how to get like the plot in the paper?
My apology in the first equation 0.2 value was missing which makes full code now
f=@(x,y) psi(1/2+2.2*x./y) - psi(1/2) + log(y/3);
g=@(x,y) psi(1/2+0.2*x./y) - psi(1/2) + log(y);
fimplicit(f)
hold on
fimplicit(g)
hold on
axis([0.11,0.19,0, 2]);
The above code gave two intersecting curves but still both phases are apppearing in left-right and up-down of the plot which doesn't match with the paper.
Matt J
Matt J 2021년 4월 2일
We've no reason to trust the paper more than Matlab...
Tiku
Tiku 2021년 4월 4일
I totally agree Matlab calulation is right. Actually after the plot I have to use some physics to ignore certain parts of the plot so at this stage both Matlab and paper is right.
So I really apppreciate your help and thank you.

댓글을 달려면 로그인하십시오.

추가 답변 (0개)

카테고리

질문:

2021년 4월 1일

댓글:

2021년 4월 4일

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by