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.Fri, 17 Mar 2023 19:54:15 +0100How to get multiplication of square roots to simplify?https://ask.sagemath.org/question/66973/how-to-get-multiplication-of-square-roots-to-simplify/ All I want is for Sage to take the sqrt(3)*sqrt(2) and show me it is sqrt(6). I have looked through the forums and found a few solutions but they are all from 5+ years ago and don't seem to do anything any more. Here is an example:
from sage.manifolds.utilities import simplify_chain_real
a = var("a")
assume(a>0)
a = sqrt(2)*sqrt(3)+6
show(a)
show(simplify_chain_real(a))
show(a.simplify_real())
show(a.canonicalize_radical())
My output is the following for all of these:
sqrt(3)*sqrt(2)+6
What do I need to do to get the output to display sqrt(6)+6? I am sure there is some really advanced mathematical reason for this not to work, but I just dealing with fairly standard stuff.
I am using the following version of Sage:
SageMath version 9.8, Release Date: 2023-02-11ZakEspleyFri, 17 Mar 2023 19:54:15 +0100https://ask.sagemath.org/question/66973/Sage cannot simplify expressions with radical functions?https://ask.sagemath.org/question/60870/sage-cannot-simplify-expressions-with-radical-functions/Sage cannot seem to simplify symbolic expressions containing radical functions, even if I specify the domain and use assumptions:
var('x', domain='positive')
assume(x>1)
bool(sqrt(x-1)>0) # True
bool(sqrt((x-1)^3)-(x-1)*sqrt(x-1)==0) #True
# not true even with x>1 assumption?
bool(sqrt(x^3-x^2)-x*sqrt(x-1)==0) #False
I know there is the `simplify_chain_real()` function that can simplify `sqrt(x^3-x^2)` to `sqrt(x-1)*x`, but shouldn't the `bool()` function force a simplification? And why the behavior is different (and correct) for `bool(sqrt((x-1)^3)-(x-1)*sqrt(x-1)==0)`?
Thanks
sgiaSun, 30 Jan 2022 02:42:05 +0100https://ask.sagemath.org/question/60870/How to keep 1/sqrt(2) as 1/sqrt(2) ? [the canonical form is not canonical]https://ask.sagemath.org/question/36944/how-to-keep-1sqrt2-as-1sqrt2-the-canonical-form-is-not-canonical/ Hi all
Using sagetex to make computaion, I would like it to keep radical in the denominator (though I remember my 8 th grade course viewing the canonical form today in a pdf file seems odd )
so something like
1/sqrt(2) would not be written as
sqrt(2)/2 as it is normally.
I saw this related link : https://ask.sagemath.org/question/35236/simplify-an-expression-of-square-roots/
but for me the command
1/sqrt(2).maxima_methods().rootscontract().simplify()
gives also a "canonical" result.
Cheers,
Laurent BTue, 14 Mar 2017 18:20:00 +0100https://ask.sagemath.org/question/36944/solving radical equations with parametershttps://ask.sagemath.org/question/10277/solving-radical-equations-with-parameters/I would like to find the solutions $y$ to this type of equations: $$\left(1+x -\sqrt{(1+x)^2-4y}\right)^2=z$$
with conditions on $x,y,z$ (like $0\lt y\lt x\leq \frac18$ and $0\lt z\lt x^2$).
Using `solve` with the option `to_poly_solve`:
sage: solve((1+x - sqrt((1+x)^2-4*y))^2 == z, y, to_poly_solve=True)
[y == 1/2*x^2 - 1/2*(x + 1)*sqrt(x^2 + 2*x - 4*y + 1) + x - 1/4*z + 1/2]
does not seem to work because $y$ appears on the right side of the solution. I expect to find a solution like
$$y=\frac14\left((1+x)^2-\left(1+x-\sqrt{z}\right)^2\right).$$
I also tried the same after specifying the conditions with `assume()`, without success.nejimbanTue, 25 Jun 2013 10:00:31 +0200https://ask.sagemath.org/question/10277/Radical Sign in answer?https://ask.sagemath.org/question/9182/radical-sign-in-answer/ How do I get an output like the following to look more like we would write it by hand?
Sage: t = var('t')
Sage: S = solve(-16*t^2 + 48*t + 5, t)
Sage: S
[t == -1/4*sqrt(41) + 3/2, t == 1/4*sqrt(41) + 3/2]
hsmit506Tue, 19 Mar 2013 12:02:41 +0100https://ask.sagemath.org/question/9182/radical expression for algebraic numberhttps://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 15:02:24 +0100https://ask.sagemath.org/question/9762/Cannot solve equation with two radical termshttps://ask.sagemath.org/question/8544/cannot-solve-equation-with-two-radical-terms/I am learning Sage on the Notebook by reworking examples in my old algebra book (starting with page one).
Could someone please explain the following behavior and how to solve the original equation?
This equation isn't getting solved:
solve(sqrt(2*x - 5) - sqrt(x - 3) == 1, x)
The output is:
[sqrt(x - 3) == sqrt(2*x - 5) - 1]
But the solution is x == 7 or x == 3
I tried the terms and they are solved:
solve(sqrt(2*x-5) == 1, x)
[x == 3]
solve(sqrt(x-3) == 1 , x)
[x == 4]
Thank youhunannerSun, 11 Dec 2011 09:10:35 +0100https://ask.sagemath.org/question/8544/Solving radical inequalitieshttps://ask.sagemath.org/question/8157/solving-radical-inequalities/Can this be solved in Sage?
> x-4>sqrt(x-2)
The standard solve method does not work, and neither does solve_ineq.Eviatar BachFri, 10 Jun 2011 04:15:16 +0200https://ask.sagemath.org/question/8157/Radical in the denominator?https://ask.sagemath.org/question/7494/radical-in-the-denominator/Is there any way I can get a general complex number to display with the radical in the denominator, rather than having it rationalized? For example (1+i)/sqrt(2).Mike WittSun, 10 Oct 2010 13:00:07 +0200https://ask.sagemath.org/question/7494/