Why do solutions get lost when I add a assumption where I know, that the correct solution would satisfie this assumption. Same if I add the inequality instead of the assume
6 visualizzazioni (ultimi 30 giorni)
Mostra commenti meno recenti
Hey,
I have a question refering to the the symbolic solution of a system of equations and unequations.
If I run my system of equations with solve, it finds a solution which satisfies x+y>1, as expected. But if I add x+y>1 as an inequation in solve or I demand this by assume(x+y>1), than the solution either gets lost or I get a warning "not able to find an explicit solution". Why is that so?
Thank to everybody who trys to help.
2 Commenti
Torsten
il 13 Ago 2023
Maybe you didn't specify x and y as real-valued:
syms x y real
?
We cannot tell because we don't know your problem.
Risposte (1)
Walter Roberson
il 13 Ago 2023
First of all, the Symbolic Engine is not very good about reasoning with inequalities.
Second of all, when the Symbolic Engine returns an indication of an solution inequality (range) and you do not have ReturnConditions set, then when you go to display, the MATLAB level examines the range and picks one representative value from the range to present, without indication that an inequality exists.
For example,
syms X
ineq = (X-3)^2+2<5
sol1 = solve(ineq)
sol2 = solve(ineq, 'returnconditions', true)
sol2.X
sol2.parameters
sol2.conditions
In sol2, the first solution for X involves values of a parameter x such that particular conditions are met. In sol1, the MATLAB level's rules about picking one particular solution first checked 0, found that did not work, then checked π and found that did work so it arbitrarily picked π . In sol2, the second solution for X involves all real-valued x; the value 0 is first checked and found to be an acceptable real so 0 is substitued into the 3+x*i giving 3 as the solution for sol1 .
Both cases are families of solutions, but the MATLAB level has presented π and 3 as if they are the only solutions. It is rather misleading.
Thus you have two situations: the internal computation engine can only handle relatively simple inequalities; and the MATLAB level gives weak or misleading answers even when the computation engine is able to reason about the inequalities.
Often, in order to deal with inequalities, you have to convert the expression into a equality involving an extra variable that you constrain to be > 0 or >= 0 . For example,
syms delta_xy positive
eqn = x + y == 1 + delta_xy
with delta_xy constrained to be non-negative, x + y > 1 has to be true.
5 Commenti
Walter Roberson
il 15 Ago 2023
If I say A11 ... C23 real than it doenst catch all solutions
Yes, that does indeed happen with the Symbolic Engine.
How long can it take until the programm realises, that chasing down one variable leeds to nothing
Let me put it this way: I ran one symbolic calculation for 13 days. When I put in a breakpoint and checked to see how far it had reached, I could see that it was only a small fraction of the way through.
As far as I know, the algorithms in the Symbolic Engine do not have any checks along the lines of "It's been 3 days already, this is too hard, I'm going to give up!"
Walter Roberson
il 15 Ago 2023
I have sometimes solved for a few variables "manually", substituted the values in, and asked to solve() the result.
- Sometimes the result is something that the Symbolic Engine gives up on, or takes much longer on than if I had not done the pre-calculation -- that is, sometimes my steps make the situation worse.
- Sometimes the result is something that the Symbolic Engine is able to calculate with, when otherwise it would have given up. This is especially the case when there are fractional powers involved: the Symbolic Engine has a tendancy to give up on fractional powers earlier than necessary.
- Sometimes the result is just to be able to track down what, more precisely, is preventing the calculation from working. When solve() cannot find a solution, it never explains what is wrong; sometimes you need to guide it through steps to figure out the mathematical issue being encountered.
If you can eliminate variables appearing linearly then it might well be worth doing so. Beyond that, elimination tends to help more often than not, but elimination can cause problems as well.
Vedere anche
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!