I found a few unexpected behaviors. There's good support for many of the inference rules. When I tried to apply Sage to more advanced uses, either I don't understand the math well enough, or support in Sage doesn't exist.

### Expectation value doesn't render Latex

Expectation values are used in the variance relation identity. I was impressed by the ability of Sage to use Expectation value from SymPy.x=var('x')

from sympy.stats import E # expectation value

expr1=E((x-E(x))^2)==E(x^2)-(E(x))^2

expr2=E(x^2-2*x*E(x)+E(x)^2)==E(x^2)-(E(x))^2

print(bool(expr1.lhs() == expr2.lhs()))

expr3=E(x^2)-2*E(x)*E(x)+E(x)^2==E(x^2)-(E(x))^2

print(bool(expr3.lhs() == expr2.lhs()))

*True*

*True*

However, I wasn't able to display the content in LaTeX:

print(latex(expr3))

*0 == 0*

This is unfortunate but not a blocker

### Real Part of Expression isn't what I was expecting

Sage doesn't produce the output I expected from .real_part()

forget()

x=var('x')

assume(x,'real')

this=cos(x) + I*sin(x)

this.real_part()

*cos(real_part(x))*cosh(imag_part(x)) - cos(real_part(x))*sinh(imag_part(x))*

What I was looking for was that this.real_part() would return cos(x); similarly this.imag_part() should return sin(x).

### Symbolic Levi-Civita not supported in Sage?

*1*

However, I can't use symbols as arguments

forget()

h,j,k=var('h,j,k')

assume(h,'integer')

assume(j,'integer')

assume(k,'integer')

levicivita = SymmetricGroup(3)

levicivita([j,k,m]).sign()

*Invalid permutation vector: [h,j, k]*

### Del (aka Nabla) lacks symbolic support in Sage?

Symbolic cross-products work as desiredh,j,k=var('h,j,k')

m,n,p=var('m,n,p')

E = vector(SR, [h,j,k])

F = vector(SR, [m,n,p])

print(E.cross_product(F))

*(-k*n + j*p, k*m - h*p, -j*m + h*n)*

*Other vector calculus operations appear to lack support for symbolic manipulation*

https://en.wikipedia.org/wiki/Del#Gradient

https://en.wikipedia.org/wiki/Del#Divergence

https://en.wikipedia.org/wiki/Del#Curl

*I don't quite understand what's being done with the following:*

forget()

V = VectorSpace(SR,3)

h,j,k=var('h,j,k')

m,n,p=var('m,n,p')

E = vector(SR, [h,j,k])

print(E.curl([1,2,3]))

print(E.div([1,2,3]))

*(0, -1, 1)*

*1*

## No comments:

## Post a Comment