Plotting a system of nonlinear equations

조회 수: 5 (최근 30일)
Mei Cheng
Mei Cheng 2022년 8월 23일
댓글: Mei Cheng 2022년 8월 24일
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!

채택된 답변

John D'Errico
John D'Errico 2022년 8월 23일
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
Mei Cheng
Mei Cheng 2022년 8월 24일
Thank you very much for your help. It is a great explanation!

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

추가 답변 (0개)

카테고리

Help CenterFile Exchange에서 Assumptions에 대해 자세히 알아보기

제품


릴리스

R2021a

Community Treasure Hunt

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

Start Hunting!

Translated by