## 12497 Reputation

12 years, 231 days

## Hmmmmm...

So you wantt a solution for a system of odes which contains some totally arbitrary function h(t)?

Just for amusement in the attached, I have shown that Maple will provide solutions for a variety of possibilities of this  otherwise completely indeterminate function - I used h(t)=0, h(t)=cos(t) and h(t)=t^2. In all cases, a solution is found. But for h(t) entirely arbitrary - get real!

You might want to consider the attached where I have used some more-or-less  *random* guesses for h(t), as in   h(t)=0,  h(t)=cos(t), and h(t)=t^2. All of these generate "solutions". But for h(t) entirely arbitrary - no chance!

 > restart:   assume(lambda>0);   interface(showassumed=0):   odeSys:= diff(x(t),t)=y(t),            diff( y(t), t) =z(t),            diff(z(t),t)=-lambda*y(t)-h(t);   dsolve(eval( [odeSys], h(t)=0));   dsolve(eval( [odeSys], h(t)=cos(t)));   dsolve(eval( [odeSys], h(t)=t^2));    (1)
 >

## Well you have several choices...

but probably the simplest is to use the surfdata() command as shown in the attached. Many options are available with the surfdata() command, none of which I have bothered with

Two points to note

1. You will have to change the file path in th ExcelTools:-Import() command to something appropriate for your machine
2. It is not obvious from the data yu supply which direction you regard as 'x' and which is 'y', so I madee an arbitrary choice
 > restart;    with(plots):    f := ExcelTools:-Import("C:/Users/TomLeslie/Desktop/PlotTest.xlsx"):    L:= [ seq          ( [ seq              ( [ f[i+1,1], f[1,j+1], f[i+1, j+1] ],                  i=1..9              )            ],            j=1..9          )        ]:    surfdata(L); > ## It is relatively simple...

to get a numerical solution for your problem - although it appears that Maple cannot find an analytic solution.

See the attached.

After the point of achieving a solution, I have no idea what your subsequent code is trying to achieve, so I have ignored it!

 > restart:   with(plots):   _local(I):   Digits := 15:   odeSys:= (1 - p)*(diff(S(t), t) + mu*S(t)) + p*(diff(S(t), t) + mu*S(t) + beta*S(t)*I(t) - rho*R(t) - varepsilon),            (1 - p)*(diff(E(t), t) + (alpha1 + mu)*E(t)) + p*(diff(E(t), t) + (alpha1 + mu)*E(t) - beta*S(t)*I(t)),            (1 - p)*(diff(I(t), t) + (alpha2 + delta + mu)*I(t)) + p*(diff(I(t), t) + (alpha2 + delta + mu)*I(t) - alpha1*E(t)),            (1 - p)*(diff(R(t), t) + (mu + rho)*R(t)) + p*(diff(R(t), t) + (mu + rho)*R(t) - alpha2*I(t)):   params:= [ mu=0.133*10^(-5),              varepsilon=0.99879,              delta=0.004554,              beta=0.1009*10^(-6),              alpha1=0.0008999,              alpha2=0.1997,              rho=0.00090021,              p=1            ]:   ibvc := S(0) = 2304219, E(0) = 84929, I(0) = 299, R(0) = 71411: # # Won't find an analytic solution :-( #   solA:=dsolve(eval( [odeSys ,ibvc], params)); # # Will find a numeric solution :-) #   solN:=dsolve(eval( [odeSys,ibvc], params), numeric);   odeplot(solN, [t, S(t)], t=0..10, color=[red, green, blue, black]);   odeplot(solN, [t, E(t)], t=0..10, color=[red, green, blue, black]);   odeplot(solN, [t, I(t)], t=0..10, color=[red, green, blue, black]);   odeplot(solN, [t, R(t)], t=0..10, color=[red, green, blue, black]);       >

## an alternative...

using a simple rotation matrix is shown in the attached

 > restart;   with(plots):   a := 7:   b := a/2:   rot:= Matrix(2,2, [ [cos(theta), -sin(theta)],                       [sin(theta),  cos(theta)]                   ]             ):   T:= rot.Vector(2, [x,y]):   Ell:=x^2/a^2+y^2/b^2=1;   doRot:= ang->expand(eval(Ell,eval( [x=T, y=T], theta=ang))):   e1:= doRot(Pi/4);   e2:= doRot(-Pi/4);   display( [ implicitplot(e1, x=-6..6, y=-6..6, color=blue),              implicitplot(e2, x=-6..6, y=-6..6, color=blue)            ]          );    >

## I'd probably...

be using the geometry() package, as in the attached

 > restart;   with(geometry):   a := 7:   b := a/2:   r := b/2:   c := 2*sqrt(10)*r:   circle(C1, [point(P1, [ c/2 - r, -c/2 + r]), r]):   circle(C2, [point(P2, [-c/2 + r, -c/2 + r]), r]):   circle(C3, [point(P3, [-c/2 + r,  c/2 - r]), r]):   circle(C4, [point(P4, [ c/2 - r,  c/2 - r]), r]):   ellipse(E, x^2/a^2 + y^2/b^2 = 1, [x,y]):   rotation(e1, E, Pi/4, clockwise):   rotation(e2, E, Pi/4, counterclockwise):   Equation(e1);   Equation(e2);   draw( [ C1(color=cyan, filled=true),           C2(color=cyan, filled=true),           C3(color=cyan, filled=true),           C4(color=cyan, filled=true),           e1(color=blue),           e2(color=blue)         ],         view=[-6..6, -6..6]       );   >

## A dangerously incomplete answer...

but since no-one else is contributing, I'm going to do my bets with some (possibly incomplete?) guidelines

I have downloaded the DirectSearch package as directed in help text but the only result from issuing the command kernelopts(toolboxdir) is " ".

I don't think that this is a very good way to check whether or not you have *successfully* installed the DirectSearch() package. A better alternative would be

```  with(LibraryTools):
FindLibrary(DirectSearch);
```

If the DirectSearch() package has been installed then the result of the command  If this command givesFindLibrary() will give the location where the DirectSearch.mla repository is installed. If this command gives nothing in return, then Maple cannot find the required file in your current search path. Your current search path is determined by the output of the command libname -as in

`libname;`

This will return a list of directories where Maple will look for stuff (such as the DirectSearch package). I suppoes it is possible that yu have managed to install the DirectSearch package, somewhere weird, but assuming that you just followed default installation instructions, then I would expect the the DirectSearch package to be in one of two locations (on a Windows machine!)

1. "C:Program Files\Maple 2022\lib\DirectSearch.mla", or

I can only recommend that you have a good look into/around these locations.

##########################################
Another *quick and dirty* method of determing whether or not the DirectSeacrh package has been successfully installed is to use Maple's help facility - because it is a pretty good bet hta if the "help" for the DirectSearch package has been installed then it is a good bet that that the executable DirectSearch package has been installled! Steps are

1. From a Maple worksheet use the menu entries Help->Maple Help
2. In the Maple help browser near the top left, there is a "toggle" button labelled Products. I'm pretty sure that (by default) this will be set to 'Maple' - which means that you can only see help for "standard" Maple. However you can change htis to check the tickbox identified as 'User Help'. This will enable the "help" facility for any "user" packages you may have installed (such as DirectSearch)
3. Having made sure that "user" help has been invoked (see item 2 above), type DirectSearch in the "Search" window. If you get  get a few pages reference in the left-hand pane, then the DirectSearch "help" is available - and by assumption, all DirectSearch commands are available

##########################################

Using Maple Cloud as means of exchanging files between computers. My first reaction is that  it seems like "overkill" (use email?) but it is possible, assuming you understand some limitations, about what you can subsequently do on these computers. This is not something I do often(/ever?) so I am working from the Maple help, part of which states

When you open a package workbook from the MapleCloud, you can use the package commands within that workbook.
However, if you want to be able to access those same package commands from within any Maple document, you must install the package workbook.

This suggests to me that yiu cannot modify or utilise (in a worksheet) anyhting from the Maple Cloud - you have to download and install it on the local machine. Haviing "installed" the relevant package, you can use standard commands from the LibraryTools() package to update the mla file any way you see fit. And then upload the results to Maple |Cloud again

## If I understand correctly...

maybe the attached will achieve what you want

 > restart;   padMatrix:= proc( M1, M2 )                     uses LinearAlgebra:                     if   op([1,2],M2) > op([1,2],M1)                     then return `<|>`                                 ( Column(M1, 1..-1),                                   Vector[column](op([1,1],M1))                                   \$                                   op([1,2],M2)-op([1,2],M1)                                 );                     elif op([1,2],M2) < op([1,2],M1)                     then return `<|>`                                 ( Column(M2, 1..-1),                                   Vector[column](op([1,1],M2))                                   \$ op([1,2],M1)-op([1,2],M2)                                 );                     fi;               end proc:   A:=LinearAlgebra:-RandomMatrix(9,4):   B:=LinearAlgebra:-RandomMatrix(6,7):   padMatrix(A, B);   padMatrix(B, A);  (1)
 >

## The *short* version...

using 2D input in Document Mode, is shown in the attached  (1)  (2)  (3) ## Certainly not a bug...

just a faiure on the OP's part to understand how Maple *categorizes* an expression, and therefore what will be returned when using convert(expression, list).

The attached contains examples (with comments) for clarification.

 > restart:
 > # # Certainly not a bug, just OP's failure to understand # how Maple categorizes expressions # # For example, what type is the following expression? #   expr:=U(xi)^2*y(xi)^5; # # Hmmmm - multiplicative #   whattype(expr); # # So what are the terms in the multiplicative expression? #   convert(expr,list);   (1)
 > # # Let's make it more complicated. How does Maple # categorize the following expression #   expr:=U(xi)^2*y(xi)^5*sin(xi); # # Hmmmm - multiplicative #   whattype(expr); # # So what are the terms in the multiplicative expression? #   convert(expr,list);   (2)
 > # # Let's make it *even* more complicated. How does Maple # categorize the following expression #   expr:=U(xi)^2*y(xi)^5*sin(xi)+diff(y(xi), xi); # # Hmmmm - additive #   whattype(expr); # # So what are the terms in the additive expression? #   convert(expr,list);   (3)
 > # # Let's simplify a little How does Maple # categorize the following expression #   expr:=U(xi)^2; # # Hmmmm - power #   whattype(expr); # # So what are the terms in the power expression? #   convert(expr,list);   (4)
 >

## Don't use...

square brackets (ie '[]') for simple grouping of terms in an algebraic expression.

See the attached  Lagrangian  (1.1) Time Equation  (2.1)  ## Read the help...

Form the help page for the ShowSolution() command (emphasis added)

The ShowSolution command is used to show the solution steps for a Calculus1 problem, that is, a limit, differentiation or integration problem such as can be expected to be encountered in a single-variable calculus course.

## Don't...

use square brackets (ie '[]') for grouping terms in a simple algebraic expression. Square brackets in Maple are used to construct indexable quantities, such as lists.

Just changing these square brackets, code runs - see the attached

 > > >  (1)
 >  (2)
 >  (3)
 >  (4)
 >  (5)
 > ## I think...

the attached solves both of your problems

 > restart:   with(LinearAlgebra):   uniqRow:= mat-> local i,j;                   `if`( member                         ( true,                           { seq                             ( seq                               ( Equal                                 ( mat[j,..],                                   mat[i,..]                                 ),                                 i=j+1..op([1,1],mat)                               ),                               j=1..op([1,1],mat)                             )                           }                         ),                         false,                         true                       ): # # The odds of getting two identical rows in # a random matrix is infinitesimal #   M:=RandomMatrix(10,10):   uniqRow(M); # # Force two rows to be the same and check again #   M[5,..]:=M[1,..]:   uniqRow(M);  (1)
 > A:=Matrix(3, 3, [[1, 2, 3], [3, 2, 1], [4, 6, 5]]):   B:=Matrix(3, 3, [[3, 2, 1], [1, 2, 3], [4, 6, 5]]):   C:=Matrix(3, 3, [[3, 2, 1], [1, 2, 3], [4, 5, 6]]):   isPerm:= (mat1, mat2)-> local i,j;                           `if`                           ( member                             ( true,                               { seq                                 ( `if`                                   ( Equal                                     ( mat1,                                       `<,>`( seq(mat2[i,..], i in j))                                     ),                                     true,                                     false                                   ),                                   j in combinat:-permute([\$1..op([1,1],mat1)])                                 )                               }                             ),                             true,                             false                           ):   isPerm(A,B);   isPerm(A,C);  (2)
 >

## Doesn't make sense...

The function definition

`f:=(r,theta)->I*sinh(theta-Pi/6)+cos(Pi/4)=r;`

could be (trivially) rewitten as

`f:=(r,theta)->I*sinh(theta-Pi/6)=r-cos(Pi/4);`

If both 'theta' and 'r' are real, then the left hand side of this latter equation is purely imaginary, and the right-hand side is purely real. So under what circumstances could they possibly be equal? Only if both sides are zero, which requires theta=Pi/6, r=cos(Pi/4)=sqrt(2)/2.

In other words you original equation is only satisfied at a single point. Now what exactly do you want to plot?

## Isn't this just...

repeated application of Dijkstra's algorithm - as in the attached?

 > restart;   with(GraphTheory):   doDijk:= proc( GG::Graph, start )                  local j;                  uses GraphTheory, ListTools:                  return seq                         ( Reverse                           ( DijkstrasAlgorithm                             ( G2,                               start,                               j                             )                           ),                           j in `minus`                                ( convert                                  ( Vertices(G2),                                    set                                  ),                                  {start}                                )                          );           end proc:
 > G2:=Graph( [\$1..5], {{2,3}, {2,4}, {3,4}, {3,5}}):  doDijk( G2, 1);  doDijk( G2, 2);  doDijk( G2, 3);  doDijk( G2, 4);  doDijk( G2, 5);     (1)
 >