Solve an equation with two variables

5 visualizzazioni (ultimi 30 giorni)
Irene Bujalance
Irene Bujalance il 17 Lug 2017
Commentato: Walter Roberson il 18 Lug 2017
I need to solve this equation for the unknowns E_fb and E_ft, with all other known constants.
I have written the following code, and it gives me this error:
sol=solve(['CTOX/e*(e*Vtg-10e17*e*(Ect-Eft)-e*Vds+chiT*q-ePhi*q)-Cvdw/e*(e*Vds-e*10e17*(Efb-Evb)-e*10e17*(Ect-Eft)+Egb*q+chiB*q-chiT*q)=e*(gv*kb*T/(pi*hbarra2))*(mv*log(exp(-q*(Eft-Evt)/(kb*t))+1)-mc*log(exp(-q*(Ect-Eft)/(kb*t))+1))','CBOX/e*(e*Vbg-10e17*e*(Efb-Evb)-Egb*q+chiB*q-ePhiB*q)-Cvdw/e*(e*Vds-e*10e17*(Efb-Evb)-e*10e17*(Ect-Eft)+Egb*q+chiB*q-chiT*q)=e*(gv*kb*T/(pi*hbarra2))*(mv*log(exp(-q*(Efb-Evb)/(kb*t))+1)-mc*log(exp(-q*(Ecb-Efb)/(kb*t))+1))'],[Eft,Efb])
Undefined function or variable 'Eft'.
Thanks for your help.
  2 Commenti
Walter Roberson
Walter Roberson il 17 Lug 2017
Could you confirm that you mean 10e17, which is 10^18 ? Or did you mean 10^17 which is 1E17 ?
Walter Roberson
Walter Roberson il 17 Lug 2017
I am confused as to where you are getting two equations from this? I do see two "=" but one is at the end of a line and the other is the beginning of the next line so plausibly that is indicating a single equality.

Accedi per commentare.

Risposte (1)

John D'Errico
John D'Errico il 17 Lug 2017
Are the variables Eft and Efb defined as symbolic variables, before you did this? (No)
So first, start by defining them.
syms Eft Efb
Next, to create a symbolic equality relationship, use == instead of = in the expression.
I have a funny feeling there will be no solution anyway, If so, then so solve will return an empty result. But hey, you might get lucky.
  3 Commenti
Irene Bujalance
Irene Bujalance il 18 Lug 2017
Modificato: Walter Roberson il 18 Lug 2017
I've changed the code to the following:
clear all
clc
format short e
CTOX=5.18e16; %F/m^2
CBOX=5.18e16; %F/m^2
Vtg=0.4;
Vbg=-0.2;
e=1.6e-19; %C
q=1.6e-19;
Vds=0.4; %eV
chiT=4; %eV
Cvdw=3.8000e+16; %F/m^2
ePhi=5.05; %eV
ePhiB=5.65;
Egb=1; %eV
chiB=5.1; %eV
gv=2;
kb=1.38e-23; %eV/K
T=300; %K
hbarra2=(6.62e-34)^2; %J·s
m=9.1e-31; %kg
mv=0.4*m; %kg
mc=0.3*m; %kg
Evt=5.3; %eV
eqns=[CTOX/e*(e*Vtg-10e17*e*phint-e*Vds+chiT*e-ePhi*q)-Cvdw/e*(e*Vds-e*10e17*phipb-e*10e17*phint+Egb*e+chiB*q-chiT*q)==e*(gv*kb*T/(pi*hbarra2))*(mv*log(exp(-q*phipb/(kb*T))+1)-mc*log(exp(-q*phint/(kb*T))+1)),CBOX/e*(e*Vbg-10e17*e*phipb+Egb*q+chiB*q-ePhiB*q)+Cvdw/e*(e*Vds-e*10e17*phipb-e*10e17*phint+Egb*q+chiB*q-chiT*q)==e*(gv*kb*T/(pi*hbarra2))*(mv*log(exp(-q*phipb/(kb*T))+1)-mc*log(exp(-q*phint/(kb*T))+1))];
vars=[phint,phipb];
[sol1,sol2]=solve(eqns,vars);
And in this case, the result I get is:
sol1 =
-0.000000000000000003470849420849420751973613790144
sol2 =
0.000000000000000002670849420849420562630573995945
Could you tell me if the result is correct? Is that I have tried to calculate both terms separately and they are not the same, and I do not know if I have committed any fault in the code.
Walter Roberson
Walter Roberson il 18 Lug 2017
You have a "clear all" but you do not "syms" phint or phipb into existence before using them.
What does it mean to have found a supposedly exact solution to equations involving coefficients that are low-precision and clearly rounded of ??
It is possible to find symbolic solutions to the equations involving a term which is a root of an expression that has no closed form solution. Furthermore this expression in turn involves a subexpression which is a root of an expression that has no closed form solution. There are four solution pairs because the outer expression is kind of quartic.
The inner root has at least two different solutions; one of them is imaginary valued, and the other is real valued and approximately 8.531*10^(-19). The slope of the equation at the point of its real solution is approximately 10^131, so you will not actually be able to find the zero unless you are operating on at least 131 digits of precision. And that is just for the inner of the nested roots; I have not investigated the precision necessary to find the outer level.
You appear to have found the real component of sol1, but my tests suggest that the imaginary component on the order of -2E-36 is not negligible -- and with the functions being so steep, it is not surprising that you might get a value quite different from 0 when you substitute in.
My calculation is that there should be a complete second set of solutions.

Accedi per commentare.

Community Treasure Hunt

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

Start Hunting!

Translated by