Slove function return empty solutions

Hello, I'm trying to solve the attached syntax, but the aolve function return empty solutions. Please help.
syms V_1 V_2 x_1 x_2 r
pi1 = (V_1) * (x_1^r/(x_1^r+x_2^r)) - x_1
pi2 = (V_2) * (x_2^r/(x_1^r+x_2^r)) - x_2
dpi1dx = diff(pi1, x_1)
dpi2dx = diff(pi2, x_2)
s = solve(dpi1dx==0, dpi2dx==0, x_1, x_2)

2 件のコメント

Roy
Roy 2023 年 3 月 24 日
Please help
Walter Roberson
Walter Roberson 2023 年 3 月 24 日
I am very busy these days.

サインインしてコメントする。

回答 (2 件)

Walter Roberson
Walter Roberson 2023 年 3 月 16 日

1 投票

Use dsolve for differential equations

20 件のコメント

Walter Roberson
Walter Roberson 2023 年 3 月 16 日
Note that if the derivative of a function is identical to 0 then the function must be constant with respect to that variable.
If you are working with initial conditions you would test things such as subs(dpi1dx, x1, 0)==0 (but remember to include the defining equations as well.) See the dsolve documentation
Roy
Roy 2023 年 3 月 17 日
Sorry but I don't understand. If i define r=1, MATLAB success to solve it.
Roy
Roy 2023 年 3 月 17 日
編集済み: Roy 2023 年 3 月 17 日
Please help me with a new code to solve the max point of equations pi1 and pi2 (respect of x_1 and x_2).. I'm at a loss
Walter Roberson
Walter Roberson 2023 年 3 月 17 日
Sorry, I did misunderstand what you are trying to do.
solve() is for trying to find indefinitely-precise closed form solutions. The derivative of pi1 involves x_1^(2*r+1) . Even if we assume that r is a positive integer, there is no general solution for polynomials with degree greater than 4.
Therefore there are only a small number of values of r that have closed form solutions.
Roy
Roy 2023 年 3 月 18 日
Thank for your answer!!
I'm trying to find the maximum of pi1 and pi2 by x_1 and x_2.
Can I limit solve() for range of r to solve this?
I can solve it easily with paper but I can't solve it with MATLAB :(
Walter Roberson
Walter Roberson 2023 年 3 月 18 日
If you show your paper calculations for r = 3 and for r = 3/2 then perhaps someone would be able to come up with something. Use V_1 = 1 to make the calculation easier.
Roy
Roy 2023 年 3 月 19 日
編集済み: Roy 2023 年 3 月 19 日
Suppose V_1=V_2, then x_1=x_2=r*V/2. The solution is for r<2, but MATLAB can't solve it. Its strange... If I define r=1, then the matlab can solve the equations. How can I fix my code?
There is other function then solve() I can use? I use dsolve and there is no solution
Walter Roberson
Walter Roberson 2023 年 3 月 19 日
syms V_1 V_2 x_1 x_2 r
pi1 = (V_1) * (x_1^r/(x_1^r+x_2^r)) - x_1
pi1 = 
pi2 = (V_2) * (x_2^r/(x_1^r+x_2^r)) - x_2
pi2 = 
dpi1dx = diff(pi1, x_1)
dpi1dx = 
dpi2dx = diff(pi2, x_2)
dpi2dx = 
eqn = subs([dpi1dx, dpi2dx], V_2, V_1)
eqn = 
simplify(subs(eqn, [x_1, x_2], [r*V_1/2, r*V_1/2]), 'steps', 20)
ans = 
These are not 0, so x_1 == x_2 == r*V/2 is not a root of the derivatives, and therefore is not a critical point.
I made some further tests. You can solve dpi1dx for x_2 or you can solve dpi2dx for x_1 but you cannot get anywhere on the next steps, which involve exp(i*pi*ANGLE) times something. You can rewrite to get (sin(ANGLE) + 1i*cos(ANGLE)) times something, but doing that does not help.
Roy
Roy 2023 年 3 月 19 日
syms V_1 V_2 x_1 x_2 r
pi1 = (V_1) * (x_1^r/(x_1^r+x_2^r)) - x_1;
pi2 = (V_2) * (x_2^r/(x_1^r+x_2^r)) - x_2;
dpi1dx = diff(pi1, x_1);
dpi2dx = diff(pi2, x_2);
eqn = subs([dpi1dx, dpi2dx], V_2, V_1);
simplify(subs(eqn, [x_1, x_2], [r*V_1/4, r*V_1/4]), 'steps', 20)
ans = 
Please see, the solution is x_1=x_2=r*V/4.
Why solve() cant solve it?
Thanks for your help!!!
John D'Errico
John D'Errico 2023 年 3 月 19 日
@Roy, really? Is r*V/4 really the solution?
syms V_1 V_2 x_1 x_2 r V
pi1 = (V_1) * (x_1^r/(x_1^r+x_2^r)) - x_1;
pi2 = (V_2) * (x_2^r/(x_1^r+x_2^r)) - x_2;
subs(pi1,[x_1,x_2],[r*V/4,r*V/4])
ans = 
subs(pi2,[x_1,x_2],[r*V/4,r*V/4])
ans = 
If it was, I would have thought the result, from substituting your claimed "solution" directly back into those equations, it would yield 0. I might be getting old though.
Even if you now claim that, oh, you made a mistake, and you have r==2 exactly, it still fails, unless also V_1==V_2. But then why do you have two different variables?
Roy
Roy 2023 年 3 月 19 日
As I mentioned in the previous message, let's V==V_1=V_2 and r<2 for simplification. So the solution is x_1=x_2=r*V/4
Why MATLAB can't solve it using solve function?? I got an empty solution
syms V x_1 x_2 r
pi1 = (V) * (x_1^r/(x_1^r+x_2^r)) - x_1
pi2 = (V) * (x_2^r/(x_1^r+x_2^r)) - x_2
dpi1dx = diff(pi1, x_1)
dpi2dx = diff(pi2, x_2)
s = solve(dpi1dx==0, dpi2dx==0, x_1, x_2)
Walter Roberson
Walter Roberson 2023 年 3 月 19 日
Under the simplification of x_1 and x_2 being equal:
syms x_1 x_2
syms r V positive
pi1 = (V) * (x_1^r/(x_1^r+x_2^r)) - x_1
pi1 = 
pi2 = (V) * (x_2^r/(x_1^r+x_2^r)) - x_2
pi2 = 
dpi1dx = diff(pi1, x_1)
dpi1dx = 
dpi2dx = diff(pi2, x_2)
dpi2dx = 
eqns = subs([dpi1dx==0, dpi2dx==0], [x_2], [x_1])
eqns = 
seqns = simplify(eqns)
seqns = 
simplify(solve(seqns(2), x_1), 'steps', 20)
ans = 
Roy
Roy 2023 年 3 月 19 日
Thank you so much for your help, I have no words to appreciate it.
There is general code for general solution for x_1!=x_2 and V_1!=V_2 ?
Roy
Roy 2023 年 3 月 21 日
Please help. it's very important to me
Walter Roberson
Walter Roberson 2023 年 3 月 21 日
If you set x_2 to be a constant multiple, c, of x_1, then
syms x_1 x_2
syms c r V_1 V_2 positive
pi1 = (V_1) * (x_1^r/(x_1^r+x_2^r)) - x_1
pi1 = 
pi2 = (V_2) * (x_2^r/(x_1^r+x_2^r)) - x_2
pi2 = 
dpi1dx = diff(pi1, x_1)
dpi1dx = 
dpi2dx = diff(pi2, x_2)
dpi2dx = 
eqns = subs([dpi1dx==0, dpi2dx==0], [x_2], [c*x_1])
eqns = 
seqns = simplify(eqns)
seqns = 
sol = solve(seqns(2), x_1, 'returnconditions', true)
sol = struct with fields:
x_1: (V_2*c^r*r)/(c + c*c^(2*r) + 2*c*c^r) parameters: [1×0 sym] conditions: r < 1/2 | 1/2 <= r
simplify(sol.conditions)
ans = 
symtrue
simplify(sol.x_1, 'steps', 20)
ans = 
seqns2 = simplify(subs(seqns(1), x_1, sol.x_1), 'steps', 20)
seqns2 = 
which is to say that if x_1 and x_2 have a particular ratio, then V_1 and V_2 must have the same ratio.
Or you could read this as saying that if you know the ratio of V_1 and V_2 then x_1 and x_2 must have the same ratio, and x_1 is as given in ans above.
Notice that with V_2 == V_1 * c then V_2 / c is V_1 so ans could be rewritten as V_1 * c^r * r / (c^r+1)^2
Roy
Roy 2023 年 3 月 21 日
Wow thank you so much.
Now I noticed that even with 1 equation with 1 varible (if x_2 become only constracts) + some symbolics the matlab can't solve.
Why this is happen? the matlab is not strong to deal with it?
syms x_1 x_2 r V_1 V_2
pi1 = (V_1) * (x_1^r/(x_1^r+x_2^r)) - x_1
pi1 = 
dpi1dx = diff(pi1, x_1)
dpi1dx = 
seqns = simplify(dpi1dx==0)
seqns = 
sol = solve(seqns, x_1, 'returnconditions', true)
Warning: Unable to find explicit solution. For options, see help.
sol = struct with fields:
x_1: [0×1 sym] parameters: [1×0 sym] conditions: [0×1 sym]
Walter Roberson
Walter Roberson 2023 年 3 月 21 日
There is no mathematics that is able to find a closed form solution for that. It requires finding the set of Z such that
V_1*r*Z^(r - 1)*x_2^r - Z^(2*r) - 2*Z^r*x_2^r - x_2^(2*r)
is 0. But as I discussed earlier, it has been proven by Able and Rosser that there does not exist a general "algebraic" solution for the case where the power (2*r) > 4 -- so r = 1 and r = 2 are the positive integer cases that can be solved .
There are also solutions for r = 1/5, r = 1/3, r = 1/2, r = 3/5, and possibly some others.
Roy
Roy 2023 年 3 月 21 日
Thank you!
yes I said that there is no solution for r<2. how can I force matlab to solve it when r<2?
I tried with assume(r<2 & r>0) and I tried with add another equation "r<2", but matlab cant solve it.
thank you very very much
Walter Roberson
Walter Roberson 2023 年 3 月 21 日
The problem is not solveable for most r .
For example for r = 3/2 then the solutions are
RootOf(4*Z^3*x_2^(3/2) + 2*Z^6 - 3*Z*x_2^(3/2)*V_1 + 2*x_2^3,Z)^2
which is the set of Z such that the expression 4*etc becomes 0. But notice the Z^6 part -- so you would need the closed-form solution for a degree 6 polynomial, and such solutions only exist if the expression can be factored into polynomials of degree 4 or lower.
If r = N/4 for odd integer N, then you need to solve something of degree either 2*N+4 (for small N) or degree 2*N (starting at N = 5). r = 1/5 and r = 3/5 are tractable (but long!!), the other N/5 are not tractable.
Roy
Roy 2023 年 3 月 21 日
noway :(
this is the solution for general r and V_1 != V_2
x_1 = V_2*(r*(V_2/V_1)^(r-1))/(1+(V_2/V_1)^r)^2
x_2 = V_1*(r*(V_1/V_2)^(r-1))/(1+(V_1/V_2)^r)^2
placing x_1 and x_2 and the dpi1dx and dpi2dx become them to 0.

サインインしてコメントする。

Roy
Roy 2023 年 3 月 21 日

0 投票

Why MATLAB can't solve this simple equations?
the solution for general r and V_1 != V_2:
x_1 = V_2*(r*(V_2/V_1)^(r-1))/(1+(V_2/V_1)^r)^2
x_2 = V_1*(r*(V_1/V_2)^(r-1))/(1+(V_1/V_2)^r)^2
placing x_1 and x_2 and the dpi1dx and dpi2dx become them to 0.

3 件のコメント

Torsten
Torsten 2023 年 3 月 22 日
編集済み: Torsten 2023 年 3 月 22 日
Are you sure the two expressions below turn out to be 0 ?
syms V_1 V_2 x_1 x_2 r
pi1 = (V_1) * (x_1^r/(x_1^r+x_2^r)) - x_1
pi1 = 
pi2 = (V_2) * (x_2^r/(x_1^r+x_2^r)) - x_2
pi2 = 
dpi1dx = diff(pi1, x_1)
dpi1dx = 
dpi2dx = diff(pi2, x_2)
dpi2dx = 
simplify(subs(dpi1dx,[x_1 x_2],[V_2*(r*(V_2/V_1)^(r-1))/(1+(V_2/V_1)^r)^2,V_1*(r*(V_1/V_2)^(r-1))/(1+(V_1/V_2)^r)^2]))
ans = 
simplify(subs(dpi2dx,[x_1 x_2],[V_2*(r*(V_2/V_1)^(r-1))/(1+(V_2/V_1)^r)^2,V_1*(r*(V_1/V_2)^(r-1))/(1+(V_1/V_2)^r)^2]))
ans = 
Walter Roberson
Walter Roberson 2023 年 3 月 22 日
If you add the assumption of positive then they do resolve to 0
syms V_1 V_2 x_1 x_2 r positive
pi1 = (V_1) * (x_1^r/(x_1^r+x_2^r)) - x_1
pi1 = 
pi2 = (V_2) * (x_2^r/(x_1^r+x_2^r)) - x_2
pi2 = 
dpi1dx = diff(pi1, x_1)
dpi1dx = 
dpi2dx = diff(pi2, x_2)
dpi2dx = 
simplify(subs(dpi1dx,[x_1 x_2],[V_2*(r*(V_2/V_1)^(r-1))/(1+(V_2/V_1)^r)^2,V_1*(r*(V_1/V_2)^(r-1))/(1+(V_1/V_2)^r)^2]))
ans = 
0
simplify(subs(dpi2dx,[x_1 x_2],[V_2*(r*(V_2/V_1)^(r-1))/(1+(V_2/V_1)^r)^2,V_1*(r*(V_1/V_2)^(r-1))/(1+(V_1/V_2)^r)^2]))
ans = 
0
Roy
Roy 2023 年 3 月 22 日
編集済み: Roy 2023 年 3 月 22 日
So why MATLAB can't solve it, and extract these x_1 and x_2 when dpi1dx=0 and dpi2dx=0 using solve() or something else?
Btw, all the varibles are positive
There is solution for this simple equations :(
x_1 = V_2*(r*(V_2/V_1)^(r-1))/(1+(V_2/V_1)^r)^2 x_2 = V_1*(r*(V_1/V_2)^(r-1))/(1+(V_1/V_2)^r)^2

サインインしてコメントする。

カテゴリ

製品

リリース

R2020b

質問済み:

Roy
2023 年 3 月 16 日

コメント済み:

2023 年 3 月 24 日

Community Treasure Hunt

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

Start Hunting!

Translated by