common tangent of two curves with vpasolve.

5 次查看(过去 30 天)
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