5 views (last 30 days)

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

Bjorn Gustavsson
on 12 Jun 2020

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

Bjorn Gustavsson
on 12 Jun 2020

Opportunities for recent engineering grads.

Apply Today
## 2 Comments

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/544451-common-tangent-of-two-curves-with-vpasolve#comment_894822

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/544451-common-tangent-of-two-curves-with-vpasolve#comment_894822

## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/544451-common-tangent-of-two-curves-with-vpasolve#comment_894861

⋮## Direct link to this comment

https://in.mathworks.com/matlabcentral/answers/544451-common-tangent-of-two-curves-with-vpasolve#comment_894861

Sign in to comment.