common tangent of two curves with vpasolve.

조회 수: 9 (최근 30일)
muhsin ider
muhsin ider 2020년 6월 8일
댓글: muhsin ider 2020년 6월 12일
The following code finds common tangents of fx and gx by symbolic expressions. I used first "solve" but sometimes it can not find all the roots of the denk1 and denk2 which are derived from common tangent geometry. vpasolve finds a pair of x,y but not both. I appreciate any help or suggestions.
best wishes,
clc, clear all, close all
disp([' (t) a b']);
R=8.314 ;%j/mol K;
O1=-15000;
O2=0; %j/mol K;
for t=1300:50:1350
syms x fx gx ek m(x) y1(x) a b y2(x) f(x) g(x) fu(x) gu(x)
syms denk1 denk2 denk3 p yx
f(x)=R*t*((x*log(x))+((1-x)*log(1-x)))+O1*(x-x^2);
g(x)=x*(12000-10*t)+((1-x)*(8000-10*t))+R*t*((x*log(x))+((1-x)*log(1-x)));
fu(x)=diff(f(x),x);%1. differential
gu(x)=diff(g(x),x);%2.differential
denk1=(((g(b)-f(a))/(b-a))==(fu(a)));
denk2=(fu(a)==gu(b));
%[a b]=solve(denk1,denk2,a,b);
%[kola kolb] = vpasolve([denk1 denk2],[a b],[0.2;.99991])
[Sola Solb] = vpasolve([denk1 denk2],[a b],[0.1; 0.3]);
a=Sola;
b=Solb;
disp([t,a,b])
x=0:0.01:1;
plot(x ,f(x),'r-',x ,g(x),'-b')
hold on
p = linspace(a,b);
%y=mx+n graph of common tangent line between a and b
yx=((fu(a))*(p-a))+f(a);
plot(p,yx, 'm-')
pause(2)
hold off
figure
end
  댓글 수: 2
darova
darova 2020년 6월 12일
Here the results i got from your code
Look good. What is your question again?
muhsin ider
muhsin ider 2020년 6월 12일
there is another common tangent on the right side of the 1 st figure around 0.8-0.9 and also in the 2nd figure. Solve or vpasolve can not automatically find those points.

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

채택된 답변

Bjorn Gustavsson
Bjorn Gustavsson 2020년 6월 12일
In your code you gove starting-points for the variable you search for. Perhaps vpasolve doesn't bother to look for all solutions of your equation (in case they are too complex one solution might be considered good enough). Try to look for a second solution starting from another point (~0.8 and 0.9). If that gives you a second solution you've found the second solution. I've not looked at your equations to know how many solutions you should have...
HTH
  댓글 수: 7
Bjorn Gustavsson
Bjorn Gustavsson 2020년 6월 12일
That is most likely a design-choise by Mathworks. If, for example, vpasolve were to try to return all solutions of equations there might be problems when you try to solve equations with infinitely many solutions. Then there would need to be some arbitrary cut-off when the number of solutions will be considered "enough". Perhaps Mathworks then made the choise that one solution is enough.
muhsin ider
muhsin ider 2020년 6월 12일
I am guessing and understanding now that vpasolve is also using a newton based or similar method or something like that because the same problem sometimes happen with that method. That method sometimes gives only one solution depending on the starting guess point.
Thanks for your help and comments.
best regards,

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Loops and Conditional Statements에 대해 자세히 알아보기

제품


릴리스

R2018b

Community Treasure Hunt

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

Start Hunting!

Translated by