ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 04 Dec 2011 11:09:30 +0100wrong variable in solution of an inequalityhttps://ask.sagemath.org/question/8527/wrong-variable-in-solution-of-an-inequality/Hi everybody,
I am new to sage, trying to solve an inequality using sage, i.e:
`m,a,d,w,e,c=var('m,a,d,w,e,c')`
`x_br=1/2*(2*c*d - d*e - d*w)/(2*d*m - e + w)`
`solve(x_br<=d/2,m)`
But what I get is:
`[[w == -2*d*m + c], [d == 0], [max(-2*d*m + e, -d*m + c) < w, 0 <
d], [-2*d*m + e < w, w < -d*m + c, d < 0, -d*m + e < c],
[-d*m + c < w, w < -2*d*m + e, d < 0, c < -d*m + e], [w <
min(-d*m + c, -2*d*m + e), 0 < d]]`
It is solved based on `w` instead of `m`. I tried different variables but the result is always the same. What should I do to have solution based on `x`?
Thank you in advance.
Sat, 03 Dec 2011 10:37:53 +0100https://ask.sagemath.org/question/8527/wrong-variable-in-solution-of-an-inequality/Answer by benjaminfjones for <p>Hi everybody,</p>
<p>I am new to sage, trying to solve an inequality using sage, i.e:</p>
<p><code>m,a,d,w,e,c=var('m,a,d,w,e,c')</code></p>
<p><code>x_br=1/2*(2*c*d - d*e - d*w)/(2*d*m - e + w)</code></p>
<p><code>solve(x_br<=d/2,m)</code></p>
<p>But what I get is:</p>
<p><code>[[w == -2*d*m + c], [d == 0], [max(-2*d*m + e, -d*m + c) < w, 0 <
d], [-2*d*m + e < w, w < -d*m + c, d < 0, -d*m + e < c],
[-d*m + c < w, w < -2*d*m + e, d < 0, c < -d*m + e], [w <
min(-d*m + c, -2*d*m + e), 0 < d]]</code></p>
<p>It is solved based on <code>w</code> instead of <code>m</code>. I tried different variables but the result is always the same. What should I do to have solution based on <code>x</code>?</p>
<p>Thank you in advance.</p>
https://ask.sagemath.org/question/8527/wrong-variable-in-solution-of-an-inequality/?answer=12965#post-id-12965The problem here might be that Sage doesn't know whether your variables are positive or negative. If you don't make more assumptions there may be no way to solve the inequality symbolically.
It looks like in your inequality, the solution would strongly depend on whether `(2*d*m - e + w)` is positive or negative, and also whether `d` is positive or negative.
Try looking at the documentation for the function `solve_ineq` which uses Maxima to solve single inequalities in one variable or systems of inequalities in several variables.
Sat, 03 Dec 2011 12:07:52 +0100https://ask.sagemath.org/question/8527/wrong-variable-in-solution-of-an-inequality/?answer=12965#post-id-12965Comment by Elmi for <p>The problem here might be that Sage doesn't know whether your variables are positive or negative. If you don't make more assumptions there may be no way to solve the inequality symbolically. </p>
<p>It looks like in your inequality, the solution would strongly depend on whether <code>(2*d*m - e + w)</code> is positive or negative, and also whether <code>d</code> is positive or negative.</p>
<p>Try looking at the documentation for the function <code>solve_ineq</code> which uses Maxima to solve single inequalities in one variable or systems of inequalities in several variables.</p>
https://ask.sagemath.org/question/8527/wrong-variable-in-solution-of-an-inequality/?comment=20762#post-id-20762Thank you. But actually there is no assumptions about `(2*d*m - e + w)` in my problem. The only assumption is d>0 which when I apply it, it does not make any changes in the solution. Although I solved the problem by hand, I am so curious to know how to achieve desired arrangement in variables which may help me through remaining of my work. Sun, 04 Dec 2011 11:09:30 +0100https://ask.sagemath.org/question/8527/wrong-variable-in-solution-of-an-inequality/?comment=20762#post-id-20762