[sage-support] Re: simplification options
Hi Michael, On 2019-03-11, Michael Beeson wrote: > I tried various simplification functions.I suppose I could start over, > not using "symbolic expressions" but > declaring K to be a suitable field or ring, maybe a quadratic extension of > the field of rational functions in a. > That is probably the "right" way to do it. Probably! > But I wish there were a simpler way. Why do you think using a sub-optimal far too general tool (e.g., symbolic variables when in fact the problem is about polynomial) is "simpler"? Best regards, Simon -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: simplification options
Le lundi 11 mars 2019 19:05:04 UTC+1, Michael Beeson a écrit : > > I appreciate Eric's post, and I do use subs sometimes, but it makes me > nervous since > it will happily substitute any old thing you tell it to, even an > incorrect thing. So, if your idea > is to check a computation, it is a dangerous thing. > In order to minimize the error risk in the substitution, note that you can use the Python variable b defined as b = sqrt(1-a^2) in the argument of subs(), thereby avoiding any duplicate code. The whole code becomes then sage: var('p,q,r,a') # note: no b at this stage (p, q, r, a) sage: b = sqrt(1-a^2) sage: eq = (p*a+r*b+q)^2 sage: eq = eq.expand(); eq a^2*p^2 - a^2*r^2 + 2*sqrt(-a^2 + 1)*a*p*r + 2*a*p*q + 2*sqrt(-a^2 + 1)*q*r + q^2 + r^2 sage: eq.subs({b: SR.var('b')}) a^2*p^2 + 2*a*b*p*r - a^2*r^2 + 2*a*p*q + 2*b*q*r + q^2 + r^2 -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: simplification options
On Monday, March 11, 2019 at 11:05:04 AM UTC-7, Michael Beeson wrote: > > I appreciate Eric's post, and I do use subs sometimes, but it makes me > nervous since > it will happily substitute any old thing you tell it to, even an > incorrect thing. So, if your idea > is to check a computation, it is a dangerous thing. True, if you put > only correct equations in, > you'll usually get correct ones out. > Checking a result is usually much easier: Take the original form of the equation, subtract the simplified form, and check that the difference is divisible by the relations you impose, such as b^2-(1-a^2). No special normal forms are required, just a divisibility test. This gets more complicated when there are more relations, because then you'll need an ideal membership test, but then you can just present that as "the computational tool" (plus, with a bit of luck you can extract the way in which the difference can be expressed in terms of the generating relations. The algorithm in principle encounters that information on the way) -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: simplification options
I appreciate Eric's post, and I do use subs sometimes, but it makes me nervous since it will happily substitute any old thing you tell it to, even an incorrect thing. So, if your idea is to check a computation, it is a dangerous thing. True, if you put only correct equations in, you'll usually get correct ones out. -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.
[sage-support] Re: simplification options
What about something like sage: var('p,q,r,a') (p, q, r, a) sage: b = sqrt(1-a^2) sage: eq = (p*a+r*b+q)^2 sage: eq = eq.expand(); eq a^2*p^2 - a^2*r^2 + 2*sqrt(-a^2 + 1)*a*p*r + 2*a*p*q + 2*sqrt(-a^2 + 1)*q*r + q^2 + r^2 sage: b = var('b') sage: eq.subs({sqrt(1-a^2): b}) a^2*p^2 + 2*a*b*p*r - a^2*r^2 + 2*a*p*q + 2*b*q*r + q^2 + r^2 -- You received this message because you are subscribed to the Google Groups "sage-support" group. To unsubscribe from this group and stop receiving emails from it, send an email to sage-support+unsubscr...@googlegroups.com. To post to this group, send email to sage-support@googlegroups.com. Visit this group at https://groups.google.com/group/sage-support. For more options, visit https://groups.google.com/d/optout.