Please help
You are now following this question
- You will see updates in your followed content feed.
- You may receive emails, depending on your communication preferences.
Slove function return empty solutions
3 views (last 30 days)
Show older comments
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)
Answers (2)
Walter Roberson
on 16 Mar 2023
Use dsolve for differential equations
20 Comments
Walter Roberson
on 16 Mar 2023
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
Walter Roberson
on 17 Mar 2023
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.
Walter Roberson
on 18 Mar 2023
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
on 19 Mar 2023
Edited: Roy
on 19 Mar 2023
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
on 19 Mar 2023
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
on 19 Mar 2023
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
on 19 Mar 2023
@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
on 19 Mar 2023
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
on 19 Mar 2023
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 =

Walter Roberson
on 21 Mar 2023
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
on 21 Mar 2023
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
on 21 Mar 2023
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
on 21 Mar 2023
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
on 21 Mar 2023
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
on 21 Mar 2023
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 Comments
Torsten
on 22 Mar 2023
Edited: Torsten
on 22 Mar 2023
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
on 22 Mar 2023
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
on 22 Mar 2023
Edited: Roy
on 22 Mar 2023
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
See Also
Categories
Find more on Calculus in Help Center and File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!An Error Occurred
Unable to complete the action because of changes made to the page. Reload the page to see its updated state.
Seleziona un sito web
Seleziona un sito web per visualizzare contenuto tradotto dove disponibile e vedere eventi e offerte locali. In base alla tua area geografica, ti consigliamo di selezionare: .
Puoi anche selezionare un sito web dal seguente elenco:
Come ottenere le migliori prestazioni del sito
Per ottenere le migliori prestazioni del sito, seleziona il sito cinese (in cinese o in inglese). I siti MathWorks per gli altri paesi non sono ottimizzati per essere visitati dalla tua area geografica.
Americhe
- América Latina (Español)
- Canada (English)
- United States (English)
Europa
- Belgium (English)
- Denmark (English)
- Deutschland (Deutsch)
- España (Español)
- Finland (English)
- France (Français)
- Ireland (English)
- Italia (Italiano)
- Luxembourg (English)
- Netherlands (English)
- Norway (English)
- Österreich (Deutsch)
- Portugal (English)
- Sweden (English)
- Switzerland
- United Kingdom (English)
Asia-Pacifico
- Australia (English)
- India (English)
- New Zealand (English)
- 中国
- 日本Japanese (日本語)
- 한국Korean (한국어)