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.Mon, 02 Sep 2019 10:44:08 -0500how do I enter 2sin|1−3√2|cos|1+ 2√3|http://ask.sagemath.org/question/47722/how-do-i-enter-2sin1-32cos1-23/when I enter it in SageMath as `2 * sin * abs(1-3 * sqrt(2))*cos*abs(1+2 * sqrt(3))` it does not run the code? your help would be very appreciated :)ariaaaaaaaaMon, 02 Sep 2019 10:44:08 -0500http://ask.sagemath.org/question/47722/Can this fraction be simplified ?http://ask.sagemath.org/question/42157/can-this-fraction-be-simplified/During some calculations, I came across a fraction of this kind :
$$\frac{\sqrt{2}+2}{\sqrt{2}+1}$$
Which should be equal to $\sqrt{2}$.
I am surprised to see that Sage can't simplify this fraction with simplify_full :
( (sqrt(2)+2)/(sqrt(2)+1) ).simplify_full()
returns the same. Just to be sure:
bool( (sqrt(2)+2)/(sqrt(2)+1) == sqrt(2) )
returns true
Am I missing a simplification option ? How can I get Sage to simplify this fraction ?
To clarify, the original expression I encountered was this one :
$$\frac{3(x^4+4\sqrt{3}(x^2+6)\sqrt{x^2+3}+24x^2+72)}{\sqrt{3}(x^5+24x^3+72x)+12(x^3+6x)\sqrt{x^2+3}}$$
which is equal to $\frac{\sqrt{3}}{x}$. Sage can show the equality, but cannot simplify the expression (but maybe it's normal, this is not as trivial as the first example...). Substituting $x=1$ in this formula give something very similar to the expression above.
It can be obtained with:
f = 3*(x^4+4*sqrt(3)*(x^2+6)*sqrt(x^2+3)+24*x^2+72)/(sqrt(3)*(x^5+24*x^3+72*x)+12*(x^3+6*x)*sqrt(x^2+3))Florentin JaffredoWed, 25 Apr 2018 05:08:26 -0500http://ask.sagemath.org/question/42157/ATAN2 AssertionError while plotting complex squareroot functionhttp://ask.sagemath.org/question/34735/atan2-assertionerror-while-plotting-complex-squareroot-function/<br>I want to plot the real part of a a squareroot function with complex argument by using the SAGE plot method.
<br>This plot method combines function evaluation and plotting within one single python statement.
<br>It fails with the error message :ATAN2 Assertion error.
<br>However, doing the job in two separate consecutive steps , i.e., evaluating the needed function values first and plotting them afterwards with SAGE's line method is successful without error.
<br>The following example code demonstrates this behaviour.
<br>Meaning of variables:
<br>f_exampl: test function calling the real part of a square-root function;
<br>exx=1 uses the method "plot" ;
<br>exx=2 uses the method "line" to plot a pre-calculated list of values.
<br>delta =0: the argument of the square-root is real
<br>delta /= 0 : I*delta is the imaginary part of the squareroot argument.
<br>The result:
<br>testcase exx=2 is successful for delta=0 and delta != 0.
<br>testcase exx=1 is successful for delta=0.
<br>testcase exx=1 aborts with ATAN2 Assertion error if the squareroot must evaluate complex numbers.
<br>Apparently there is a conflict between the evaluation of complex sqareroots during SAGE's plot method.
<br>Evaluating the complex sqareroots without plotting them can be done without problems.
<br>However, In my case it is more convenient to use SAGE's plot instead of SAGE's line method.
<br>Is it possible to avoid the assertion error in the preferred plot method?
<br>I used SAGE Version 7.1 within a Linux opensuse 42.1 OS.
x,delta,exx=var('x', 'delta', 'exx')
delta=0.0
exx=1
def f_exampl(xx):
return sqrt(xx-I*delta)
xmin=1.0
plotpts=2
plotpts_1=plotpts+1
xmax=3.0
ym=2.0
if exx==2:
# exampl_2: no assertion error, if delta != 0:
list_exampl=[[xmin+(xmax-xmin)*i/plotpts,real_part(f_exampl(xmin+(xmax-xmin)*i/plotpts))]for i in range(plotpts_1)]
exampl_2=line(list_exampl,thickness= 2,color='red',marker='+')
show(exampl_2)
else:
# exampl_1: assertion error, if delta != 0:
exampl_1=plot (real_part(f_exampl(x)),(x,xmin,xmax),ymin=1.0,ymax=+ym,plot_points=plotpts,color='blue',marker='+')
show(exampl_1)bekalphMon, 05 Sep 2016 14:59:22 -0500http://ask.sagemath.org/question/34735/Simplify an expression of square rootshttp://ask.sagemath.org/question/35236/simplify-an-expression-of-square-roots/ Sage's .simplify() command is unable to simplify the expression $\sqrt{2} \cdot \sqrt{3} \cdot \sqrt{6}$: the output of both
(sqrt(6) * sqrt(3) * sqrt(2)).simplify()
and
(sqrt(6) * sqrt(3) * sqrt(2)).simplify_full()
is just sqrt(6)*sqrt(3)*sqrt(2) again.
Notably, (sqrt(6)*sqrt(3)*sqrt(2)).is_integer() also returns false.
Is there a more powerful version of the simplify command that won't get overwhelmed by an expression like this?
user101214Sun, 23 Oct 2016 13:31:31 -0500http://ask.sagemath.org/question/35236/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/is_square in p-adicshttp://ask.sagemath.org/question/9648/is_square-in-p-adics/I need to find whether a given (often somewhat complicated) dyadic field contains $i$. I tried to use `is_square` method, but I'm getting error reports.
Consider the following (very simplified) example:
> `Q2 = Qp(2); Q2(-1).is_square()`
As far as good - the answer is `False` as expected. So try a simple extension:
> `F.<a> = Qq(2^3); F(-1).is_square()`
And... I'm getting an error message:
> AttributeError: 'sage.rings.padics.padic_ZZ_pX_CR_element.pAdicZZpXCRElement' object has no attribute 'residue'
Is this a Sage bug or I'm doing something wrong?
pkoprowskiSun, 23 Dec 2012 03:24:53 -0600http://ask.sagemath.org/question/9648/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/