## 13821 Reputation

14 years, 205 days

## You haven't necessarily...

made an error. Like the following excerpt from the pdsolve/numeric help page states (emphasis added

The solver has two modes of operation.
The first mode of operation uses the default method, which is a centered implicit scheme, and is capable of finding solutions for higher order PDE or PDE systems. The PDE systems must be sufficiently close to a standard form for the method to find the numerical solution.
The second mode of operation is strictly educational, and allows specification of a particular method to solve a PDE. This mode is restricted to a single PDE.

You may want to ask the question - what does "close to a standard form" actually mean - I have no idea.

## Hmmm...

Persuading solve() to return only those solutions which you wantcan be a bit of a "black art".

The (usual) first approach, is to restrict the domain of the problem, by using assumptions ( in your case beta>0, beta<1). Then restrict the range of the problem, by adding inequalities (in your case xi>0, xi<1) to the equation to be solved. You should be aware that either/both of these approaches can fail: sometimes Maple will provide a warning message stating that it "may" be ignoring assumptions on variables; also Maple's only has a rather limited capability to deal with inequalities in the system to be solved.

However this approach appears to work in your case, see the attached.

 > restart; # # Set assumptions restricting domain #   assume(beta>0, beta<1):   interface(showassumed=0):   eq[1]:=(1/6)*beta^3+(1/2)*xi^2*beta-(1/2)*beta^2-(1/2)*xi^2+(1/3)*beta = 0:   eq[2]:=(1/6)*beta*(beta^2+3*xi^2-6*xi+2) = 0: # # Include inequalities to restrict range of xi #   left:=solve([ eq[1], xi>0, xi<1],xi)[];   right:=solve([ eq[2],xi>0,  xi<1], xi)[];   plot( [ rhs(left), rhs(right)],         beta=0..1,         color=[red, blue],         legend=["left", "right"],         labels=['beta', xi]       );
 >

## With Maple...

there is often more than one way. See the attached for an alternative

 > restart;   with(plots):   ic:=[seq(j, j=0..1, 0.1)]:   display( [ seq              ( odeplot                ( dsolve                  ( { diff(x(t),t)=y(t),                      diff(y(t),t)=-x(t),                      x(0)=1,                      y(0)=ic[j]                    },                    numeric                  ),                  [[t, x(t)], [t, y(t)]],                  t=0..10,                  color=[red, blue]                ),                j=1..numelems(ic)              )            ]          );
 >
 >

## The code attached...

will import from a text file containing this

```t[s]; scanId; m/z; I[A]; pTot[mbar]
2.00;0;0; 0.000000e+000; 0.000000e+000
4.00;0;0; 0.000000e+000; 0.000000e+000
441.00;0;0; 0.000000e+000;1,29E+00
443.00;0;0; 0.000000e+000;1,29E+00
453.00;0;0; 0.000000e+000;1,26E+00
455.00;0;0; 0.000000e+000;1,24E+00
463.00;1; 0.390625;8,14E-05;1,23E+00
464.00;1; 0.40625;1,23E-04;1,43E+00
464.00;1; 0.421875;1,73E-04;1,43E+00
464.00;1; 0.4375;2,27E-04;1,43E+00
464.00;1; 0.453125;2,77E-04;1,43E+00```

to a matrix. Obviously you will have to change 'fname', the location of the data file, to something appropriate for your installation

 > restart;   interface(rtablesize=20):   with(StringTools):   fname:="C:/Users/TomLeslie/Desktop/data.txt":   T[0]:=Split( readline(fname), ";"):   j:=1:   line:=readline(fname):   while line <> 0 do         T[j]:=parse~( map2( Subs, ["E"="e", ","="."], Split(line, ";")));         line:=readline(fname):         j:=j+1;   od:   M:=Matrix([seq(T[k],k=0..j-1)]);
 (1)
 >

## The code in...

the attached produces an output file whose contents are pasted below

```{{a, b}, {b, c}}
{{d, e}, {e, f}}
{{d, f}, {e, f}}
{{a, h}, {h, i}}
{{a, i}, {h, i}}
{{d, e}, {d, f}}
{{a, h}, {a, i}}
{{c, d}}
{{a, b}, {a, c}}
{{a, c}, {b, c}}```

Is that what you want? - Obviously you will have to change the file path to somethhing appropriate for your machin

 > restart; M:=Vector[column](10, [{{a, b}, {b, c}}, {{d, e}, {e, f}}, {{d, f}, {e, f}}, {{a, h}, {h, i}}, {{a, i}, {h, i}}, {{d, e}, {d, f}}, {{a, h}, {a, i}},{{c, d}}, {{a, b}, {a, c}}, {{a, c}, {b, c}}]): Export("C:/Users/TomLeslie/Desktop/test.csv", M):
 >

## Well, I'm not sure why,...

but if you isolate all the first derivatives on to the lhs of the odes, then the dsolve(...,numeric) process executes in negligible time.

See the attached

## The only "import"...

command which acts in the way you describe (ie imports as a string) is readline(). Whilst this command is useful in some contexts, it is a bit "clunky" for general use.

It is probably better to save "executable code" as an "mpl" file, which is plaintext, human-readable (same as Maple's 1D input) and can be modified in your favourite text editor

"mpl" files can either be created from a worksheet within Maple using File->Export As from the menus, or created with an external text editor, or a mixture of both

"mpl" files can be loaded into a new worksheet with a simple "read" command. Code in the file will be read/executed. Consideer the "toy" example shown in the attached, where I have used File->Export As on the code I provided for this problem

https://www.mapleprimes.com/questions/235455-Brianch0n-Theoreme-With-Hexagon,

to create the mpl file. Rather annoylngly this site does not permit the uploading of "mpl", for which the workaround is to "zip" them like this hexplot3.zip. Once you unzip this file, it can be read/executed as shown in the worksheet below

 > restart; # # OP will have to change the file path in the following # depnding on where (s)he, saved the "mpl" file # # Code in the file will read/execute with the following # command, and produce a geometric construction, which # happens to be a solution I provided for the problem # posed here # # https://www.mapleprimes.com/questions/235455-Brianch0n-Theoreme-With-Hexagon # # The execution takes a few seconds, so wait #   read "C:/Users/TomLeslie/Desktop/hexplot3.mpl";
 >

## I have no idea whether...

the attached fulfils what you were trying to achieve - but at least it executes!

 > restart;   with(plots):   local gamma:   line := proc (x1, y1, x2, y2)                 options operator, arrow;                 (x-x1)*(y2-y1)-(y-y1)*(x2-x1)           end proc:   R := 3:   ang := [0, (1/3)*Pi, 3*Pi*(1/4)+.2, 7*Pi*(1/6)+.4, 8*Pi*(1/5), 13*Pi*(1/7)]:   for i to 6 do       P || i := [R*cos(ang[i]), R*sin(ang[i])]   end do:   pts := [seq(P || i, i = 1 .. 6)]:   for i to 6 do       tang || i := x*P || i[1]+y*P || i[2] = R^2   end do:   sol:=solve({tang1,tang3},{x,y}):   Q13:=[subs(sol,x),subs(sol,y)]:   sol := solve({tang1, tang2}, {x, y}):   Q1 := [subs(sol, x), subs(sol, y)]:   sol := solve({tang2, tang3}, {x, y}):   Q2 := [subs(sol, x), subs(sol, y)]:   sol := solve({tang3, tang4}, {x, y}):   Q3 := [subs(sol, x), subs(sol, y)]:   sol := solve({tang4, tang5}, {x, y}):   Q4 := [subs(sol, x), subs(sol, y)]:   sol := solve({tang5, tang6}, {x, y}):   Q5 := [subs(sol, x), subs(sol, y)]:   sol := solve({tang1, tang6}, {x, y}):   Q6 := [subs(sol, x), subs(sol, y)]:   ptQ := [seq(Q || i, i = 1 .. 6)]:   line14 := line(Q1[1], Q1[2], Q4[1], Q4[2]):   L14 := implicitplot(line14, x = -10 .. 10, y = -10 .. 10, color = red):   line25 := line(Q2[1], Q2[2], Q5[1], Q5[2]):   L25 := implicitplot(line25, x = -10 .. 10, y = -10 .. 10, color = red):   line36 := line(Q3[1], Q3[2], Q6[1], Q6[2]):   L36 := implicitplot(line36, x = -10 .. 10, y = -10 .. 10, color = red):   sol := solve({line14, line25}, {x, y}):   I1 := [subs(sol, x), subs(sol, y)]:   lineP23 := line(P2[1], P2[2], P3[1], P3[2]):   lineP56 := line(P5[1], P5[2], P6[1], P6[2]):   sol := solve({lineP23, lineP56}, {x, y}):   gamma := [subs(sol, x), subs(sol, y)]:   lineP12 := line(P1[1], P1[2], P2[1], P2[2]):   lineP45 := line(P4[1], P4[2], P5[1], P5[2]):   sol := solve({lineP12, lineP45}, {x, y}):   beta := [subs(sol, x), subs(sol, y)]:   lineP34 := line(P3[1], P3[2], P4[1], P4[2]):   lineP16 := line(P1[1], P1[2], P6[1], P6[2]):   sol := solve({lineP16, lineP34}, {x, y}):   alpha := [subs(sol, x), subs(sol, y)]:   pl:= line(alpha[1], alpha[2], gamma[1], gamma[2]): #  hexa := seq(implicitplot(tang||i, x = -20 .. 20, y = -20 .. 20, linestyle=3,color = blue),i=1..6); #  hexa:=plot([seq([P||i,P||(i mod 6)+1],i=1..6),color=green);    hexa:=plot([seq([`||`(P,i), `||`(P, irem(i,6)+1)],i=1..6)],thickness=4,color=green):   hex:=plot([[Q1,Q2],[Q2,Q3],[Q3,Q4],[Q4,Q5],[Q5,Q6],[Q6,Q1]],thickness=4,color=green):   tp := textplot({seq([op(pts[i]), cat("P", i)], i = 1 .. 6)}, 'align' = {'above', 'left'}):   tpq := textplot({seq([op(ptQ[i]), cat("Q", i)], i = 1 .. 6)}, 'align' = {'above', 'left'}):   TP:=textplot([[I1[],"I"],[alpha[],"alpha"],[beta[],"beta"],[gamma[],"gamma"]],'align' = {'above', 'left'}):   slopes:=[seq(((dx,dy)->dy/dx)((pts[i]-pts[(i mod 6)+1])[]),i=1..6)]:   lines:=zip((pt,slope)->y=slope*(x-pt[1])+pt[2],pts,slopes):   plotpts:=plot(pts,style=point,colour=red,symbol=solidcircle,symbolsize=5):   plotptQ:=plot(ptQ,style=point,colour=black,symbol=solidcircle,symbolsize=5):   plotlines:=plot(rhs~(lines),style=line,linestyle=3,colour=magenta):   cir:=implicitplot(x^2+y^2=R^2,x=-R..R,y=-R..R,color=black):   PL:=implicitplot(pl,x=-1..15,y=-15..6,color=blue,thickness=3):   display( plotpts,plotptQ,plotlines,hex,cir,L14,L25,L36,PL,tp,tpq,TP,            axis = [gridlines = [4, color = blue]],            view=[-6..10,-15..6],            scaling=constrained,            axes=none,            size=[800,800]          );
 >

## Don't understand the problem...

You state

This is something that has been a problem using Maple for decades.

Is it at all possible to create indexed variables ?

It has always been possible to create "indexed variables" - and you have a large choice.

Depending on what you want to do with these variables, you can create them as lists, tables, arrays, vectors, or matrices. So which of these have you (but no-one else) had a problem creating (for decades!?!)

## It is rare...

to come across such a grabled worksheet - quantities defined and never used, quantities defined multiple times, no dinction made between functions and indexed variables etc, etc.

In the attached I have removed a lot of stuff you definitely don't need and made a lot of wild guesses about your intentions at various points. I suggest you read it very carefully because the chances of all of my "wild guesses" being correct iare not very good!

Still - at least it executes.

 > restart: N[t]:=0.7: N[b]:=0.6: Gr:=2.0: G[1]:=0.5: j[1]:=0.4: Pr:=2.5: R:=1.3: Sc:=0.4:g[1]:=0.5: F[0]:=0: F[1]:=1: F[2]:= A/2: delta[-1]:=0: delta[0]:=1: delta[1]:=0: Theta[0]:=1: Theta[1]:=B: Phi[0]:=1: Phi[1]:=C: for k from 2 to 20 do     delta[k]:=0: od:
 > for k from 0 to 3 do     F[k + 3] := ( add((k - m + 1)*F[k - m + 1]*(m + 1)*F[m + 1], m = 0 .. k)*(1 + G[1]) + Gr*Theta[k] - add(F[k - m]*(m + 1)*(m + 2)*F[m + 2], m = 0 .. k) + (k + 1)*F[k + 1]*(M^2 + j[1]))/((k + 1)*(k + 2)*(k + 3)): end do:
 > for k from 0 to 3 do     Theta[k + 2] := -Pr*(N[t]*add(add(delta[l - 1]*(m - l + 1)*Theta[m - l + 1]*(k - m + 1)*Theta[k - m + 1], l = 0 .. m), m = 0 .. k) + add(F[k - m]*(m + 1)*Theta[m + 1], m = 0 .. k) + N[b]*add((k - m + 1)*Theta[k - m + 1]*(m + 1)*Phi[m + 1], m = 0 .. k) + Delta*Theta[k] - g[1]*add(Theta[k - m]*(m + 1)*F[m + 1], m = 0 .. k))/((1 + (4*R)/3)*(k + 1)*(k + 2)): end do:
 > for k from 0 to 3 do     Phi[k + 2] := -(Sc*add(F[k - m]*(m + 1)*Phi[m + 1], m = 0 .. k) + N[t]*(k + 1)*(k + 2)*Theta[k + 2]/N[b])/((k + 1)*(k + 2)): end do:
 > f := add(F[i]*eta^i, i = 0 .. 3); theta := add(Theta[i]*eta^i, i = 0 .. 3); phi := add(Phi[i]*eta^i, i = 0 .. 3);
 (1)
 > sol := RealDomain[solve]( { eval( diff(eval(f, [M = 1.1, Delta = 0.5]), eta), eta=3) = 1,                             eval( theta, [M = 1.1, Delta = 0.5, eta=3]) = 0,                             eval( phi, [M = 1.1, Delta = 0.5, eta=3]) = 0                           }                         )[3][];
 (2)
 > d1 := diff( eval(f, [sol, M = 1.1, Delta = 0.5]), eta): d2 := diff( eval(f, [sol, M = 1.6, Delta = 0.5]), eta): d3 := diff( eval(f, [sol, M = 2.2, Delta = 0.5]), eta): d4 := diff( eval(f, [sol, M = 2.6, Delta = 0.5]), eta): plot([d1, d2, d3, d4], eta = 0 .. 7);
 > s1 := eval(theta, [sol, Delta = 0.5] ):   s2 := eval(theta, [sol, Delta = 1.0] ):   s3 := eval(theta, [sol, Delta = 1.5] ):   s4 := eval(theta, [sol, Delta = 2.0] ):   plot([s1, s2, s3, s4], eta = 0 .. 7);
 >

## Before doing anything else...

learn the difference between square brackets and round brackets!! ie [] and ().

Square brackets, ie '[]',  are used to access elements of indexable quantities, such as tables, vectors, arrays, lists etc. They should never be used for simple grouping of terms in a mathematical expression.

Round brackets, ie '()' are used for grouping of terms in a mathematical expression, or applying a function to an argument.

So, for example, delta(v) and delta[v] mean two entirely different things to Maple

You appear to be using these two different kinds of parentheses more-or-less interchangeably - which you can't!

In the attached I have *guessed* your intentions with respect to the parentheses problem, and fixed too many other syntax errors to list. At least this worksheet executes, although it producesw "answers" in terms of Theta[-3],Theta[-2],and Theta[-1], none of whihc have been defined. This may (or may not?) be related to the use of the same summation index 'w' at two levels of a nested sum (highlighted inred in the attached), which *looks* very suspicious to me.

 >
 >
 >
 (1)
 >

## Don't see a probelm...

in Maple 2022.

I used leftclick in Maple to select something for cop, followed by rightclick to bring up the context menu, then Copy As->Image on this menu. This allowed me to produce the attached MSWord document with a couple of images from the attached Maple document.

test.mw

test.docx

## Some fixes...

are shown in the attached - but the original code is so confusing, it is difficult for me to be sure whther or not the 'fixes' are correct.

At least the code now executes without error.

However, your final expression 'e5', contains the five unknowns {k[f], k[nf], m[0], m[1],m[2]} and you can't solve a single equation for five unknowns - so I was unable to make any further progress

part.mw

## 'break 2'...

Some relevant excerpts from the helprom the help

.......exit from the innermost repetition (for/while/do) statement within which it occurs.

If break is followed by an integer N, then execution exits the Nth innermost repetition statement. The statement break 1 is equivalent to just break

It is an error if a break appears in a context other than within a repetition statement........or there are fewer than N enclosing repetition statements.

You only have one enclosing "repetition statement" (aka for-loop), so 'break 2' will always give an error.

It is not clear (to me at least) why you state that

If I don't include the integer, I am able to run the procedure, but it does not function like I would like it to

So exactly how would you like it to function?

## Well...

the variable 'm0' occurs in the expressions you want to plot, but has nowhere been assigned.

I would have fixed this except that 'm0' is equated to (but not assigned to) various different quantities in your worksheet, and I have no idea which value(s) you actually want

 First 8 9 10 11 12 13 14 Last Page 10 of 207
﻿