Status: Valid
Owner: ----
Labels: Type-Defect Priority-Medium Solvers
New issue 3545 by [email protected]: solving a complicated expression with
square roots
http://code.google.com/p/sympy/issues/detail?id=3545
From http://colabti.org/irclogger/irclogger_log/sympy?date=2012-12-02
09:05 R0b0t1 asmeurer__, if I try solve(expr = expr, var), I get something
about "the argument to solve can not be a statement"
09:05 R0b0t1 also, it seems like SymPy is flat-out incapable of solving an
equation I give it, yet my TI-89 can
09:06 asmeurer__ you cannot use == to mean symbolic equality
09:06 asmeurer__ you need to use Eq()
09:06 asmeurer__ or just subtract one side from another
09:07 asmeurer__ like solve(x**2 - 1, x) or solve(Eq(x**2, 1), x)
09:08 asmeurer__ you can't use = either. that is python syntax for variable
assignment
09:10 R0b0t1 derp
09:10 R0b0t1 Well, thanks. I was just subtracting, but sometimes found it a
pain.
09:13 R0b0t1 As for sympy not being able to solve some things... Do I have
any recourse? Doing them by hand is insanely infuriating.
09:14 asmeurer__ can you give an example?
09:14 asmeurer__ sympy is better at solving some kinds of expressions than
others
09:16 R0b0t1 How might I change the printing so it isn't pretty anymore?
09:17 asmeurer__ init_printing(pretty_print=False)
09:17 asmeurer__ or if you just want to print one expression, just use
print
09:17 asmeurer__ or str()
09:18 R0b0t1 sqrt((-m**2/2 - sqrt(4*m**4 - 4*m**2 + 8*m + 1)/4 - 1/4)**2 +
(m**2/2 - m - sqrt(4*m**4 - 4*m**2 + 8*m + 1)/4 - 1/4)**2) == sqrt((m -
q)**2 + (-m/(2*q) + 1/2)**2)
09:18 R0b0t1 for example
09:19 asmeurer__ solving for m I take it
09:19 R0b0t1 Er, sorry, solving for q.
09:19 R0b0t1 It can solve for m.
09:19 R0b0t1 I've tried rearranging or trying to make the equation "nicer",
but nothing has helped.
09:20 R0b0t1 My TI-89, solved it, I got 2m^2*abs((m-1)/(2m+1))+m
09:20 asmeurer__ yeah, it doesn't know what to do with the square roots
09:21 R0b0t1 There is a form of this equation I could possibly remove the
square roots from by hand, I'll try that
09:21 asmeurer__ you could try squaring both sides, then moving the inner
square root to one side, and squaring both sides again
09:21 R0b0t1 Alright, thanks
09:21 asmeurer__ you'll need to check the solutions when you are done
because squaring can introduce new solutions
09:21 R0b0t1 Mhmm
09:22 asmeurer__ ah, maybe not that easy
09:22 asmeurer__ I didn't notice that the inner square roots are inside a
square
09:24 asmeurer__ actually...
09:25 asmeurer__ oh, you are solving for q, not m
09:28 asmeurer__ I can get a very nasty solution for q, but you have to do
solve(expr, q, simplify=False, check=False), or else it hangs
09:29 R0b0t1 oh my good god
09:30 R0b0t1 this could perhaps work for my purposes, but I still want to
know what magic my TI89 does...
09:30 asmeurer__ not sure if any of them are the same as the ti one
actually
09:30 asmeurer__ if I numerically evaluate at a random point, it comes out
different
09:31 R0b0t1 :S
09:31 asmeurer__ you can solve for m, though
09:31 asmeurer__ that is a relatively simple solution
09:32 R0b0t1 Yeah. I'm not sure how it would help me, however... I'll
perhaps have to try to use a solution for m.
09:32 R0b0t1 http://pastebin.com/GHL9R4Yv
09:33 R0b0t1 Thanks for your help
09:33 R0b0t1 (above is if you wanted to know how I got that ridiculous
thing in the first place)
09:33 asmeurer__ let me open a sympy issue for this
09:33 asmeurer__ maybe someone else who has more time than I do can make
sense of it
Here is the contents of the pastebin, since it expires in 21 hours:
Let f(x) = x and g(x) = x**2.
Let
t(m, x) = g'(m)*x - g'(m)*m + g(m)
and
p(m, x) = -x/g'(m) + m/g'(m) + g(m)
Find n such that
p(m, n) = n
Using n, find q so
sqrt((n - m)**2 + (f(n) - t(m, m))**2) = sqrt((m - q)**2 + (t(m, m) - p(m,
q))**2)
There may be more to the IRC discussion at the link at the top, if more
happened after I clicked submit here.
--
You received this message because you are subscribed to the Google Groups
"sympy-issues" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to
[email protected].
For more options, visit this group at
http://groups.google.com/group/sympy-issues?hl=en.