Symbolic solve with user-specified precision
2 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hi all,
I have 9 polynomial equations i would love to simplify using
solve(equ, [beta_bar sigma_bar phi_bar theta_bar phi_pi_bar phi_y_bar g_23],'Real',true,'ReturnConditions', true)
where
equ =
[0 < beta_bar, beta_bar < 1, 0 < sigma_bar, 0 < phi_bar, 0 < phi_pi_bar, 0 < phi_y_bar, g_23^2 - 6835969944064461/9007199254740992 == 0, phi_y_bar - 3907/20000 == 0, phi_pi_bar - 14709/10000 == 0, g_23*theta_bar - (7846842892884325*theta_bar)/9007199254740992 == 0, (11137*g_23)/10000 - (7846842892884325*phi_bar)/9007199254740992 + g_23*phi_bar - 1092378616225659/1125899906842624 == 0, (6250*phi_bar)/6197 - (2659174770252075*theta_bar)/1125899906842624 - (12447*phi_bar*theta_bar)/6197 + phi_bar*theta_bar^2 + (11137*theta_bar^2)/10000 + 55685/49576 == 0, sigma_bar - 11137/10000 == 0, beta_bar*theta_bar - (6197*theta_bar)/6250 == 0, (11137*beta_bar)/10000 - (6197*phi_bar)/6250 + beta_bar*phi_bar - 1243281529372025/1125899906842624 == 0]
so they would look nicer and cleaner, then i can feed them to a optimizer to find each parameter's maximum/minimum. The reason i don't do this simple exercise by hand is i have a lot of similar equations to solve sequentially, so i would love to automate this procedure.
As you can see, there should be infinite solutions and i want parametrized full solutions (so maybe vpasolve is not a good idea?), but matlab threw me a empty solution set. I think it might be because of a precision reason.
Is there any way to get around this ?
Thank you!
5 Commenti
Torsten
il 27 Lug 2022
Modificato: Torsten
il 27 Lug 2022
Inequalities are no equations. So you can't specify inequalities in "solve". Maybe you can use "assume" to set conditions on the solution.
The number of equations must be equal to the number of unknowns.
Try to run your code after the necessary changes.
Risposte (2)
John D'Errico
il 27 Lug 2022
Modificato: John D'Errico
il 27 Lug 2022
Your belief has preciously little value. Faith in mathematics tends to be a waste of mental energy. Let me expand your equations, looking at them one at a time.
0 < beta_bar
beta_bar < 1
0 < sigma_bar
0 < phi_bar
0 < phi_pi_bar
0 < phi_y_bar
So those are simply lower and upper bounds on the problem. Solve does not understand inequalities, because they never give a unique solution.
syms g_23 phi_y_bar phi_pi_bar theta_bar phi_bar sigma_bar beta_bar
g_23 = solve(g_23^2 - 6835969944064461/9007199254740992 == 0)
That gave us two potential solutions for g_23. One is positive, one negative, but you never said anything about what g_23 should be.
phi_y_bar = solve(phi_y_bar - 3907/20000 == 0)
phi_pi_bar = solve(phi_pi_bar - 14709/10000 == 0)
Those pair of equations simply assign values to variables. Why would you put lower and upper bounds on something when you then assign it a value?
Next, we see the equation for theta_bar. It has a trivial solution, regardless of the value of g_23.
theta_bar = solve(g_23*theta_bar - (7846842892884325*theta_bar)/9007199254740992 == 0,theta_bar)
Yep. theta_bar is just ZERO. You can see that, if you factor out theta_bar.
Next, we see an equation for phi_bar. I'll tell vpa to just write out the equation itself. Remember, that you told us that phi_bar MUST be positive.
vpa((11137*g_23)/10000 - (7846842892884325*phi_bar)/9007199254740992 + g_23*phi_bar - 1092378616225659/1125899906842624 == 0,5)
Do you see the first case? That tells us that phi_bar is NEGATIVE. Or the second term offers the possibility that phi_bar is EXACTLY zero. But you told us that phi_bar MUST be positive. Neither of the solutions are valid.
The fact is, we can stop right now. There are NO solutions to your problem.
While I could look at the rest of your problem, there is no need to proceed further. Well, I could write them down. This next one again tells us that phi_bar is NEGATIVE. But since we know it is not allowed to be negative...
(6250*phi_bar)/6197 - (2659174770252075*theta_bar)/1125899906842624 - (12447*phi_bar*theta_bar)/6197 + phi_bar*theta_bar^2 + (11137*theta_bar^2)/10000 + 55685/49576 == 0
sigma_bar - 11137/10000 == 0
beta_bar*theta_bar - (6197*theta_bar)/6250 == 0
(11137*beta_bar)/10000 - (6197*phi_bar)/6250 + beta_bar*phi_bar - 1243281529372025/1125899906842624 == 0
Again, faith is a waste of mental energy. This is simply not a precision problem, but a question of existence at all.
5 Commenti
Paul
il 27 Lug 2022
Modificato: Paul
il 27 Lug 2022
Hi @Kylekk
Perhaps I don't fully understand the Question, but I don't think there's a way to force the Symbolic Toolbox to find an "approximate" solution, if that's the desire.
The equations to be solved are:
syms g_23 phi_y_bar phi_pi_bar phi_bar theta_bar sigma_bar beta_bar real
equ(1) = g_23^2 - 6835969944064461/9007199254740992 == 0;
equ(2) = phi_y_bar - 3907/20000 == 0;
equ(3) = phi_pi_bar - 14709/10000 == 0;
equ(4) = g_23*theta_bar - (7846842892884325*theta_bar)/9007199254740992 == 0;
equ(5) = (11137*g_23)/10000 - (7846842892884325*phi_bar)/9007199254740992 + g_23*phi_bar - 1092378616225659/1125899906842624 == 0;
equ(6) = (6250*phi_bar)/6197 - (2659174770252075*theta_bar)/1125899906842624 - (12447*phi_bar*theta_bar)/6197 + phi_bar*theta_bar^2 + (11137*theta_bar^2)/10000 + 55685/49576 == 0;
equ(7) = sigma_bar - 11137/10000 == 0;
equ(8) = beta_bar*theta_bar - (6197*theta_bar)/6250 == 0;
equ(9) = (11137*beta_bar)/10000 - (6197*phi_bar)/6250 + beta_bar*phi_bar - 1243281529372025/1125899906842624 == 0;
The constraints on the variables are
assume([0 < beta_bar, beta_bar < 1, 0 < sigma_bar, 0 < phi_bar, 0 < phi_pi_bar, 0 < phi_y_bar]);
As noted, solve can't find a solution to all nine equations under the stated assumptions.
sol = solve(equ,[beta_bar sigma_bar phi_bar theta_bar phi_pi_bar phi_y_bar g_23],'Real',true,'ReturnConditions',true)
solve can't find a solution without the assumptions
sol = solve(equ,[beta_bar sigma_bar phi_bar theta_bar phi_pi_bar phi_y_bar g_23],'Real',true,'ReturnConditions',true,'IgnoreProperties',true)
However, there is a unique solution when considering all but equation 6
sol = solve(equ([1:5 7:9]),[sigma_bar beta_bar phi_bar theta_bar phi_pi_bar phi_y_bar g_23],'Real',true,'ReturnConditions',true)
However, equation 6 is not close to being satisfied with that solution
vpa(subs(equ(6),[phi_bar theta_bar],[sol.phi_bar sol.theta_bar]))
So the equations as written are not consistent.
It sounds like the goal might be an approximate solution? In which case it may be possible to set up some or all of equ as inequalities, like
abs(lhs(equ(1))) < .001
No idea if that's really going to help get to an answer.
1 Commento
Vedere anche
Categorie
Scopri di più su Number Theory in Help Center e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!