itsme

584 Reputation

13 Badges

12 years, 348 days

MaplePrimes Activity


These are questions asked by itsme

does maple provide a way to programatically get the name of the "current" worksheet file?

I'm looking for something analogous to
interface(worksheetdir);

which gives the directory the worksheet file is in.

thanks.

 

what is the best way to "extract" a list of terms from a sum of terms.

So something like this::

split_expr(a+b+3) should return [a,b,3]

split_expr(diff(x(t),t)) should return  [ diff(x(t),t)]

split_expr(Int(abc(t), t=2..3) + 3) should return [Int(abc(t), t=2..3) , 3]

I very often have expressions with sums of many terms, and need to run some command on each element (say simplify, or collect, etc)... i've been using convert(expr, list) to split things up, apply a command and recombine, but the convert command breaks on some cases. Maybe this is something that maple can do natively?

thanks!

what is the most elegant way to get coefficients of a series that contains negative powers.

for example in this:

tt := a*N__s^3 + N__s + CSxSx__0 + CSxSx__1/N__s + CSxSx__2/N__s^2 + CSxSx__3/N__s^3;

i would like

fancy_coeff(tt, 1/N__s, 3)

to give me `CSxSx__3`

while

fancy_coeff(tt, 1/N__s, -3)

give me `a`

(the standard coeff call doesn't work with this, as would be known to people here)

thanks!

what's the easiest way to have maple simplify the expression below from 'expr1' to the form of 'desired_form'? mathematica automatically simplifies to that (subjectively of course!) much nicer looking form.

 


 

restart:

 

expr1:=-lambda-(1/2)*kappa__c-gamma__p-(1/2)*sqrt(-16*N*g^2+4*lambda^2-8*lambda*gamma__p+4*lambda*kappa__c+4*gamma__p^2-4*gamma__p*kappa__c+kappa__c^2);

-lambda-(1/2)*kappa__c-gamma__p-(1/2)*(-16*N*g^2+4*lambda^2-8*lambda*gamma__p+4*lambda*kappa__c+4*gamma__p^2-4*gamma__p*kappa__c+kappa__c^2)^(1/2)

(1)

desired_form:=1/2*(-2*gamma__p - kappa__c - 2 *lambda - sqrt(-16*N*g^2 + (-2 * gamma__p + kappa__c + 2 * lambda)^2));

-gamma__p-(1/2)*kappa__c-lambda-(1/2)*(-16*N*g^2+(-2*gamma__p+kappa__c+2*lambda)^2)^(1/2)

(2)

expr1- desired_form:
simplify(%);

0

(3)

 


 

Download factor_under_sqrt.mw

how can i get an 'implicit=false' form (no RootOf) of my eigenvalues from the Eigenvectors() command? Should one expect the behavior be the same in Eigenvectors() and Eigenvalues()?

thanks

 

restart:

 

 

M:=Matrix(3, 3, [[-2*lambda-kappa__c, -2*sqrt(2)*g, 0], [(1/2)*g*N*sqrt(2), -lambda-(1/2)*kappa__c-gamma__phi, -sqrt(2)*g], [0, g*N*sqrt(2), -2*gamma__phi]])

Matrix(3, 3, {(1, 1) = -2*lambda-`#msub(mi("κ",fontstyle = "normal"),mi("c"))`, (1, 2) = -2*sqrt(2)*g, (1, 3) = 0, (2, 1) = (1/2)*g*N*sqrt(2), (2, 2) = -lambda-(1/2)*`#msub(mi("κ",fontstyle = "normal"),mi("c"))`-`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`, (2, 3) = -sqrt(2)*g, (3, 1) = 0, (3, 2) = g*N*sqrt(2), (3, 3) = -2*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`})

(1)

LinearAlgebra:-Eigenvalues(M); #this is what i want but from Eigenvectors()

Vector(3, {(1) = -lambda-(1/2)*`#msub(mi("κ",fontstyle = "normal"),mi("c"))`-`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`, (2) = -lambda-(1/2)*`#msub(mi("κ",fontstyle = "normal"),mi("c"))`-`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`+(1/2)*sqrt(-16*N*g^2+4*lambda^2+4*lambda*`#msub(mi("κ",fontstyle = "normal"),mi("c"))`-8*lambda*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`+`#msub(mi("κ",fontstyle = "normal"),mi("c"))`^2-4*`#msub(mi("κ",fontstyle = "normal"),mi("c"))`*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`+4*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`^2), (3) = -lambda-(1/2)*`#msub(mi("κ",fontstyle = "normal"),mi("c"))`-`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`-(1/2)*sqrt(-16*N*g^2+4*lambda^2+4*lambda*`#msub(mi("κ",fontstyle = "normal"),mi("c"))`-8*lambda*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`+`#msub(mi("κ",fontstyle = "normal"),mi("c"))`^2-4*`#msub(mi("κ",fontstyle = "normal"),mi("c"))`*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`+4*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`^2)})

(2)

LinearAlgebra:-Eigenvalues(M, implicit=true); #RootOf notation; not what i want, but option works here

Vector(3, {(1) = -lambda-(1/2)*`#msub(mi("κ",fontstyle = "normal"),mi("c"))`-`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`, (2) = RootOf(_Z^2+(2*lambda+`#msub(mi("κ",fontstyle = "normal"),mi("c"))`+2*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`)*_Z+4*N*g^2+4*lambda*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`+2*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`*`#msub(mi("κ",fontstyle = "normal"),mi("c"))`, index = 1), (3) = RootOf(_Z^2+(2*lambda+`#msub(mi("κ",fontstyle = "normal"),mi("c"))`+2*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`)*_Z+4*N*g^2+4*lambda*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`+2*`#msub(mi("γ",fontstyle = "normal"),mi("φ",fontstyle = "normal"))`*`#msub(mi("κ",fontstyle = "normal"),mi("c"))`, index = 2)})

(3)

evals, evecs:=LinearAlgebra:-Eigenvectors(M); #RootOf everywhere;

evals, evecs := Vector(3, {(1) = RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 1), (2) = RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 2), (3) = -lambda-(1/2)*`κ__c`-`γ__φ`}), Matrix(3, 3, {(1, 1) = 8*g^2/(RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 1)+2*lambda+`κ__c`)^2, (1, 2) = 8*g^2/(RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 2)+2*lambda+`κ__c`)^2, (1, 3) = 2/N, (2, 1) = -2*sqrt(2)*g/(RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 1)+2*lambda+`κ__c`), (2, 2) = -2*sqrt(2)*g/(RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 2)+2*lambda+`κ__c`), (2, 3) = -(1/4)*sqrt(2)*(2*lambda+`κ__c`-2*`γ__φ`)/(g*N), (3, 1) = 1, (3, 2) = 1, (3, 3) = 1})

(4)

 

 

evals, evecs:=LinearAlgebra:-Eigenvectors(M, implicit=false); #still RootOf everywhere;

evals, evecs := Vector(3, {(1) = RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 1), (2) = RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 2), (3) = -lambda-(1/2)*`κ__c`-`γ__φ`}), Matrix(3, 3, {(1, 1) = 8*g^2/(RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 1)+2*lambda+`κ__c`)^2, (1, 2) = 8*g^2/(RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 2)+2*lambda+`κ__c`)^2, (1, 3) = 2/N, (2, 1) = -2*sqrt(2)*g/(RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 1)+2*lambda+`κ__c`), (2, 2) = -2*sqrt(2)*g/(RootOf(_Z^2+(2*lambda+`κ__c`+2*`γ__φ`)*_Z+4*g^2*N+4*`γ__φ`*lambda+2*`γ__φ`*`κ__c`, index = 2)+2*lambda+`κ__c`), (2, 3) = -(1/4)*sqrt(2)*(2*lambda+`κ__c`-2*`γ__φ`)/(g*N), (3, 1) = 1, (3, 2) = 1, (3, 3) = 1})

(5)

 

 


 

Download evals.mw

 

 

 

 

1 2 3 4 5 6 7 Last Page 1 of 11