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.Wed, 28 Apr 2021 13:31:54 +0200Issue with inversion of complex symbolic array initialized with numpyhttps://ask.sagemath.org/question/56850/issue-with-inversion-of-complex-symbolic-array-initialized-with-numpy/Hello!
I am trying to invert a symbolic matrix that is initialized with a combination of numpy arrays and I get an error. Below i present a simple code that gives the error.
import numpy as np
a = np.zeros((5,5) , dtype = 'complex')
np.fill_diagonal(a,1)
b = var('x')*a
c = matrix(b)
c.inverse()
Gives the error:
> ECL says: THROW: The catch
> MACSYMA-QUIT is undefined.
What I have noticed up until now is that the issue stems from the data type. When I try casting the numpy array to float before turning it into a matrix, it works. However, my actual code makes use of complex coefficients. I believe it might have to do with how the imaginary part is represented in SageMath in comparison to numpy. ( `j` vs `I` )
When I manually create the symbolic array with `I` for the imaginary part, the `.inverse()` has no issue.yorgos_sotWed, 28 Apr 2021 13:31:54 +0200https://ask.sagemath.org/question/56850/Working with complex symbolic expressionshttps://ask.sagemath.org/question/8716/working-with-complex-symbolic-expressions/I am a beginner at Sage so my questions may not be well informed, so bear with me.
The context: I am trying to use sage to explore the exponential function assuming all I know about it is that it is its own derivative and has the value 1 at z = 0. It is then easy to develop the Taylor series to any degree using formula like:
expp2( z ) = 1 + ( 1/ factorial( 1 ) )* z + ( 1/ factorial( 2 ) ) * ( z ^ 2 )
You can take 2 of these for z = a and z = b and multiply them together in Sage. Getting something like:
1/4*(b^2 + 2*b + 2)*(a^2 + 2*a + 2)
Now I have done the algebra by hand and know this reduces to the Taylor expansion for z = a + b.
What I do not get is how to show this part in Sage in a nice clean way ( I have some ways I do not like so much ).
Here I have 2 questions one specific, and one general ( I am interested in the answer to either one or both):
1) If this exponential question interests anyone, could you offer some tips? I have tried various ( but not all ) applications of expand and simplify. I am still plugging away.
2) Is there a guide that would help me learn how to carry out algebraic operations over complex expressions. I have looked at several basic tutorials, but they do not have much detail. The most useful single resource I have found is
http://www.sagemath.org/doc/reference/sage/symbolic/expression.html
and the pages linking from it.
russ_henselMon, 13 Feb 2012 15:07:47 +0100https://ask.sagemath.org/question/8716/Question about error using plothttps://ask.sagemath.org/question/10435/question-about-error-using-plot/Hello all,
I'd like to view the plot of the real portion of `(1+x*I)^(1+5*I)`. I've tried the following in sage:
`plot(((.5+x*I)^(1+5*I)).real(),(x,0,5))` but I keep getting cannot convert symbolic expression to numeric value.
Honestly, I'd actually like to integrate the expression with respect to x on some arbitrary real interval. That kept giving errors as well when I tried to use integral_numerical.
Can anyone help me? I am running the newest edition of sage, as I updated two days ago.
Thanks,
RickTherickamanWed, 14 Aug 2013 21:02:51 +0200https://ask.sagemath.org/question/10435/how to use variables (`var`)https://ask.sagemath.org/question/10209/how-to-use-variables-var/I thought they are complex by default. But even when I try to force the domain to be complex, I always get `x.conjugate().simplify() == x`. Why? See also below:
sage: t1,t2,t4 = var("t1 t2 t4")
sage: t2.conjugate().simplify()
t2
sage: t1,t2,t4 = var("t1 t2 t4", domain="complex")
sage: t2
t2
sage: t2.is_real()
False
sage: t2.conjugate().simplify()
t2
sage: (t2.real()*2 - t2).simplify()
t2
sage: t2.real().simplify()
t2
sage: t2.imag().simplify()
0
Albert ZeyerMon, 10 Jun 2013 09:27:53 +0200https://ask.sagemath.org/question/10209/Problem with conjugate_transpose of a symbolic matrixhttps://ask.sagemath.org/question/10115/problem-with-conjugate_transpose-of-a-symbolic-matrix/ dAbar=diagAbar.subs(t=0);dAbar
[ 3.18953143618644*I*sech(x3) - 3.00000000000000 - 2.68953143618644*I
0 0]
[ 0
-3.18953143618644*I*sech(x3) - 3.00000000000000 + 2.68953143618644*I
0]
[ 0
0 -4]
TdiagAbar=dAbar.conjugate_transpose() + dAbar
Traceback (click to the left of this block for traceback)
...
AttributeError:
'sage.rings.complex_interval.ComplexIntervalFieldElement' object has no
attribute 'sech'
I hope their is an easy answer. Thanks, nonlinearDionysusSat, 11 May 2013 23:46:41 +0200https://ask.sagemath.org/question/10115/complex conjugate of a variablehttps://ask.sagemath.org/question/8887/complex-conjugate-of-a-variable/I attempted to construct the complex conjugate of a variable thus -
x = var('x')
f = x*conjugate(x)
f({x:2+2i})
this throws a SyntaxError, although the `f({x:2})` case works perfectly.
d3banjanSun, 15 Apr 2012 12:00:58 +0200https://ask.sagemath.org/question/8887/compile a symbolic function and use it in cythonhttps://ask.sagemath.org/question/8632/compile-a-symbolic-function-and-use-it-in-cython/I have written [code to create plots of Newton fractals](https://lestum.mat.uam.es/home/pub/32/). Cython was key, pure python was way too slow.
But I'd like to create an interact: write the polynomial and watch the fractal. The problem is the user should enter the polynomial in a text box as a symbolic expression, then I should send that to cython and the cython code should do the rest, calling that function when necessary.
I've managed to do so: I create a fast_callable on the expression, and pass the output of fast_callable to cython, but it is **very slow**. Unfortunately, I cannot make the different data types for complex numbers match, and there might be something else.
Maybe you can think of a different approach...pangTue, 17 Jan 2012 07:32:36 +0100https://ask.sagemath.org/question/8632/