Feeds:
Posts

Posts Tagged ‘Simplify’

From time to time when one works with operators, such as in Quantum mechanics, something like an exponential of the operator appears (this is also the case in many areas of Mathematics like group theory of differential geometry). This exponentiation of a matrix should be understood as the series expansion of the exponential.

SAGE knows how to do this exponentiation,

```sage: reset()
sage: var('a,b,c', domain=RR)
sage: A = a*I*matrix([[0,1],[1,0]])
sage: B = b*I*matrix([[0,-I],[I,0]])
sage: C = c*I*matrix([[1,0],[0,-1]])
sage: A.exp()
[1/2*(e^(2*I*a) + 1)*e^(-I*a) 1/2*(e^(2*I*a) - 1)*e^(-I*a)]
[1/2*(e^(2*I*a) - 1)*e^(-I*a) 1/2*(e^(2*I*a) + 1)*e^(-I*a)]
sage: B.exp()
[   1/2*(e^(2*I*b) + 1)*e^(-I*b) -1/2*(I*e^(2*I*b) - I)*e^(-I*b)]
[ 1/2*(I*e^(2*I*b) - I)*e^(-I*b)    1/2*(e^(2*I*b) + 1)*e^(-I*b)]
sage: C.exp()
[ e^(I*c)        0]
[       0 e^(-I*c)] ```

The only problem here is that, even when the relations are simple in this example, I’ve not found a `trivial’ way of simplifying the matrix elements of the exponentiation, not even with the procedure post in here. I didn’t try with the rewrite package

Enjoy.

Dox

Since yesterday I’m trying to use the free software SAGE(math) for the computation of my current research, so the problems don’t wait… they appear at each corner.

I’d like to thank to the people of the IRC channel #sage-devel.

Issue 1.

Today I wanted to simplify a expression, say $e^{a \; ln(x)}$ with $a$ a number.

First issue, declare the variables… and try the simplest one

```sage: a, x = var('a,x')
sage: simplify(e^(a*log(x)))
e^(a*log(x))```

i.e.,  I got nothing.

Solution.

Somehow, the best way for doing simplifications is the Python way. How is it?

Give a name to your expression, and then simplify (with the exponential option)

```sage: ex = e^(a*log(x))
sage: ex.simplify_exp()
x^a```

so you get the right answer, $x^a$.

Besides the exponential simplification option, there are trigonometric (simplify_trig), logarithmic (simplify_log), rational… and many others. If you’re using the Interactive shell, the auto-completion will help you.

Issue 2.

As you may know, when using symbolic calculation software, the declaration of assumptions is pretty important. How do we do it in Sage(math)?

Solution.

The command is assume, so if your variable is positive,

`sage: assume(a > 0)`

or if your variable is an integer,

`sage: assume(a, 'integer')`

in the latter also rational, real, odd and even works.

Ordered assumptions works, say

`sage: assume(x<y, y<z)`

For seen all the assumptions use the assumptions command,

`sage: assumptions()`

and for eliminate them, use the command forget

`sage: forget()`

That’s the main of it…