8 years, 64 days

## using indexed name for variable vs. two...

Maple 2020

For entering system of linear ode's, from textbook, such as this example

I can either use x[1],x[2]  or x__1 and x__2.

Maple dsolve works with both. The Latex generated is also exactly the same Which is x_{1} and x_{2}.

The only minor difference I see is on the screen in the worksheet (I only use 1D), where the subscript looks a little nicer in the case of x[1] vs. x__1

The subscript in the case of x[1] is upright while the one in x__1 is italic. I like the first one more.

Other than this cosmetic difference, Are there are subtle sematic differences between the two forms in terms of computation? I know x[1] create table x. OK.  While x__1 is a separate symbol. No table is created.,

Which would be  a safer/better option to use in this case?   Or is it just a matter of choice?

sys:=[ diff(x[1](t),t)=x[1](t)+x[2](t),diff(x[2](t),t)=x[1](t)+3*x[2](t)];
sys:=[ diff(x__1(t),t)=x__1(t)+x__2(t),diff(x__2(t),t)=x__1(t)+3*x__2(t)];


In some way, using x__1(t) might be a little easier to read on the eye than x[1](t) since there is only one type of paranthesis involved.

ps. I tried to search for __ in Maple help to read more about it, but ?__ do not show it. I am sure __ is in the help under some other name.

## replacing pattern in expression...

Maple 2020

For display only purposes, to get the Latex looking better, I replace the constant of integrations Maple using which is _C1, _C2., etc... to c[1],c[2],.....

This is something I do at the very end of computation, just before I get the Latex of the expression.

The way I do this now, is not good. .And I am asking if there is a better way to do this replacement. In Mathematica, I can do this using a patterm where I tell it to replace  C?  by c[?] where ? means anything.

Is it possible to do something like this in Maple? Here is an example

sol:=dsolve(diff(x(t),t$3) = x(t));  This gives solution as And just before ask for the Latex of this, I change it to This is done using a function. Please see worksheet below. The problem with the current solution is that I do not know how many _C there are, so I assumed 10 as worst case, which works for my case. But I prefer a more general solution, may be using pattern in the subs command?  > restart;  > replace_all_C:=proc(expr::anything) local n,N,c; local new_expr; local max_count :=10; #worst case, since do not know how many new_expr:=expr; for n from 1 to max_count do N:=convert(n,string); new_expr:=subs( :-parse(cat("_C",N))=:-parse(cat("c[",N,"]")),new_expr); od: return new_expr; end proc:  > sol:=dsolve(diff(x(t),t$3) = x(t)); tmp:=replace_all_C(sol)

 >

And now I get the latex of tmp in the above, instead of sol which looks better.

## Finding all Eigenvectors for real and r...

Maple 2020

When a real matrix have repeated eigenvalue (i.e. multiplicity >1) and the matrix is not the identity matrix, then it is called defective eigenvalue.

For example if the eigenvalue is repeated 2 times, there will be only one eigevector associated with it.

There is an algorithm to generate another (linearly independent) eigenvector from this same eigenvalue called the defective eigenvalue method.

My question is: Does Maple have support for finding such additional eigenvectors?  The standard Eigenvectors does not seem to do this. Here is an example.

restart;
A :=Matrix([[1,-2],[2,5]]);
(eigen_values, eigen_vectors) := LinearAlgebra:-Eigenvectors(A);


By hand, using the defective eigenvalue method it is possible find second eigenvector for this eigenvalue, which is linearly independent of the one returned by Maple. Such as

The method to find these additional eigenvector is described in number of places such as

https://en.wikipedia.org/wiki/Defective_matrix

And the pdf at the bottom show a more detailed example.

I can code this method by hand to find complete set of L.I. eigenvectors for this defective eigenvalue.

But before doing that, I thought to ask if Maple have buildin support for this, such as a single command to do this or some package.

I looked at help for LinearAlgebra and I am still not able to see anything, It only says this:

With an eigenvalue of multiplicity  k>1 , there may be fewer than  k linearly independent eigenvectors. In this case, the matrix is called defective.  By design, the returned matrix always has full column dimension.  Therefore, in the defective case, some of the columns that are returned are zero.  Thus, they are not eigenvectors.  With the option, output=list, only eigenvectors are returned.  For more information, see LinearAlgebra[JordanForm] and LinearAlgebra[SchurForm].

This PDF also describes using Maple, how to do it for one example

https://wps.prenhall.com/wps/media/objects/884/905485/chapt5/proj5.4/proj5-4.pdf

This PDF also describes how to do it by hand without using Maple, starting at end of page 3

http://www.math.utah.edu/~zwick/Classes/Fall2013_2280/Lectures/Lecture23_with_Examples.pdf

It is not too hard to code this method in Maple. But if Maple allready can do it, using some command, it will be better ofcourse.

## small new issue with Physics:-Latex...

Maple 2020

Using latest Physics, I found case where it is not giving the Latex.

Please see attached worksheet.  This is on windows 10, Maple 2020.1.1

 > restart;
 > interface(version);

 > Physics:-Version()

 > ode:=diff(y(t),t) = -2*arctan(y(t))/(1+y(t)^2);

 > sol:=dsolve(ode)

 > Physics:-Latex(sol)

Error, (in unknown) invalid range for string subscript

 > latex(sol)

t+\int ^{y \left( t \right) }\!{\frac {{{\it \_a}}^{2}+1}{2\,\arctan
\left( {\it \_a} \right) }}{d{\it \_a}}+{\it \_C1}=0

 >

By trial and error, I found that the error was introduced in Physics 797. Since in Physics 796 it did work.

Here is screen shot

## using hint for symgen, why not giving an...

Maple 2020

When I give symgen a HINT, using functional form f(x),g(x)*y it does not generate the infinitesimals of the Lie group for this ODE.

But from the answer given using way=abaco1 it is clear they have this form, where f(x)=-1/x and g(x)=1/x^2

From help, it says

HINT=[e1,e2], indicates to the solver that it should take e1 and e2 as the infinitesimals, where e1 and e2 can contain a maximum of two indeterminate functions. The solver tries to determine the infinitesimals to solve the problem.

And I am using only two indeterminate functions. These are f(x) and g(x)

Am I making a mistake somewhere? Please see worksheet below.

 > restart;
 > interface(version)

 > Physics:-Version()

 > restart; ode:=diff(y(x),x)=(1-y(x)^2)/(x*y(x))+1; #why this below do not give result? DEtools:-symgen(ode,HINT=[f(x),g(x)*y]);

 > DEtools:-symgen(ode,way=abaco1);

 > #it works for this though. May be the two functions #can  not be both functions of x at same time? #one function must be function of x and the other of y? #But help does not say that. ode :=diff(y(x),x)=(x+cos(exp(-x)*(1+x)+exp(y(x))))/(exp(x+y(x))); DEtools:-symgen(ode,HINT=[f(x),x*g(y)]);

 >