Plotting a system of nonlinear equations

61 visualizaciones (últimos 30 días)
Mei Cheng
Mei Cheng el 23 de Ag. de 2022
Comentada: Mei Cheng el 24 de Ag. de 2022
Hello!
there is a system of nonlinear equations as below,
syms x y z T
y=1/T+ln(x);
z=(x+y)/(1-xy);
exp(T)/x^2+z/x^3=1;
I want to plot (3*z-1/T) as a function of T, with 100<T<500.
As these are a system of nonlinear equations, I really hope you can help me to figure it out.
Thanks a million in advance!

Respuesta aceptada

John D'Errico
John D'Errico el 23 de Ag. de 2022
Learn first that MATLAB uses log(x) as the NATURAL log, NOT ln(x).
As well, learn that MATLAB does NOT use implicit multiplication. So xy is just the variable xy, here, undefined.
syms x y z T
solve(y==1/T+log(x), z==(x+y)/(1-x*y), exp(T)/x^2+z/x^3==1,[x,y,z])
Warning: Unable to find explicit solution. For options, see help.
ans = struct with fields:
x: [0×1 sym] y: [0×1 sym] z: [0×1 sym]
So solve does not find a solution. At least not directly. Can we do some manipulation? First, play with the first equation, to get
y - log(x) = 1/T
and therefore
T = 1/(y - log(x))
Exponentiate to get exp(T).
exp(T) = exp(1/(y - log(x)))
Next, we can look at equation 3. Multiply by x^2.
exp(T) = x^2 - z/x
Which leaves us the pair of equations
x^2 - z/x == exp(1/(y - log(x)))
z==(x+y)/(1-x*y)
As you can see, these are independent of T. They will describe a curved path through the domain (x,y,z) , that is, if any numerical solution exists at all. But that path is COMPLETELY independent of T. Pick any value of T, and any point along that path will be a solution.
As such the plot you desire to see will be a simple one, of the form a + 1/T, if ANY solution exists. So a branch of a hyperbola in T. There a will be a function of z.
Can we do more? Yes, probably so. We can eliminate y temporarily, as:
isolate(z==(x+y)/(1-x*y),y)
ans = 
EQ = subs(x^2 - z/x == exp(1/(y - log(x))),y,-(x-z)/(x*z+1))
EQ = 
This is nothing terrible exciting. It certainly has no closed form resolution. But we can plot it.
fimplicit(EQ)
grid on
xlabel x
ylabel z
So a nasty looking thing, with multiple branches. It appears a solution exists for ANY value of z. In fact, for many values of z, there will be several solutions.
And that means the final plot you want to see is just that simple 3*z+1/T curve. Pick ANY value of x, and that will produce several solutions for z.
  1 comentario
Mei Cheng
Mei Cheng el 24 de Ag. de 2022
Thank you very much for your help. It is a great explanation!

Iniciar sesión para comentar.

Más respuestas (0)

Categorías

Más información sobre Numbers and Precision en Help Center y File Exchange.

Productos


Versión

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by