ASKSAGE: Sage Q&A Forum - Latest question feedhttp://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sun, 12 Jan 2020 04:17:34 -0600how to best simplify product of square rootshttp://ask.sagemath.org/question/49512/how-to-best-simplify-product-of-square-roots/I'd like to simplify expressions like
p1,p2,p3 = var('p1 p2 p3')
assume(p1>0,p2>0,p3>0)
R = p1*p2*sqrt(p3)*sqrt(p3/p1)*sqrt(p3/p2)
R
without using `R.canonicalize_radical()`, which unfortunately messes up other factors. I understand there are some options using `R.simplify_chain_real()`, but what else can I try?
Let us see an example where also `R.simplify_chain_real()` messes things up:
p1,p2,p3 = var('p1 p2 p3')
assume(p1>0,p2>0,p3>0)
# R = p1*p2*sqrt(p3)*sqrt(p3/p1)*sqrt(p3/p2)
R = p1*p2*sqrt(p3)*sqrt(p3/p1)*sqrt(p3/p2)/((p1 - p3)*(p2 - p3)*(p3 - 1))
%display latex
from sage.manifolds.utilities import simplify_chain_real
simplify_chain_real(R)
#Rrue82Sun, 12 Jan 2020 04:17:34 -0600http://ask.sagemath.org/question/49512/Square roots in finite fieldshttp://ask.sagemath.org/question/47596/square-roots-in-finite-fields/ In a finite field, say
p = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab
F = GF(p)
does the square_root function always return the root r s.t. sign(r) = +1, assuming that a root exists, where sign is the function that return -1 iff r > (p-1)/2NikolajMon, 26 Aug 2019 09:50:40 -0500http://ask.sagemath.org/question/47596/square root signhttp://ask.sagemath.org/question/47595/square-root-sign/ In a finite field, say
p = 0x1a0111ea397fe69a4b1ba7b6434bacd764774b84f38512bf6730d2a0f6b0f6241eabfffeb153ffffb9feffffffffaaab
F = GF(p)
does the square_root function always return the root r s.t. sign(r) = +1, assuming that a root exists, where sign is the function that return -1 iff r > (p-1)/2NikolajMon, 26 Aug 2019 09:50:07 -0500http://ask.sagemath.org/question/47595/Compute the square root of a complex matrixhttp://ask.sagemath.org/question/47010/compute-the-square-root-of-a-complex-matrix/Hello,
I can't find how to compute the square root of a complex matrix... I tried `m.sqrt()`, `sqrt(m)` (display only symbolic sqrt), `sqrt(m).n()`... None of them work. What is the regular way to compute the root of a complex matrix? (you can assume the matrix is self-adjoint if needed).
Thanks!
def test():
phi = matrix(CC, [[1/sqrt(2)],[i]])
m = phi * phi.C.T
print("Matrix: {}".format(m))
s = sqrt(m).n() # Does not work: AttributeError: 'ComplexField_class_with_category' object has no attribute 'complex_field'
#s = m^(1/2) # Does not work either, NotImplementedError: non-integral exponents not supported
# s = m.sqrt() # Does not work either, no attribute sqrt
print("Sqrt: {}".format(s))
print("s*s: {}".format(s*s))
if s*s == m:
print("Ok")
else:
print("Nope :(")
EDIT: For now I'm using the numpy backend with manual diagonalisation, but I'd like to know if there is a better way to proceed...
phi = matrix(CDF, [[1/sqrt(2)],[i]])
D, P = m.eigenmatrix_right()
s = P*diagonal_matrix([sqrt(x) for x in D.diagonal()])*P^-1tobiasBoraWed, 26 Jun 2019 05:21:03 -0500http://ask.sagemath.org/question/47010/How to change sqrt(5) to decimal?http://ask.sagemath.org/question/45709/how-to-change-sqrt5-to-decimal/How can i typing to change root5 to decimal?johnThu, 07 Mar 2019 10:16:54 -0600http://ask.sagemath.org/question/45709/Sage doesn't simplify a fraction if it's multiplied by 2http://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?sagenoviceSun, 02 Dec 2018 21:22:20 -0600http://ask.sagemath.org/question/44544/.canonicalize_radical() produces incorrect resulthttp://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 09:01:17 -0600http://ask.sagemath.org/question/44414/Square root of polynomial modulo another irreducible polynomialhttp://ask.sagemath.org/question/42042/square-root-of-polynomial-modulo-another-irreducible-polynomial/Hello,
If I'm not wrong, it is always possible to compute the square root of a polynomial $P$ modulo an irreducible polynomial $g$ when the base field is in $GF(2^m)$, i.e. find $Q \in GF(2^m)$ such that $Q^2 \equiv P \mod g$. Indeed, the operation $Q \rightarrow Q^2 \pmod g$ should be linear (because we are in $GF(2^m)$) so an idea would be to compute the matrix $T$ that perform this operation, and then invert it, but I'd like to find an embedded operation in sage. I tried the sagemath $P.sqrt()$ method, but the problem is that because it does not take into account the modulo, it fails most of the time when the polynomial has some terms with odd power of $X$.
Any idea?
Thanks!tobiasBoraMon, 16 Apr 2018 02:57:45 -0500http://ask.sagemath.org/question/42042/Error when calling the CRT functionhttp://ask.sagemath.org/question/39698/error-when-calling-the-crt-function/I have the following Magma code that I want to rewrite in Sage:
D := 1444451111007492249157225145240924628689936300289032719520989176681391983750\
5026233531541656521516385113467258658058158757413856041226225263754438069945819\
321862869928499936414339298248291015625;
N2tfac := [ 389017, 704969, 912673, 1030301, 1295029, 1442897, 2571353, 3307949,
3869893, 29929, 32761, 37249, 38809, 52441, 54289, 58081, 66049, 72361 ];
signs := [ 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1 ];
vecTau := [Integers()!(Sqrt(-IntegerRing(fac)!D)) : fac in N2tfac];
lst := [(-1)^(Integers()!signs[ind])*vecTau[ind] : ind in [1..#N2tfac]];
tau := CRT(lst, N2tfac);
"tau=",tau;
and when I run it I get the result of `tau= 13374843322841533370163824183368767068675387448700309211897565319967356307\
909512193392966464291429`. But when I rewrite it in Sage as this:
D = 1444451111007492249157225145240924628689936300289032719520989176681391983750\
5026233531541656521516385113467258658058158757413856041226225263754438069945819\
321862869928499936414339298248291015625
N2tfac = [ 389017, 704969, 912673, 1030301, 1295029, 1442897, 2571353, 3307949,
3869893, 29929, 32761, 37249, 38809, 52441, 54289, 58081, 66049, 72361 ]
signs = [ 1, 0, 0, 1, 1, 0, 1, 0, 1, 1, 0, 1, 1, 0, 1, 0, 1, 1 ]
vecTau = [Zmod(fac)(-D).square_root() for fac in N2tfac]
lst = [(-1)^(signs[ind])*vecTau[ind] for ind in [0..len(N2tfac)-1]]
tau = CRT(lst, N2tfac)
It gives me an error message of:
> TypeError: unsupported operand
> parent(s) for -: 'Ring of integers
> modulo 704969' and 'Ring of integers
> modulo 389017'
Any ideas what the problem might be, and how to solve it? For one thing I know that the `sqrt` function in Magma and Sage does not always return the same square root, can this be the problem? If yes, how to circumvent it, if no, what is causing the error here?whateverTue, 21 Nov 2017 08:11:18 -0600http://ask.sagemath.org/question/39698/Inconsistent result between Sage and Magma for sqrthttp://ask.sagemath.org/question/39670/inconsistent-result-between-sage-and-magma-for-sqrt/I have the following Magma code:
N2t := 625;
D := 84100;
tau:= Sqrt(-IntegerRing(N2t)!D);
tau
It basically creates a ring of integers modulo 625, evaluated it for the value of `D` with negation, and finally applies a square root calculation. Now, the result produced is `280`. When, I convert the code to Sage such as this:
N2t = 625
D = 84100
Z = Integers(N2t)
tau = sqrt(-Z(D))
tau
I get a result of `30`. Any ideas why this is the case?whateverMon, 20 Nov 2017 08:57:39 -0600http://ask.sagemath.org/question/39670/formatting fractions involving square rootshttp://ask.sagemath.org/question/32383/formatting-fractions-involving-square-roots/How can I tell sage that I want the result to be shown as $\frac{1}{\sqrt{3}}$ rather than $\frac13\sqrt3$ when I type <code>show(1/sqrt(3))</code>?BjörnSat, 30 Jan 2016 06:48:36 -0600http://ask.sagemath.org/question/32383/solve irrational inequalityhttp://ask.sagemath.org/question/32978/solve-irrational-inequality/Is there any way to solve the following inequality for `a` in Sage?
(It's pretty easy to do in Maple.)
abs(-1/4*a - 1/4*sqrt(a^2 - 30*a + 17) + 1/4) < 1
Using `solve` doesn't work. I tried using the QEPCAD package,
but on SageMathCloud, i get an error: "unable to start QEPCAD".
I tried using sympy-solve and sympy-solveset, and that didn't work either.
I plan to raise questions regarding sympy on stackexchange,
but if anyone has helpful guidelines on using sagemath's solve vs sympy-solve,
that'd be greatly appreciated. My general experience has been that sympy-solve
is a lot more capable than sagemath's solve.
Any help would be greatly appreciated. Thank you.
**EDIT**
Thank you for replying. I am able to use qepcad now, but the problem
I'm trying to solve takes a very long time. Here is the code:
var('a')
dnf = solve(abs(-1/4*a - 1/4*sqrt(a^2 - 30*a + 17) + 1/4) <= 1, a)
qf = apply(qepcad_formula.or_, map(qepcad_formula.and_, dnf)) # reformat the solution
qf
qepcad(qf, vars='(a)') # simplify
Any help solving this would be greatly appreciated. Also, would it be possible
to update the version of sympy on sagemathcloud? Thank you.sophiaSun, 03 Apr 2016 14:52:36 -0500http://ask.sagemath.org/question/32978/sqrt function not working properlyhttp://ask.sagemath.org/question/30325/sqrt-function-not-working-properly/ I have the following code where I want to substitute `a, b, c` into `s`. Since `s` factors as a square, I want to get the square root of it :
p, t= var('p t')
a=(-2*p*t^2-p^2*t)+(2*t*p-p^2)+t+1
b=(p*t^2+2*p^2*t)+(2*t*p-t^2)-p+1
c=(p*t^2-p^2*t)+(t^2+2*t*p+p^2)+t-p #3 sides (a,b,c) in terms of theta and phi [equation (1.1)]
s=(factor(2*c^2+2*a^2-b^2));s
S=s.sqrt();S
Unfortunately the answer I get is
sqrt((3*p*t^2 - 2*p^2 - 2*p*t + t^2 + p + 2*t + 1)^2)
The `sqrt` and the square power does not cancel off which I want it to cancel. I tried using the code `S.simplify_full()` to simplify it hoping the sqrt and square power will cancel off but no luck. Is there any other specific code I can use for that.
ShaWed, 28 Oct 2015 18:45:04 -0500http://ask.sagemath.org/question/30325/simplify sqrt(x/y^2)*yhttp://ask.sagemath.org/question/29514/simplify-sqrtxy2y/ Hello my problem is with a bigger equation but the problem is bassicly this :
sage: var('x','y', domain=real) <br/>
sage: assume(x>0)<br/>
sage: assume(y>0)<br/>
sage: e = sqrt(1/y^2)*y<br/>
sage: e.simplify_full()<br/>
1<br/>
sage: e = sqrt(x/y^2)*y<br/>
sage: e.simplify_full()<br/>
y*sqrt(x/y^2)<br/>
Anyone explain me how to get just sqrt(x) and why it doesn't do directly? ThanksmiguelythonSun, 20 Sep 2015 11:03:09 -0500http://ask.sagemath.org/question/29514/dividing vector(a,b) by sqrt(x) gives (a/x*sqrt(x),b/x*sqrt(x))http://ask.sagemath.org/question/25980/dividing-vectorab-by-sqrtx-gives-axsqrtxbxsqrtx/ I can't seem to figure out why the behavior above is happening.
I have been trying to familiarize myself with Sage as I am both an IT person at my university and currently a Calc III student and it would seem to me to be helpful for both to know how this software works since many professors use it and I can use it to check work in my classes.
When I attempt to get the unit vector in the direction of <1,1> I divide the vector by its magnitude, and instead of the expected result of <1/sqrt(2), 1/sqrt(2)> I have been getting <1/2*sqrt(2), 1/2*sqrt(2)> and this happens the same way with a vector divided by the sqrt of anything. (i.e. <1,1> / sqrt(3) == <1/3*sqrt(3), 1/3*sqrt(3)>)
Is this a bug, or am I missing something?
EDIT - To clarify, I am dividing a vector by it's magnitude, which is a scalar number. vector{a,b} divded by c should yield vector{a/c, b/c}. This works fine for integers. but when doing so with the sqrt() function it produces odd results. So if c == sqrt(d) the answer is coming back as vector{a/(d*c), b/(d*c)} and I don't understand why the denominator is being multiplied by d.
RickySat, 28 Feb 2015 17:27:40 -0600http://ask.sagemath.org/question/25980/equation sqrthttp://ask.sagemath.org/question/10710/equation-sqrt/I tried to solve with sage $$4=x+\sqrt{(x+1)(x+2)}+\sqrt{(x+2)(x+3)}+\sqrt{(x+3)(x+1)}$$
but it does work.
Could you help me what shoud I enter in sage to get exact solution ?
thank youmathWed, 06 Nov 2013 11:31:54 -0600http://ask.sagemath.org/question/10710/strange way to simplify square rootshttp://ask.sagemath.org/question/9534/strange-way-to-simplify-square-roots/Hi!
Let us consider the number
>a=1/sqrt(4-2*sqrt(3))-1/(sqrt(3)-1)
which is zero. If we simplify
>a.simplify_full().n()
we obtain
-2.73205080756888 - 8.36449319149292e-17*I,
which of course is false. I guess it is a problem handling complex roots of degree four, but still, it don't seems to me a reasonable computation. ¿Anybody knows how to fix it?
mathematicboyWed, 14 Nov 2012 06:48:49 -0600http://ask.sagemath.org/question/9534/Laurent series, Rational Functions in sqrt(q)?http://ask.sagemath.org/question/9869/laurent-series-rational-functions-in-sqrtq/I need to construct the ring of formal Laurent series in `q**(1/2)` over the rational numbers. How would I do that in sage?
I realize that there's a perfectly good workaround, but I'd be nonetheless very happy if I didn't have to use it. I could just use Laurent series in another variable, like t,
R.<t> = LaurentSeriesRing(QQ)
I could then define q to be `t**2`, and use t as a formal square root of q. But then I still can't raise q to a non-integer power - sage complains that there's a non-integer in the exponent. I'd make about 500 mistakes just typing in formulas and it would be hard to read the output.
Another workaround which I'm not keen on is to just say
var('q')
and just use symbolic expressions instead. I don't really want to do that either: I like having all the Laurent series methods available and I gather that working in an explicit ring is a lot faster? If I'm misinformed there, then please let me know.
Lastly, I'd also like to construct the rational functions in sqrt(q) - same basic problem, as far as I can see. Any help appreciated.
Benjamin YoungSat, 02 Mar 2013 06:26:10 -0600http://ask.sagemath.org/question/9869/radical expression for algebraic numberhttp://ask.sagemath.org/question/9762/radical-expression-for-algebraic-number/What is the easiest way to turn an algebraic number (i.e. an element of `QQbar`) into a symbolic expression involving radicals? I know that this is only possible if the degree of the minimal polynomial does not exceed 4, but for those cases I'd have hoped to find an easy solution, but haven't found one yet.
Example of where this would be useful:
sage: M = Matrix([[1,2],[3,4]])
sage: M.parent()
Full MatrixSpace of 2 by 2 dense matrices over Integer Ring
Simply applying `gram_schmidt` over `ZZ` will fail:
sage: M.gram_schmidt(True)[0]
TypeError: QR decomposition unable to compute square roots in Rational Field
Changing to the symbolic ring won't help either:
sage: M.change_ring(SR).gram_schmidt(True)[0]
NotImplementedError: Gram-Scmidt orthogonalization not implemented
for matrices over inexact rings, except for RDF and CDF
Changing to the algebraic numbers lets me compute the matrix, but reading the result is kind of hard.
sage: N = M.change_ring(QQbar).gram_schmidt(True)[0]
sage: N
[ 0.4472135954999580? 0.8944271909999159?]
[ 0.8944271909999159? -0.4472135954999580?]
But all the numbers in there are actually simple square roots, as the minimal polynomials will show.
sage: N.apply_map(lambda x: x.minpoly())
[x^2 - 1/5 x^2 - 4/5]
[x^2 - 4/5 x^2 - 1/5]
So I wrote my own function to convert real algebraic numbers of degree two to symbolic expressions.
sage: def AA2SR(x):
....: x = AA(x)
....: p = x.minpoly()
....: if p.degree() < 2:
....: return SR(QQ(x))
....: if p.degree() > 2:
....: raise TypeError("Cannot handle degrees > 2")
....: c, b, a = p.coeffs()
....: y = (-b+sqrt(b*b-4*a*c))/(2*a)
....: if x == AA(y):
....: return y
....: y = (-b-sqrt(b*b-4*a*c))/(2*a)
....: assert x == AA(y)
....: return y
....:
sage: M.change_ring(QQbar).gram_schmidt(True)[0].apply_map(AA2SR)
[ sqrt(1/5) 2*sqrt(1/5)]
[2*sqrt(1/5) -sqrt(1/5)]
But pasting that code into every sage session where I might need it feels rather ugly. I would have hoped that there is some easier way to achieve what I'm doing here. Is there?MvGFri, 01 Feb 2013 08:02:24 -0600http://ask.sagemath.org/question/9762/Solving equation with sqrthttp://ask.sagemath.org/question/9500/solving-equation-with-sqrt/Hello!
I'm trying to solve the following equation:
sage: var('a b c')
(a, b, c)
sage: a==b-sqrt(b**2-c**2/4)
a == b - sqrt(b^2 - 1/4*c^2)
sage: solve(_, b)
[b == a + sqrt(b^2 - 1/4*c^2)]
In the last line Sage doesn't solve the equation for b completely. Can you give me a hint what I'm doing wrong?
Thank you!
JonasMon, 05 Nov 2012 00:30:09 -0600http://ask.sagemath.org/question/9500/eliminating fractions and roots from equationshttp://ask.sagemath.org/question/9400/eliminating-fractions-and-roots-from-equations/I'm trying to solve the following equations for $a$ and $c$, where all numbers are real, $0\leq a < 1$ and $0 < c$:
[sqrt(abs((b - 1)*(a + 1)/sqrt(c^2 + abs(b - 1)^2) + a)^2 + abs((a +
1)*c/sqrt(c^2 + abs(b - 1)^2))^2) == a + 1, sqrt(abs(-(b + 1)*(a -
1)/sqrt(c^2 + abs(b + 1)^2) + a)^2 + abs(-(a - 1)*c/sqrt(c^2 + abs(b +
1)^2))^2) == -a + 1]
$$\sqrt{\left|\frac{(b-1)\cdot(a+1)}{\sqrt{c^2+|b-1|^2}+a}\right|^2+\left|\frac{(a+1)\cdot c}{\sqrt{c^2+|b-1|^2}}\right|^2}=a+1$$
$$\sqrt{\left|\frac{-(b+1)\cdot(a-1)}{\sqrt{c^2+|b+1|^2}+a}\right|^2 + \left|\frac{-(a-1)\cdot c}{\sqrt{c^2+|b+1|^2}}\right|^2}=-a+1$$
Now solve itself seems to take forever on this without coming up with a result. On the other hand, I as a human have a pretty good idea how I'd solve such beasts: square both sides to get rid of the outer square roots, then multiply both sides with the common denominator, then move the single remaining square root to one side and all the rest to the other side and square again.
I know that these steps *might* introduce additional solutions, which are valid solutions of the modified system but not of the original one. Nevertheless, I'd like to be able to get at them, probably with some indication how good they are.
I wrote a bit of code to massage my equations for me:
def massage(e):
e = e.simplify().simplify_radical().full_simplify()
e = e.power(2).simplify()
e = e.multiply_both_sides(e.lhs().denominator()).simplify()
e = e.subtract_from_both_sides(e.rhs()).simplify()
e = e.subtract_from_both_sides([
term for term in e.lhs().operands() if 'sqrt' in str(term)][0])
e = e.simplify().power(2).simplify()
e = e.subtract_from_both_sides(e.rhs()).expand()
e = e.simplify().simplify_radical().full_simplify()
return(e)
But this sequence is highly specific to the equations at hand. And the part about how to identify which operand contains the nested square root is plain ugly. **So what better methods are there to perform this kind of equation simplification?** Preferrably in a much more automated way.
*Just for your information:* If I modify my equations using the code above, I am able to get 9 solutions. I'm not sure whether I actually trust them, as I would have expected something else, but there might be something wrong with either my expectation or the way I obtained the euqations.MvGMon, 08 Oct 2012 05:43:35 -0500http://ask.sagemath.org/question/9400/Need positive sqrts onlyhttp://ask.sagemath.org/question/9059/need-positive-sqrts-only/Hi,
I have solved some equations using solve() which does some manipution then takes a few positive and negative sqrts and then some more manipulation. There are several sets of solutions, but it's not obvious which ones correspond to which sign of sqrts. Is there an easy way I can make solve() only take positive square roots?
Thanks! And let me know if more info is needed.Mr CoolMon, 11 Jun 2012 03:11:43 -0500http://ask.sagemath.org/question/9059/Simplify multiplication of SQRT()shttp://ask.sagemath.org/question/8931/simplify-multiplication-of-sqrts/ sage: a=var('a')
sage: b=var('b')
sage: sqrt(1/(a*b))*sqrt(a/b)
sqrt(a/b)*sqrt(1/(a*b))
sage: (1/(a*b))*(a/b)
b^(-2)
to simplify, the expressions under the square root have to be brought together. This is not happening. Is there any workaround?
kirill_igumThu, 26 Apr 2012 20:15:02 -0500http://ask.sagemath.org/question/8931/square roothttp://ask.sagemath.org/question/8738/square-root/I am continually running into the problem where square roots defeat any attempt to simplify an expression. For example:
sqrt(-x_3 + sqrt(x_1^2 + x_2^2 + x_3^2))*sqrt(x_3 + sqrt(x_1^2 + x_2^2 +
x_3^2))/sqrt(x_2^2/x_1^2 + 1)
should simplify to x_1.
I understand the reason sage hesitates to simplify a square root. But being unable to force the issue is starting to render sage almost completely useless.
Does anybody know how to get sage to simplify these types of expressions? simplify_radical does not work. The closest I can come is to square the expression first, then simplify and take the square root. That still does not get rid of the final square root. I wonder if making the expression complex might work, and if so, how might I do that?
BobBSat, 25 Feb 2012 17:57:32 -0600http://ask.sagemath.org/question/8738/latex(2*2^(1/3))http://ask.sagemath.org/question/8190/latex2213/ sage: latex(2*2^(1/2))
2 \, \sqrt{2}
that is ok
but what ist that?
sage: latex(2*2^(1/3))
2 \, 2^{\left(\frac{1}{3}\right)}
How can I get the right result
2\cdot 2^{\left(\frac{1}{3}\right)}
or
2\, \sqrt[3]{2}
????
Thanks for help
amaleaSat, 25 Jun 2011 09:01:32 -0500http://ask.sagemath.org/question/8190/why won't simplify multiply out square roots?http://ask.sagemath.org/question/7787/why-wont-simplify-multiply-out-square-roots/I was trying to remove half angles in an expression. And it seems simplify() does not like to multiply out square root.
sage:theta=var('theta')
sage:assume(theta,'real')
sage:assume(theta>0)
sage:assume(theta<pi)
sage:m=((sin((1/2)*theta)*cos((1/2)*theta)).trig_expand(half_angles=True))
sage:view(m.simplify_full())
The output I get is $\frac{1}{2}\sqrt{-\cos\left(\theta\right) + 1} \sqrt{\cos\left(\theta\right) + 1}$
Is there a way I can make sage multiply out the the expression and give me $(1/2)sin \theta$
ShashankThu, 02 Dec 2010 10:06:54 -0600http://ask.sagemath.org/question/7787/