## 769 Reputation

16 years, 337 days

## custom latex representation for function...

Maple

The documentation shows that one can set up custom latex form for different function/variables:
https://www.maplesoft.com/support/help/maple/view.aspx?path=latex/functions

This is very nice, but how do I see what's currently set?

I was hoping something like:
showstat(`latex/AntiCommutator`);
or
eval(`latex/hypergeom`);
would work, but these don't.

I would like to simply copy/paste what maple already does and only make slight adjustments - don't want to have to write these from scratch.

thanks!

## Substituting for expressions that contai...

Maple

What's the simplest way to partially substitute for expressions that contain operators from the Physics package?
(hopefully my worksheet below shows what I mean)
Thanks

 > restart:
 > with(Physics):
 > Physics:-Version();
 (1)
 > Setup(quantumoperators = {sigma__x, sigma__y, sigma__z, rho, H, comm}, mathematicalnotation = true);
 (2)

we could just use Physics:-Psigma, etc... but here let's define these manually:

 > Setup(algebrarules={ %Commutator(sigma__x, sigma__y) = 2*I*sigma__z, %Commutator(sigma__y, sigma__z) = 2*I*sigma__x, %Commutator(sigma__z, sigma__x) = 2*I*sigma__y } );
 (3)

some expression (normally long and complicated that contains many operators):

 > expr:=(sigma__y*sigma__x*rho - sigma__y*rho*sigma__x);
 (4)

say want to make this type of substitution:

 > subs_vars:=sigma__y*sigma__x=H;
 (5)

this doesn't work

 > algsubs(subs_vars, expr);
 (6)

this also doesn't work:

 > subs(subs_vars, expr);
 (7)

this works (here we explicitly specify the whole thing, that includes rho)

 > subs(sigma__y*sigma__x*rho=H*rho, expr);
 (8)

but I would like for the substitution to also work for *parts* of the expression, as in the normal case, when not using operators.

 >
 >
 >

## division by zero in dsolve...

Maple

I'm looking at a small system of differential equations. It can be readily solved numerically, but an attempt for an analytical solution spits out a "division by zero"... Is it obvious to anyone why that would be? or what the issue is?

(mathematica does spit out a solution in terms of inverse of elliptic  functions)

thanks!

 > restart:
 >
 > Physics:-Version();
 (1)
 >

system:

 > sys:=[diff(Xc(t),t) = - Sy(t), diff(Sy(t),t) = -Xc(t) * (1  - Xc(t)^2), Xc(0)=0, Sy(0)=1];
 (2)

numeric sol:

 > sol:=dsolve(sys, [Xc(t), Sy(t)], numeric);
 (3)

looks good:

 > plots:-odeplot(sol, [[t, Sy(t)], [t, Xc(t)]], t=0..10);

try analytic solution...

 > analytic_sol:=dsolve(sys, [Xc(t), Sy(t)]);
 >
 >
 >
 >

## expression manipulation (with Physics op...

Maple

I'm trying to do some manipulation of expressions that contain products of scalars and non-commuting operators (as defined by the physics package). The worksheet below shows this on a particular example. I can imagine a long/tedious way to do this, but perhaps the two key steps outlined below might be easily handled by some pattern-matching maple trickery, that is obvious to the pros here?

In short, I need to convert expressions of the general form:

 expr:=alpha*Sx*Sz^2 + beta*Sy*Sz + gamma*Sz*Sy*Sx  + Sx + beta^2;

to something like:

expr3:=alpha*f([Sx,Sz, Sz]) + beta*f([Sy,Sz]) + gamma*f([Sz, Sy, Sx]) + f([Sx]) + beta^2;

... with the caveat that the 'Sk' are operators (and their products could be of an arbitrary length).

The context here (for those who care) is basically to use the nice handling of non-commutative algebra of the Physics package to write down some Heisenberg equations of motion for a given system, and then approximate those using a cummulant expansion (this is in practice really tedious to do by hand in even simple systems, but arguably the most painful part is trivially done by the physics' package nice handling and sorting of the non commuting oprators). That, in essence requires one to transform larger products of non-commuting operators into smaller products (so say approximating an expectation value of 3-operator product as a sum of 2-operator peoducts and single operators).

If anyone has ideas how best to approach this in the maple-ish way, please let me know.

thanks!

 > restart:

Init related stuff

 > with(Physics);
 (1)
 > algebra_rules:={NULL ,%Commutator(Sx,Sy)=I*Sz ,%Commutator(Sy,Sz)=I*Sx ,%Commutator(Sz,Sx)=I*Sy };
 (2)
 > Setup(mathematicalnotation=true, hermitianoperators = {Sx, Sy, Sz}, algebrarules=algebra_rules);
 (3)
 >

Say i have an expression like this below. In principle, each term could be a product:

(scalar) * (some prodcut of opertors)

with some arbitrary number of operators.

 > expr:=alpha*Sx*Sz^2 + beta*Sy*Sz + gamma*Sz*Sy*Sx  + Sx + beta^2;
 (4)

would like apply ave(expr) and end up with:

 > expr2:=alpha*ave(Sx*Sz^2) + beta*ave(Sy*Sz) + gamma*ave(Sz*Sy*Sx)+ ave(Sx)   + beta^2;
 (5)

so basically need a rule that forces:
ave(scalar*operators)->scalar*ave(operators)
with
ave(scalar)=>scalar

Next, given expr2, would like to be able to apply some transformation to all the ave(XXX) functions.
for simplicity let's assume that I would like a following transformation:

ave(A*B*C ....)->f([A, B, C, ...])

with each of A, B, C here being an operator.

However the crucial point is that if there are powers of operators, each one should get its own entry in the list. So for example:

ave(A*B^2)->f([A, B, B]).
So applying this transformation to expr2, should give:

 > expr3:=alpha*f([Sx,Sz, Sz]) + beta*f([Sy,Sz]) + gamma*f([Sz, Sy, Sx]) + f([Sx]) + beta^2;
 (6)

## integrating over a list, vector, matrix,...

Maple

Is there a reason why maple can't directly integrate over iterable objects (lists, vectors, matrices, etc.)?
From a first glance I would think doing

int(<sin(x), cos(x)>, x=0..2)

should be equivalent to:

map(int, <sin(x), cos(x)>, x=0..2)

Is there a good reason why this would be a bad idea?  (for whatever it's worth, that's what mathematica does by default).

 1 2 3 4 5 6 7 Last Page 1 of 12
﻿