ecterrab

14605 Reputation

24 Badges

20 years, 98 days

MaplePrimes Activity


These are answers submitted by ecterrab

It is the first time I see someone complaining about \rm ....(wow!). Learning. If some packages don't handle \rm, we need a replacement. By the way, \rm is being used within the whole Latex in only one place, to represent the e of 'exponential'. Where else is that you saw it popping up? And for a single letter, \mathrm or \textrm work as well. Any indication that  one is better than the other one?

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

As everybody guessed, there was a place in the code where an expansion of exp(x + y) was not happening, that place was PDEtools:-Library:-IsNotSeparable, a quick shortcut to avoid wasting time with unsolvable problems. Without that expansion, for some arbitrary F(x + y),  deq1 := diff(u(x, y), x) - diff(u(x, y), y$2) = F(x + y); is of course not separable.

This issue is resolved and the adjustment distributed for everybody within the Maplesoft Physics Updates v.865 and higher; thanks for posting the example.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

One condition, with denominator different from zero, for the existence of a solution using the S-function method was missing. A fix for this is distributed within the Maplesoft Physics Updates v.864 or newer.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

@nm 

Good point, although there is always the issue of who is the prime variable.. I'll add something for this in the next version of the Maplesoft Physics Updates. And what do you expect for PDE boundary conditions? Jet notation as you see in the help page for PDEtools:-ToJet?

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

See Workaround for the problem of installing MapleCloud packages in the Windows platform; probably that is your case.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

 

For reasons A and B that I skip here, in cases like this one, I coded to try a particular solution using symmetries, a computationally not-expensive and conceptually simple approach, however not well known by most people. See ?dsolve,details. In Maple, this approach is coded within DEtools[particularsols] for nonlinear equations. I don't have the books with me right now, but it may be explained in the symmetry books by George Bluman or the one by Peter Olver.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

Textbook notation shows "sin^2 x", not "sin^2 (x)" as Mathematica does. I understand the lack of parenthesis in textbook notation is the reason for showing the exponent right after the function's name.

In the DLMF, arguably the main reference for mathematical functions, basically all functions of one argument are displayed without parenthesis. For all of them, one could expect the exponent right after the function's name. On the other hand, in Mathematica, only Log and trig (not arctrig) functions are displayed that way.

This topic you bring is thus more about a convention for displaying powers of trig functions only - shall they be displayed differently than other functions Y/N?

The answer is debatable. I think the relevant things to keep in mind are:

  1. standard notation
  2. consistency
  3. non-ambiguous notation
  4. keep an eye on possible confusion with input notation

That said, consider these images:

These three expressions are mathematically different, the third one actually is a wrong representation of sin(x)^2, but of course valid input that makes sense in some (operator) contexts. So we want a representation for the three of them. In Maple, the second one in the input is actually equal to sin(x)^2.Textbook notation, however, represents the second one in the input, as the third one in the output - mixing these two, against item 3. If we go with what you suggest, we would also have no notation for the first expression in the input unless you suggest that sin^(2) <> sin^2, which for me would be against items 1. and 3. Complicated.

Next two images tell the same, just focusing closer:

These two are different expressions, that also look different in the input and the output. Your suggestion would make the two sides of the inequality look the same. Likewise, consider:

Here again, two different objects are displayed differently in the output - that is good, but your suggestion would make them look the same when translated to LaTeX.

So I see merit in what you say, the habit of writing "sin x" and, therefore, "sin^2 x" (not sin^2 (x)) is a compelling argument towards tex-translating sin(x)^2 to \sin^2 x. However, the computer still handles (sin@@2)(x) and also the (operator form) "sin^2 * x" and we need a representation for those too.

Taking all into account, what do you suggest?

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

Hi
I use TexShop, which is official CTAN standard latex, and having \\ before \end{array} does not tell the compiler to insert a newline. From the image you present, maybe you are using non-CTAN software.

In any case, \\ at the end of the last row is not necessary. I added a line of code to remove it, so what you ask is there in v.859 of the Maplesoft Physics Updates.

Regarding "ps. if the Latex conversion source code could be made public, ..." note Maple code is 100% readable (is that what you call public?). By the way, that is one of the big advantages of Maple with regards to Mathematica; all the library code is readable. In the case of modules (as is the case of Latex), to see it, remember to enter kernelopts(opaquemodules = false). Then, print or showstat will show you any subroutine. If you know what you are doing (Maple and LaTeX knowledge) you can change it to behave the way you prefer.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

To handle non-rational constants using the DifferentialAlgebra package, use the PDEtools:-casesplit command with the diffalg keyword; for details, see casesplit's help page.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

There are several ways of doing vector computations using Dirac's "Bra & Ket" notation. Note first that, whether you use the Vectors package or Dirac's notation directly, if you use unit vectors (e.g. `#mover(mi("i"),mo("&and;"))`, `#mover(mi("j"),mo("&and;"))`, `#mover(mi("k"),mo("&and;"))`), a vector is expressed as the sum of projections onto each axis multiplied by the corresponding unit vectors, not as a sequence of components separated by commas.

 

Load the two related packages

with(Physics); with(Vectors)

 

Set the imaginaryunit as you show

interface(imaginaryunit = I)

I

(1)

One way of accomplishing what you want is to set alias for the unit vectors of the Vectors package, so that they are displayed using Dirac's notation, for example as in

Ket(_i) = _i, Ket(_j) = _j, Ket(_k) = _k

Physics:-Ket(_i) = _i, Physics:-Ket(_j) = _j, Physics:-Ket(_k) = _k

(2)

alias(Physics[Ket](_i) = _i, Physics[Ket](_j) = _j, Physics[Ket](_k) = _k)

 

Input now your Ket(a) and Ket(b) expressions

Ket(a) = (1+I)*_i+_j+I*_k

Physics:-Ket(a) = (1+I)*Physics:-Ket(_i)+Physics:-Ket(_j)+I*Physics:-Ket(_k)

(3)

Ket(b) = 3*_i+(2-2*I)*_k

Physics:-Ket(b) = 3*Physics:-Ket(_i)+(2-2*I)*Physics:-Ket(_k)

(4)

Compute their inner product (for that, you use the dot `.` operator, not the star`*`)

LinearAlgebra:-Transpose(Physics[Ket](b) = 3*Physics[Ket](_i)+(2-2*I)*Physics[Ket](_k)).(Physics[Ket](a) = (1+I)*Physics[Ket](_i)+Physics[Ket](_j)+I*Physics[Ket](_k))

Physics:-Bracket(Physics:-Bra(b), Physics:-Ket(a)) = 5+5*I

(5)

In the above, LinearAlgebra:-Transpose(Physics[Ket](b) = 3*Physics[Ket](_i)+(2-2*I)*Physics[Ket](_k)) = Dagger(Physics[Ket](b) = 3*Physics[Ket](_i)+(2-2*I)*Physics[Ket](_k)), you need this since you are working with complex vectors, and you can use both notations to represent the same thing.

_______________________________________________________________________________

 

Another way to accomplish the same is to use Dirac's notation directly, without using the Vectors package, by setting a discrete basis of dimension 3 - see Physics,Setup  

Setup(quantumbasisdimension = {A = 1 .. 3})

[quantumbasisdimension = {A = 1 .. 3}]

(6)

So this is a projector onto the A basis

Projector(Ket(A))

Sum(Physics:-`*`(Physics:-Ket(A, n), Physics:-Bra(A, n)), n = 1 .. 3)

(7)

and the equivalence between kets of this basis and the input vectors `#mover(mi("i"),mo("&and;"))`, `#mover(mi("j"),mo("&and;"))`, `#mover(mi("k"),mo("&and;"))`, is

_i = Ket(A, 1), _j = Ket(A, 2), _k = Ket(A, 3)

Physics:-Ket(_i) = Physics:-Ket(A, 1), Physics:-Ket(_j) = Physics:-Ket(A, 2), Physics:-Ket(_k) = Physics:-Ket(A, 3)

(8)

To input your expressions you can use

subs(Physics[Ket](_i) = Physics[Ket](A, 1), Physics[Ket](_j) = Physics[Ket](A, 2), Physics[Ket](_k) = Physics[Ket](A, 3), Physics[Ket](a) = (1+I)*Physics[Ket](_i)+Physics[Ket](_j)+I*Physics[Ket](_k))

Physics:-Ket(a) = (1+I)*Physics:-Ket(A, 1)+Physics:-Ket(A, 2)+I*Physics:-Ket(A, 3)

(9)

subs(Physics[Ket](_i) = Physics[Ket](A, 1), Physics[Ket](_j) = Physics[Ket](A, 2), Physics[Ket](_k) = Physics[Ket](A, 3), Physics[Ket](b) = 3*Physics[Ket](_i)+(2-2*I)*Physics[Ket](_k))

Physics:-Ket(b) = 3*Physics:-Ket(A, 1)+(2-2*I)*Physics:-Ket(A, 3)

(10)

The inner product

LinearAlgebra:-Transpose(Physics[Ket](b) = 3*Physics[Ket](A, 1)+(2-2*I)*Physics[Ket](A, 3)).(Physics[Ket](a) = (1+I)*Physics[Ket](A, 1)+Physics[Ket](A, 2)+I*Physics[Ket](A, 3))

Physics:-Bracket(Physics:-Bra(b), Physics:-Ket(a)) = 5+5*I

(11)

_______________________________________________________________________________

 

Finally, a third way to do the same but with the Ket(A, n) vectors looking like the left-hand sides of (8), is to combine both ideas above. For that purpose first undo the alias done in (2)

alias(Ket(_i) = Ket(_i), Ket(_j) = Ket(_j), Ket(_k) = Ket(_k))

 

Next set new alias as in

Ket(_i) = Ket(A, 1), Ket(_j) = Ket(A, 2), Ket(_k) = Ket(A, 3)

Physics:-Ket(_i) = Physics:-Ket(A, 1), Physics:-Ket(_j) = Physics:-Ket(A, 2), Physics:-Ket(_k) = Physics:-Ket(A, 3)

(12)

alias(Physics[Ket](_i) = Physics[Ket](A, 1), Physics[Ket](_j) = Physics[Ket](A, 2), Physics[Ket](_k) = Physics[Ket](A, 3))

 

Entering your vectorial expressions

Ket(a) = (1+I)*Ket(_i)+Ket(_j)+I*Ket(_k)

Physics:-Ket(a) = (1+I)*Physics:-Ket(_i)+Physics:-Ket(_j)+I*Physics:-Ket(_k)

(13)

Ket(b) = 3*Ket(_i)+(2-2*I)*Ket(_k)

Physics:-Ket(b) = 3*Physics:-Ket(_i)+(2-2*I)*Physics:-Ket(_k)

(14)

LinearAlgebra:-Transpose(Physics[Ket](b) = 3*Physics[Ket](_i)+(2-2*I)*Physics[Ket](_k)).(Physics[Ket](a) = (1+I)*Physics[Ket](_i)+Physics[Ket](_j)+I*Physics[Ket](_k))

Physics:-Bracket(Physics:-Bra(b), Physics:-Ket(a)) = 5+5*I

(15)

This third way looks like the first one (equations (2) to (5)) but it is not. In (2) to (5), the operations are actually performed by the Physics:-Vectors package and the dot product of the unit vectors `#mover(mi("i"),mo("&and;"))`, `#mover(mi("j"),mo("&and;"))`, `#mover(mi("k"),mo("&and;"))` while in equations (12) to (15) the operations are performed by the Physics package (top-level) directly using Dirac's notation, just with Kets of the A basis looking like you see in (12).


 

Download Inner_product_of_vectors_using_Dirac_notation.mw

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

hastype(expr, radical) will answer your question. See also ?type,radical; there are other types of this sort, including composite types like type(expr, 'anything^fraction')

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

I'm not sure I understand your question. The definition of an ODE solution is that it satisfies the ODE. In Maple, you have a command to verify that. Try odetest(sol, ode2) and you receive 0. Therefore the solution you got from particularsol is a solution, indeed. If you are not comfortable with using odetest you can try eval(ode2, sol). You get the same feedback, the output by particularsols is indeed a solution as expected.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

You can get a slightly better solution, sill in implicit form or with RootOf, exploring the options of the symmetry integrators (see ?dsolve,Lie):

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft 

Good reminder; the option, dropmultiplicity::truefalse := true, the same one exists in solve with the opposite default value, is missing in PDEtools:-Solve at user level. I will add it today within the next Maplesoft Physics Updates.

UPDATE: the option is already implemented, in v.842 of the Physics Updates. Its use is as expected: dropmultiplicity = false to indicate that you want all the roots, not just those that are different.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Matheatical Functions, Maplesoft.

Therefore, the following does what you want to do:

foo := proc(expr, x)
local previous_values;

try
    previous_values := Typesetting:-Settings('prime' = x, 'typesetprime' = true);
    return((Physics:-Latex(expr)));
finally:
    Physics:-Latex:-Forget();
    Typesetting:-Settings('prime' = previous_values[1], 'typesetprime' = previous_values[2]);
end
end proc;

To the side: if you are using current Maplesoft Physics Updates, you do not need to prefix Latex with Physics:-; the package also includes a user-level Latex command that is a replica of Physics:-Latex.

Edgardo S. Cheb-Terrab
Physics, Differential Equations and Mathematical Functions, Maplesoft

First 18 19 20 21 22 23 24 Last Page 20 of 60