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.Mon, 03 Dec 2018 04:22:20 +0100Sage doesn't simplify a fraction if it's multiplied by 2https://ask.sagemath.org/question/44544/sage-doesnt-simplify-a-fraction-if-its-multiplied-by-2/Hello, for some reason sage doesn't simplify a trigonometric expression:
sage: ( 2 * (1-cos(x)) / sqrt(1-cos(x)) ).simplify_full()
-2*(cos(x) - 1)/sqrt(-cos(x) + 1)
while I'd expect `sqrt(1-cos(x))`.
I also tried a nice `simplify_chain_real` function (thanks eric_g for [the hint](https://ask.sagemath.org/question/44414/canonicalize_radical-produces-incorrect-result/?answer=44421#post-id-44421)) but I've got the same result:
sage: from sage.manifolds.utilities import simplify_chain_real
sage: simplify_chain_real( 2 * (1-cos(x)) / sqrt(1-cos(x)) )
-2*(cos(x) - 1)/sqrt(-cos(x) + 1)
The weird thing is that it works without the `2*` part:
sage: ( (1-cos(x)) / sqrt(1-cos(x)) ).simplify_full()
sqrt(-cos(x) + 1)
And even replacing `-` with `+` makes it working:
sage: ( 2*(1+cos(x))/sqrt(1+cos(x)) ).simplify_full()
2*sqrt(cos(x) + 1)
I mean, obviously, it can do that kind of simplification. But I can't make it simplify the `2*(1-cos(x))/sqrt(1-cos(x))` expression. What do I miss?sagenoviceMon, 03 Dec 2018 04:22:20 +0100https://ask.sagemath.org/question/44544/.canonicalize_radical() produces incorrect resulthttps://ask.sagemath.org/question/44414/canonicalize_radical-produces-incorrect-result/I'm trying to simplify some trigonometric expressions using sage, and I noticed that .simplify_full() doesn't optimize those, unless a .canonicalize_radical() is used (thanks slelievre for [the hint](https://ask.sagemath.org/question/44391/simplify_full-doesnt-simplify-an-obvious-trigonometric-expression/?answer=44392#post-id-44392)). But that yields incorrect results for some expressions. For example:
sage: y = sqrt(sin(x)^2 + 4*sin(x) + 4) - sqrt(sin(x)^2 - 4*sin(x) + 4)
sage: y.simplify_full()
sqrt(sin(x)^2 + 4*sin(x) + 4) - sqrt(sin(x)^2 - 4*sin(x) + 4)
.canonicalize_radical() simplifies it further:
sage: y.canonicalize_radical()
4
But that is wrong! The answer should be `2*sin(x)`. Obviously it selected an incorrect sign for the second sqrt(...).
Is there a way to make .canonicalize_radical() smarter? Or any other way to simplify an expression like this correctly?sagenoviceSat, 24 Nov 2018 16:01:17 +0100https://ask.sagemath.org/question/44414/.simplify_full() doesn't simplify an obvious trigonometric expressionhttps://ask.sagemath.org/question/44391/simplify_full-doesnt-simplify-an-obvious-trigonometric-expression/Hello, I'm trying to simplify a trigonometric expression, and it didn't work as I expected. The original example was larger, but I reproduced the issue with a smaller one:
sage: y = (sin(x)+2) * sqrt( sin(x) / (sin(x)^2 + 4*sin(x) + 4) )
sage: y.simplify_full()
sqrt(sin(x)/(sin(x)^2 + 4*sin(x) + 4))*(sin(x) + 2)
Why doesn't that turn into `sqrt(sin(x))`? What do I miss?
sagenoviceFri, 23 Nov 2018 09:50:56 +0100https://ask.sagemath.org/question/44391/Simplifying rational expressionshttps://ask.sagemath.org/question/39111/simplifying-rational-expressions/I am working with a power series with coefficients being rational functions of several variables (everything over QQ). Is there any way to make sage automatically simplify the coefficients?
Here is an example of what is going on
k=RR.zero()+(-524288*x^2 - 1048576*x*y - 524288*y^2 + 524288*x*z + 524288*y*z)/(-1048576*z^2)
print k
print u
print u-k
print (simplify(u))
print u
print parent(u)
print parent(k)
print factor(u.numerator())/factor(u.denominator())
And results:
(1/2*x^2 + x*y + 1/2*y^2 - 1/2*x*z - 1/2*y*z)/z^2
(-524288*x^2 - 1048576*x*y - 524288*y^2 + 524288*x*z + 524288*y*z)/(-1048576*z^2)
0
(-524288*x^2 - 1048576*x*y - 524288*y^2 + 524288*x*z + 524288*y*z)/(-1048576*z^2)
(-524288*x^2 - 1048576*x*y - 524288*y^2 + 524288*x*z + 524288*y*z)/(-1048576*z^2)
Fraction Field of Multivariate Polynomial Ring in x, y, z over Rational Field
Fraction Field of Multivariate Polynomial Ring in x, y, z over Rational Field
(-1/2) * z^-2 * (-x - y + z) * (x + y)AntWed, 11 Oct 2017 06:20:26 +0200https://ask.sagemath.org/question/39111/simplification errors in simple expressionshttps://ask.sagemath.org/question/8324/simplification-errors-in-simple-expressions/I'm currently testing the possibilities of SAGE as a teaching aid in a high school math course (in Belgium). I stumbled upon this:
- When evaluating x/sqrt(x^2), SAGE answers $\frac{x}{|x|}$, as it should. Appending a ***.simpify()***-instruction to the input does not change anything.
- However, `((1-x^2)/sqrt(1-2*x^2+x^4)).simplify_full()` evaluates to $-1$, in stead of $\frac{1-x^2}{|1-x^2|}$.
As an aside, it's definitely baffling that a behemoth program like SAGE is outdone in this respect by a one-floppy-disk, antique program called DERIVE.
As another aside, I still have to find a meaningful use for the instruction ***simplify()***. Can someone provide me an expression that is actually simplified by simplify()?
***Note added:***
I'm not sure I'm satisfied with mr. Fateman's answer (and I definitely disagree that defining sqrt(x^2)=|x| - for real x - entails +1=-1). But what I really want to know is this: is there a SAGE object that represents (reliably) the positive square root of a positive real number x? (Surely a quantity that is not without interest.) And how do I define it in SAGE?Dirk DanckaertThu, 22 Sep 2011 17:53:33 +0200https://ask.sagemath.org/question/8324/simplify sinh expressionhttps://ask.sagemath.org/question/9723/simplify-sinh-expression/I guess I just ran up against one of those maxima things again, but I thought I would signal the problem anyway.
I would have expected Sage to simplify
sinh(log(1+sqrt(2)))
(it is 1), but Sage doesn't. It doesn't return True to the following either
arcsinh(1)==1+sqrt(2)
or am I missing something?Dirk DanckaertSun, 20 Jan 2013 11:13:50 +0100https://ask.sagemath.org/question/9723/Why simplify doesn't work?https://ask.sagemath.org/question/9558/why-simplify-doesnt-work/Hi! My problem is that I don't want to use simplify_full(). It messes up the way my formulea look preety bad. Yet I have in them terms of the form:
f(x,y)=(x^y)^(1/y)
and these a left untouched by simplify(). Is there any way for sage to recognize, that f=x without simplify_full()?
.
(Here's what i mean by messed up formula:
var('x,b2,b1')
f1(x,b1,b2)= e^(-x/b2)/b2 - e^(-x/b1)/b1
f2(x,b1,b2)= x
f1=f1( x=log( (b1/b2)^(b1*b2/(b1-b2)) ) )
f2=f2( x=log( (b1/b2)^(b1*b2/(b1-b2)) ) )
show( f1.simplify_full() + f2.simplify_full()== (f1+f2).simplify_full() )
The lhs looks way better, doesn't it?)
.
Big thanks in advance for any comments!ozikThu, 22 Nov 2012 20:17:49 +0100https://ask.sagemath.org/question/9558/simplify_full developmenthttps://ask.sagemath.org/question/8684/simplify_full-development/Hi! Could someone elaborate on the status of the simplification routines in SAGE? I've noticed that the simplify_full can't exactly be said to compete with e.g. mathematica's corresponding FullSimplify...
I don't know if the simplify functions operate as replacement rules or such, but if they do, I might be able to contribute in the development (I'm not much of a programmer though).
So could someone please explain about how simplify_full and other simplification functions work, and how I and others can participate? This post could work as an info for all who want to take part!H. ArponenTue, 31 Jan 2012 11:03:17 +0100https://ask.sagemath.org/question/8684/simplify() does not work?https://ask.sagemath.org/question/8101/simplify-does-not-work/I enter:
sage: a, b = var('a, b'); simplify((a + b)^2 - a^2 - 2*a*b - b^2)
and I would expect 0 (i.e. zero) as a result from simplify(),
but instead I get back unmodified:
(a + b)^2 - a^2 - 2*a*b - b^2
Am I missing anything?
I just started using it and it looks very promissing...ryszard314159Wed, 04 May 2011 10:35:34 +0200https://ask.sagemath.org/question/8101/