tomleslie

13876 Reputation

20 Badges

15 years, 175 days

MaplePrimes Activity


These are answers submitted by tomleslie

Not something I do often/at all, but I have just tried this on one of my own worksheets, which happens be to split into mutliple sections, using Maple 2018.1 running on 64-bit win7 everything works as I would expect (more or less)

  1. F11 goes to slideshow mode: NB it "fullscreens" the Maple worksheet, with not even sheet borders visible
  2. I can step through slides using keyboard 'arrow' keys - not sure why but my first "instinct" was to use 'up' and 'down' arrows, but (rather obviously) left and right keyboard arrows are required to change 'slides'
  3. The 'Esc' key exits the fullscreen/slideshow mode.

I'm not generally convinced how useful this slideshow mode actually is

A single 'slide' is a Maple 'section', and if the latter is 'too long' to fit the slide, then it is simply truncated - not great. On balance I think I would prefer to fullscreen the Maple worksheet and then use 'Page Up' and 'Page Down' from the keyboard. Obviously this means that one still has the worksheet borders/toolbars etc, but there is no requirement for the Maple worksheet to have (appropriate length) sections

I know nothing about "Ising models", but it seems to depend on a random matrix populated with entries from [-1, 1], together with a "nearest neighbour" interaction function.

Provided that the interaction function is "scalar", then the attached ought to provide a start. You will have to provide a definition for this function; I have just used the general f(arg1, arg2).

(If the "interaction function" is vector-valued on nearest neighbours, I'd want to think a little more!)

  restart;
#
# Specify dimensions of the matrices
#
  nR:= 5:
  nC:= 5:
  with(LinearAlgebra):
#
# Generate random matrix with 1/-1 entries
#
  r:= rand(0..1):
  s:= ()-> (-1)^r():
  C:= RandomMatrix(nR,nC, generator=s);
#
# Define a *scalar* nearest-neighbour interaction
# function
#
  N:= (i,j)-> add
              ( add
                ( `if`
                  ( `and`
                    ( i+p > 0, i+p < nR+1,
                      j+q > 0, j+q < nC+1,
                     `not`(`and`(p=0, q=0) )
                    ),
                    f(C[i,j], C[i+p, j+q]),
                    0
                  ),
                  p = -1..1
                ),
                q = -1..1
              ):
#
# Generate the nearest-neighbour interaction
# matrix
#
  B:= Matrix(nR, nC, (i,j)-> N(i,j) );

Matrix(5, 5, {(1, 1) = 1, (1, 2) = 1, (1, 3) = 1, (1, 4) = -1, (1, 5) = 1, (2, 1) = -1, (2, 2) = -1, (2, 3) = -1, (2, 4) = 1, (2, 5) = -1, (3, 1) = -1, (3, 2) = -1, (3, 3) = 1, (3, 4) = 1, (3, 5) = -1, (4, 1) = 1, (4, 2) = -1, (4, 3) = 1, (4, 4) = -1, (4, 5) = 1, (5, 1) = -1, (5, 2) = -1, (5, 3) = -1, (5, 4) = -1, (5, 5) = 1})

 

Matrix(%id = 18446744074372383078)

(1)

 

Download ising.mw

Since you can trivially isolate the second derivative from the original ODE, all you have to do is to plot/calculate the relevant function,

ie y(t)-t*sin(5*t)

as in the attached

  restart;
  sol := dsolve( [ -diff(y(t), t$2)+y(t) = t*sin(5*t),
                   y(0)=0.2,
                   y(1)=1
                 ],
                 numeric
               );
plots:-odeplot( sol,
                [ [t, y(t)],
                  [t, diff(y(t),t)],
                  [t, -t*sin(5*t)+y(t)]
                ],
                t=0..1,
                color=[red, green, blue]
              );

proc (x_bvp) local res, data, solnproc, _ndsol, outpoint, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; _EnvDSNumericSaveDigits := Digits; Digits := 15; if _EnvInFsolve = true then outpoint := evalf[_EnvDSNumericSaveDigits](x_bvp) else outpoint := evalf(x_bvp) end if; data := Array(1..4, {(1) = proc (outpoint) local X, Y, YP, yout, errproc, L, V, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; X := Vector(8, {(1) = .0, (2) = .13356755121790845, (3) = .30430039984542584, (4) = .4711335427102931, (5) = .6262694366777036, (6) = .7636417442240576, (7) = .8856536401001731, (8) = 1.0}, datatype = float[8], order = C_order); Y := Matrix(8, 2, {(1, 1) = .2, (1, 2) = .6355472386901964, (2, 1) = .28679901058587776, (2, 2) = .6642172351157226, (3, 1) = .4026629349647905, (3, 2) = .6898565048786539, (4, 1) = .5191388059317775, (4, 2) = .7087686351481234, (5, 1) = .6327422107075403, (5, 2) = .7672375606410581, (6, 1) = .745854892367845, (6, 2) = .8933518491303937, (7, 1) = .8652730228741763, (7, 2) = 1.0741950607628237, (8, 1) = 1.0, (8, 2) = 1.2869514632712835}, datatype = float[8], order = C_order); YP := Matrix(8, 2, {(1, 1) = .6355472386901964, (1, 2) = .2, (2, 1) = .6642172351157226, (2, 2) = .2040819987788216, (3, 1) = .6898565048786539, (3, 2) = 0.987321747068094e-1, (4, 1) = .7087686351481234, (4, 2) = .18582163798963208, (5, 1) = .7672375606410581, (5, 2) = .6263258981104891, (6, 1) = .8933518491303937, (6, 2) = 1.2240154135287016, (7, 1) = 1.0741950607628237, (7, 2) = 1.7154194632259072, (8, 1) = 1.2869514632712835, (8, 2) = 1.9589242746631386}, datatype = float[8], order = C_order); errproc := proc (x_bvp) local outpoint, X, Y, yout, L, V, i; option `Copyright (c) 2000 by Waterloo Maple Inc. All rights reserved.`; Digits := 15; outpoint := evalf(x_bvp); X := Vector(8, {(1) = .0, (2) = .13356755121790845, (3) = .30430039984542584, (4) = .4711335427102931, (5) = .6262694366777036, (6) = .7636417442240576, (7) = .8856536401001731, (8) = 1.0}, datatype = float[8], order = C_order); Y := Matrix(8, 2, {(1, 1) = .0, (1, 2) = 0.13030464384801514e-6, (2, 1) = 0.1302535103026619e-7, (2, 2) = 0.14221614646911444e-6, (3, 1) = -0.4128469958203856e-7, (3, 2) = 0.15918945269923148e-6, (4, 1) = -0.7225809617070991e-7, (4, 2) = 0.11203207102741712e-6, (5, 1) = -0.5203959916725329e-7, (5, 2) = 0.648213485009814e-7, (6, 1) = -0.26104233388354814e-7, (6, 2) = 0.4841390359814309e-7, (7, 1) = -0.10238961917655763e-7, (7, 2) = 0.4628901322935305e-7, (8, 1) = .0, (8, 2) = 0.48876597274231683e-7}, datatype = float[8], order = C_order); if not type(outpoint, 'numeric') then if outpoint = "start" or outpoint = "left" then return X[1] elif outpoint = "right" then return X[8] elif outpoint = "order" then return 6 elif outpoint = "error" then return HFloat(1.5918945269923148e-7) elif outpoint = "errorproc" then error "this is already the error procedure" elif outpoint = "rawdata" then return [2, 8, [y(t), diff(y(t), t)], X, Y] else return ('procname')(x_bvp) end if end if; if outpoint < X[1] or X[8] < outpoint then error "solution is only defined in the range %1..%2", X[1], X[8] end if; V := array([1 = 4, 2 = 0]); if Digits <= trunc(evalhf(Digits)) then L := Vector(4, 'datatype' = 'float'[8]); yout := Vector(2, 'datatype' = 'float'[8]); evalhf(`dsolve/numeric/lagrange`(8, 2, X, Y, outpoint, var(yout), var(L), var(V))) else L := Vector(4, 'datatype' = 'sfloat'); yout := Vector(2, 'datatype' = 'sfloat'); `dsolve/numeric/lagrange`(8, 2, X, Y, outpoint, yout, L, V) end if; [t = outpoint, seq('[y(t), diff(y(t), t)]'[i] = yout[i], i = 1 .. 2)] end proc; if not type(outpoint, 'numeric') then if outpoint = "start" or outpoint = "left" then return X[1] elif outpoint = "method" then return "bvp" elif outpoint = "right" then return X[8] elif outpoint = "order" then return 6 elif outpoint = "error" then return HFloat(1.5918945269923148e-7) elif outpoint = "errorproc" then return eval(errproc) elif outpoint = "rawdata" then return [2, 8, "depnames", X, Y, YP] else error "non-numeric value" end if end if; if outpoint < X[1] or X[8] < outpoint then error "solution is only defined in the range %1..%2", X[1], X[8] end if; if Digits <= trunc(evalhf(Digits)) and (_EnvInFsolve <> true or _EnvDSNumericSaveDigits <= trunc(evalhf(Digits))) then V := array( 1 .. 6, [( 1 ) = (7), ( 2 ) = (0), ( 3 ) = (false), ( 4 ) = (false), ( 5 ) = (false), ( 6 ) = (false)  ] ); L := Matrix(7, 2, {(1, 1) = .0, (1, 2) = .0, (2, 1) = .0, (2, 2) = .0, (3, 1) = .0, (3, 2) = .0, (4, 1) = .0, (4, 2) = .0, (5, 1) = .0, (5, 2) = .0, (6, 1) = .0, (6, 2) = .0, (7, 1) = .0, (7, 2) = .0}, datatype = float[8], order = C_order); yout := Vector(2, {(1) = .0, (2) = .0}, datatype = float[8]); evalhf(`dsolve/numeric/hermite`(8, 2, X, Y, YP, outpoint, var(yout), var(L), var(V))) else if _EnvInFsolve = true then Digits := _EnvDSNumericSaveDigits end if; V := array( 1 .. 6, [( 1 ) = (7), ( 2 ) = (0), ( 3 ) = (false), ( 4 ) = (false), ( 5 ) = (false), ( 6 ) = (false)  ] ); L := Matrix(7, 2, {(1, 1) = 0., (1, 2) = 0., (2, 1) = 0., (2, 2) = 0., (3, 1) = 0., (3, 2) = 0., (4, 1) = 0., (4, 2) = 0., (5, 1) = 0., (5, 2) = 0., (6, 1) = 0., (6, 2) = 0., (7, 1) = 0., (7, 2) = 0.}, order = C_order); yout := Vector(2, {(1) = 0., (2) = 0.}); `dsolve/numeric/hermite`(8, 2, X, Y, YP, outpoint, yout, L, V) end if; [outpoint, seq(yout[i], i = 1 .. 2)] end proc, (2) = Array(0..0, {}), (3) = [t, y(t), diff(y(t), t)], (4) = 0}); solnproc := data[1]; if not type(outpoint, 'numeric') then if outpoint = "solnprocedure" then return eval(solnproc) elif member(outpoint, ["start", "left", "right", "errorproc", "rawdata", "order", "error"]) then return solnproc(x_bvp) elif outpoint = "sysvars" then return data[3] elif procname <> unknown then return ('procname')(x_bvp) else _ndsol := pointto(data[2][0]); return ('_ndsol')(x_bvp) end if end if; try res := solnproc(outpoint); [t = res[1], seq('[y(t), diff(y(t), t)]'[i] = res[i+1], i = 1 .. 2)] catch: error  end try end proc

 

 

 

 


 

Download odeProb.mw

redefines the function Sum(), so the minute you enter

with(SignalProcessing)

then Sum() will refer to the command SignalProcessing:-Sum()

If you need to access the "original, worksheet/default" Sum() command, then precede it with :-, as in teh following

restart;
with(SignalProcessing):
Sum(q^n, n=1..infinity); # this will error!!
:-Sum(q^n, n=1..infinity);  # but this won't

 

Another "workaround" - which really shouldn't be necessary!


 

restart;
with(plottools): with(plots):
V1,V2,V3,V4,V5,V6,V7,V8:=[0,-1,0],[0,0,0],[1,0,0],[1,-1,0],[0,-1,1],[0,0,1],[1,0,1],[1,-1,1]:  # The vertices of the cube
Faces:=[[V1,V4,V8,V5],[V5,V6,V7,V8],[V2,V3,V7,V6],[V1,V2,V3,V4],[V3,V4,V8,V7],[V1,V2,V6,V5]]: # The list of the faces
Colors:=[green, red,RGB(1, 0, 4),blue,grey,gold]: # The list of the colors
Cube[0]:=display([seq(polygon(Faces[i],color=Colors[i]),i=1..6)]):
 

nf:=16:
for n from 1 to 7 do
    F[n]:= t -> rotate(Cube[n-1],t, [[0,n-1,0],[1,n-1,0]]):
    Cube[n]:= rotate(Cube[n-1],-Pi/2, [[0,n-1,0],[1,n-1,0]]):
    A[n]:= display( [seq( F[n](-j*Pi/(2*nf)), j=0..nf)],
                    insequence=true,
                    scaling=constrained
                  );
od:
for m from 6 to 0 by -1 do
    G[m]:= t -> rotate(Cube[m+1],t, [[0,m,0],[1,m,0]]):
    B[m]:= display( [seq( G[m](j*Pi/(2*nf)), j=0..nf)],
                    insequence=true,
                    scaling=constrained
                  );
od:
C1:= display([seq(A[k], k=1..7)], insequence=true):
C2:= display([seq(B[k], k=6..0, -1)], insequence=true):
display([C1,C2], insequence=true, axes=normal);
 

 

 

 

 

 


 

Download anim.mw

as in the attached worksheet.

Notice that rand() essentially calls RandoomTools:-Generate() with some simple options (eg a unifomr distribution, etc). More control over the generation process can be obtained by calling RandoomTools:-Generate()  with specifc options

  restart;
#
# Use rand() to produce two random
# number generators, which return
# floats in the range -1..1, with
# a uniform distribution.
#
# The randomize() command ensure that
# a *different* sequence of numbers
# will be produced each time the
# worksheet is executed. If OP wants
# the *same* sequence of random numbers
# on each re-execution, then comment out
# the randomize() command
#
  randomize():
  X:=rand(-1.0..1.0);
  Y:=rand(-1.0..1.0);
#
# Use the above two generators to
# produce 20 "samples" from each
# generator
#
  seq( X(), i=1..20);
  seq( Y(), i=1..20);

proc () options operator, arrow; RandomTools:-Generate(float('range' = -1.0 .. 1.0, 'method' = 'uniform')) end proc

 

proc () options operator, arrow; RandomTools:-Generate(float('range' = -1.0 .. 1.0, 'method' = 'uniform')) end proc

 

-.233308012, .936469446, -.745674386, -.261000633, .246962027, .841672837, -.616302950, .794577573, .429781684, -0.68813690e-1, -.250318550, .473409299, -.869183630, .264171703, .591296331, .549672215, -.309929895, 0.24771005e-1, -.254816243, .400524284

 

-.262964446, -.350690589, .648167872, .872407721, .825366823, -.124811028, -.128839891, .910612260, -.315615228, -.447486216, .140515562, 0.80816815e-1, -.411982347, .751893218, .654970525, .598126461, -.141963404, -.508372677, -0.46081049e-1, -.690790791

(1)

 

 

Download getRand.mw

 

what you are trying to achieve. The ArrayTools:-Alias() command would normally be used to access "sub-arrays" of a Matrix/Vector, or perhaps a "re-ordering" of that Matrix/Vector. You appear to be creating a new 3-D Array.

Consider both of the methods in the attached - do you really need the first rather than the second?

NULL

restart

 

Wn := Array(0 .. 1, 0 .. 1, 1 .. 3); for n to 3 do Wn[0 .. 1, 0 .. 1, n] := n*ArrayTools:-Alias(Matrix(2, 2, {(1, 1) = 3, (1, 2) = 1, (2, 1) = 1, (2, 2) = 3}), [0 .. 1, 0 .. 1]) end do

Wn[0 .. 1, 0 .. 1, 1]; Wn[0 .. 1, 0 .. 1, 2]; Wn[0 .. 1, 0 .. 1, 3]

Array(%id = 18446744074393609030)

 

Array(%id = 18446744074393605054)

 

Array(%id = 18446744074393600478)

(1)

restart

 

Wn := Array(0 .. 1, 0 .. 1, 1 .. 3); for n to 3 do Wn[0 .. 1, 0 .. 1, n] := n*(Matrix(2, 2, {(1, 1) = 3, (1, 2) = 1, (2, 1) = 1, (2, 2) = 3})) end do

Wn[0 .. 1, 0 .. 1, 1]; Wn[0 .. 1, 0 .. 1, 2]; Wn[0 .. 1, 0 .. 1, 3]

Array(%id = 18446744074393608670)

 

Array(%id = 18446744074393604694)

 

Array(%id = 18446744074393600118)

(2)

 

NULL


 

Download AT.mw

which fail to address the basic issue.

For the OP's problem

Maple 18     is just plain wrong
Maple 2015 is just plain wrong
Maple 2016 is just plain wrong
Maple 2017 is correct
Maple 2018 is just plain wrong

See the attachments below

restart;

interface(version);
interface(displayprecision=4);
123.456789;

`Standard Worksheet Interface, Maple 18.02, Windows 7, October 20 2014 Build ID 991181`

 

-1

 

123.456789

(1)

 

restart;

interface(version);
interface(displayprecision=4);
123.456789;

`Standard Worksheet Interface, Maple 2015.2, Windows 7, December 21 2015 Build ID 1097895`

 

-1

 

123.456789

(1)

 

restart;

interface(version);
interface(displayprecision=4);
123.456789;

`Standard Worksheet Interface, Maple 2016.2, Windows 7, January 13 2017 Build ID 1194701`

 

4

 

123.456789

(1)

 

restart;

interface(version);
interface(displayprecision=4);
123.456789;

`Standard Worksheet Interface, Maple 2017.3, Windows 7, September 13 2017 Build ID 1262472`

 

4

 

123.456789

(1)

 

restart;

interface(version);
interface(displayprecision=4);
123.456789;

`Standard Worksheet Interface, Maple 2018.1, Windows 7, June 8 2018 Build ID 1321769`

 

4

 

123.456789

(1)

 

Download prec2018.mw

Download prec2017.mw

Download prec2016.mw

Download prec2015.mw

Download prec18.mw

in what format you want the resulting roots. I actually found it simpler to define your 'map' as a vector with three entries, then it is simple to obtain 'roots' as a vector with three entries.

When you want to all possible values of expressions involving RootOfs - then the allvaalues() command is usually the way to go.

See the attached

restart;
LambdaMap := Vector(3,
             [RootOf(kh[a2]*_Z^2+(-R[b]*kh[a2]-R[m]*kh[a2]+Rh[m]*kh[a2]+2*kh[a2]*x[2])*_Z-2*k[a2]*x[1]*x[2]-k[a2]*x[1]^2+k[a2]*x[1]*R[b]+2*kh[d2]*x[2]-2*k[d2]*x[2]),
              x[2],
              x[1]+x[3]-RootOf(kh[a2]*_Z^2+(-R[b]*kh[a2]-R[m]*kh[a2]+Rh[m]*kh[a2]+2*kh[a2]*x[2])*_Z-2*k[a2]*x[1]*x[2]-k[a2]*x[1]^2+k[a2]*x[1]*R[b]+2*kh[d2]*x[2]-2*k[d2]*x[2])
             ]
             );
rts:=allvalues~(eval(LambdaMap, [x[1]=0, x[2]=0, x[3]=0]));

Vector(3, {(1) = RootOf(kh[a2]*_Z^2+(-R[b]*kh[a2]-R[m]*kh[a2]+Rh[m]*kh[a2]+2*kh[a2]*x[2])*_Z-2*k[a2]*x[1]*x[2]-k[a2]*x[1]^2+k[a2]*x[1]*R[b]+2*kh[d2]*x[2]-2*k[d2]*x[2]), (2) = x[2], (3) = x[1]+x[3]-RootOf(kh[a2]*_Z^2+(-R[b]*kh[a2]-R[m]*kh[a2]+Rh[m]*kh[a2]+2*kh[a2]*x[2])*_Z-2*k[a2]*x[1]*x[2]-k[a2]*x[1]^2+k[a2]*x[1]*R[b]+2*kh[d2]*x[2]-2*k[d2]*x[2])})

 

Vector[column](%id = 18446744074382999910)

(1)

 

Download roots.mw

 

 

There is a "time-honoured tradition" in Windows applications that any menu entry can be acessed by using the Alt key followed by the underlined character in the menu name , followed by the underlined character in the menu entry (which may result in a sub-menu) and so on ad infinitum.

Adopting this approach, enclosing something within a section becomes

  1. Select what you want to be in a sub-section
  2. Alt+I+S (that's Insert->Section)

If you just use Alt+I+S without selecting anything, then Maple will insert a new section after the current cursor position.

In fact this is such a common thng to do, that

  1. it has its own toolbar icon - try entering 'worksheet toolbar' in the Maple help search field, to see what all the toolbar icons actually do.
  2. It also has a "Maple-specific" shortcut CTRL+. (that's CTRL+period). You can see this "Maple-specific" shortcut by entering 'worksheet hotwin' in the Maple help search field

"Maple-specific" shortcuts is a bit of misnomer, because some of these are not specific to Maple -some of them are just stuff you would expect to work.

As a trivial example take cut+paste: using the menu-search method described above, this would be Alt+E+t followed by Al+E+P which does work, but I'm guessing that you (like me!) would prefer CTRL+X/CTRL+C, so obviously Maple implements this as well

Expanding and collapsing sections

In the Maple Help window, that would be View->Expand All Sections, or Alt+V+E. This does illustrate a minor issue with this "traditional" menu-search method, because the same operation in a Maple worksheet window would be View->Sections->Expand All Sections, which would be Alt+V+i+E. Nothing much can be done about this: different windows will have different menus, with different entries, so the keyboard sequence for the same command may be different:-(

I have been unable to replicate the problem of 'clicking' on the section marker to open/close. For me this always works: can only suggest a better mouse?

 

 

is a command in the signal processing package.

If you wish to use the "default" meaning for Sum() whilst having the Signal Processing package loaded, then prefix the command with ':-', as in the attached

NULL

with(LinearAlgebra); with(VectorCalculus); with(Student[LinearAlgebra]); with(SignalProcessing); with(Statistics); with(stats)

u[1] := :-Sum(:-Sum(-delta*(t+1)*alpha^2*(1-alpha)^(t+T)/(t+1+lambda[2]*(T+1)/lambda[1]), T = 0 .. 100), t = 0 .. 100)

Sum(Sum(-delta*(t+1)*alpha^2*(1-alpha)^(t+T)/(t+1+lambda[2]*(T+1)/lambda[1]), T = 0 .. 100), t = 0 .. 100)

(1)

u[2] := :-Sum(:-Sum((t+1)*alpha^2*(1-alpha)^(t+T)/(t+1+lambda[2]*(T+1)/lambda[1]), T = 0 .. 100), t = 0 .. 100)

Sum(Sum((t+1)*alpha^2*(1-alpha)^(t+T)/(t+1+lambda[2]*(T+1)/lambda[1]), T = 0 .. 100), t = 0 .. 100)

(2)

NULL

Download sumTrouble.mw

  1.  That is, Sum(....), rather than sum(...)
  2. if subsequently, evalf(Sum(...)) leads to a complex value then there are two possibilities
    1. something about the summand means that complex values are unavoidable
    2. if the sum *shouldn't" return a complex value, then it is possible that some combination of simplify() and evalc() will "remove" the maginary term
  3. One can (usually) differentiate an infinite inert sum - although this will probably depend on the nature of the summand, so, for example, the following "toy" example will work

S:=Sum(x^2/n, n=1..infinity);
diff(S, x);

Difficult to be sure about any/all of the above unless you upload a specific example

It really ought  to be possible to achieve this using the location sub-option of the axis[1] option, ie

plot(.......axis[1]=[location=0.0]

but the location sub-option does not accept a numeric value ;-(

Even setting the combination smartview=false, axis[1]=[location=origin] won't help ;-(

So I see no option but "spoofing" it by defining an "additional" function whose value is zero for all x. This will plot an extra curve along the x-axis, but you can ensure that this is "invisible", by setting its color=white. Clunky, I know: see the attached

plot([0, piecewise( x<5, 100, x>5,200)], x=0..10, color=[white,red]);

 

 

 

Download plotAxis.mw

but also the Physics:-Setup() command appears to be more sensitive (than I would expect) to the order of declaration of its options

Syntax issues are stuff like sin^2*theta, rather than sin(theta)^2; use of e^ rather than exp(), and maybe a few othere which I have forgotten.

Having fixed the above the attached shows eight possibilities for the required Setup(), four using 1-D match input (becuase this was how I debugged your problem) and four using 2-D math input.

I would have expected all of these to work, but only half of them do. I can only assume that this has something to do with the "order" in which options passed to the Setup() command are processed.

#
# I would have expected this to work - but it
# doesn't!
#
  restart;
  with(Physics):
  Setup( mathematicalnotation = true,
         coordinatesystems = spherical,
         metric=-a*d_(t)^2+exp(lambda(t, R))*d_(r)^2+r(t, R)^2*d_(theta)^2+(r(t, R)*sin(theta)*d_(phi))^2
       );

Error, (in Physics:-d_) differentiation variables for dAlembertian, d_ and D_ are not defined; either use Setup(differentiationvariables =  ...) to set them, or indicate the differentiation variables as a second argument to dAlembertian

 

#
# Try setting mathematicalnotation=true, separately.
#
# No - still doesn't work
#
  restart;
  with(Physics):
  Setup( mathematicalnotation = true);
  Setup( coordinatesystems = spherical,
       metric=-a*d_(t)^2+exp(lambda(t, R))*d_(r)^2+r(t, R)^2*d_(theta)^2+(r(t, R)*sin(theta)*d_(phi))^2
     );

[mathematicalnotation = true]

 

Error, (in Physics:-d_) differentiation variables for dAlembertian, d_ and D_ are not defined; either use Setup(differentiationvariables =  ...) to set them, or indicate the differentiation variables as a second argument to dAlembertian

 

#
# Try setting both the mathematicalnotation and
# coordinatesystems separately.
#
# This does work!
#
  restart;
  with(Physics):
  Setup( mathematicalnotation = true,
         coordinatesystems = spherical
       );
  Setup(metric= -a*d_(t)^2+exp(lambda(t, R))*d_(r)^2+r(t, R)^2*d_(theta)^2+(r(t, R)*sin(theta)*d_(phi))^2);

`Default differentiation variables for d_, D_ and dAlembertian are:`*{X = (r, theta, phi, t)}

 

`Systems of spacetime Coordinates are:`*{X = (r, theta, phi, t)}

 

[coordinatesystems = {X}, mathematicalnotation = true]

 

[metric = {(1, 1) = exp(lambda(t, R)), (2, 2) = r(t, R)^2, (3, 3) = r(t, R)^2*sin(theta)^2, (4, 4) = -a}]

(1)

#
# Try setting both the mathematicalnotation and
# coordinatesystems separately.
#
# Define the metric separately
#
# This works as well!
#
  restart;
  with(Physics):
  Setup( mathematicalnotation = true,
         coordinatesystems = spherical
       );
  ds2:=-a*d_(t)^2+exp(lambda(t, R))*d_(r)^2+r(t, R)^2*d_(theta)^2+(r(t, R)*sin(theta)*d_(phi))^2:
  Setup(metric=ds2 );

`Default differentiation variables for d_, D_ and dAlembertian are:`*{X = (r, theta, phi, t)}

 

`Systems of spacetime Coordinates are:`*{X = (r, theta, phi, t)}

 

[coordinatesystems = {X}, mathematicalnotation = true]

 

[metric = {(1, 1) = exp(lambda(t, R)), (2, 2) = r(t, R)^2, (3, 3) = r(t, R)^2*sin(theta)^2, (4, 4) = -a}]

(2)

restart; with(Physics); Setup(mathematicalnotation = true, coordinatesystems = spherical, metric = -Physics:-`*`(a, Physics:-`^`(d_(t), 2))+Physics:-`*`(exp(lambda(t, R)), Physics:-`^`(d_(r), 2))+Physics:-`*`(Physics:-`^`(r(t, R), 2), Physics:-`^`(d_(theta), 2))+Physics:-`^`(Physics:-`*`(Physics:-`*`(r(t, R), sin(theta)), d_(phi)), 2))

Error, (in Physics:-d_) differentiation variables for dAlembertian, d_ and D_ are not defined; either use Setup(differentiationvariables =  ...) to set them, or indicate the differentiation variables as a second argument to dAlembertian

 

restart; with(Physics); Setup(mathematicalnotation = true); Setup(coordinatesystems = spherical, metric = -Physics:-`*`(a, Physics:-`^`(d_(t), 2))+Physics:-`*`(exp(lambda(t, R)), Physics:-`^`(d_(r), 2))+Physics:-`*`(Physics:-`^`(r(t, R), 2), Physics:-`^`(d_(theta), 2))+Physics:-`^`(Physics:-`*`(Physics:-`*`(r(t, R), sin(theta)), d_(phi)), 2))

[mathematicalnotation = true]

 

Error, (in Physics:-d_) differentiation variables for dAlembertian, d_ and D_ are not defined; either use Setup(differentiationvariables =  ...) to set them, or indicate the differentiation variables as a second argument to dAlembertian

 

restart; with(Physics); Setup(mathematicalnotation = true, coordinatesystems = spherical); Setup(metric = -Physics:-`*`(a, Physics:-`^`(d_(t), 2))+Physics:-`*`(exp(lambda(t, R)), Physics:-`^`(d_(r), 2))+Physics:-`*`(Physics:-`^`(r(t, R), 2), Physics:-`^`(d_(theta), 2))+Physics:-`^`(Physics:-`*`(Physics:-`*`(r(t, R), sin(theta)), d_(phi)), 2))

`Default differentiation variables for d_, D_ and dAlembertian are:`*{X = (r, theta, phi, t)}

 

`Systems of spacetime Coordinates are:`*{X = (r, theta, phi, t)}

 

[coordinatesystems = {X}, mathematicalnotation = true]

 

[metric = {(1, 1) = exp(lambda(t, R)), (2, 2) = r(t, R)^2, (3, 3) = r(t, R)^2*sin(theta)^2, (4, 4) = -a}]

(3)

restart; with(Physics); Setup(mathematicalnotation = true, coordinatesystems = spherical); ds2 := -Physics:-`*`(a, Physics:-`^`(d_(t), 2))+Physics:-`*`(exp(lambda(t, R)), Physics:-`^`(d_(r), 2))+Physics:-`*`(Physics:-`^`(r(t, R), 2), Physics:-`^`(d_(theta), 2))+Physics:-`^`(Physics:-`*`(Physics:-`*`(r(t, R), sin(theta)), d_(phi)), 2); Setup(metric = ds2)

`Default differentiation variables for d_, D_ and dAlembertian are:`*{X = (r, theta, phi, t)}

 

`Systems of spacetime Coordinates are:`*{X = (r, theta, phi, t)}

 

[coordinatesystems = {X}, mathematicalnotation = true]

 

[metric = {(1, 1) = exp(lambda(t, R)), (2, 2) = r(t, R)^2, (3, 3) = r(t, R)^2*sin(theta)^2, (4, 4) = -a}]

(4)

 

Download PhysicsSetup.mw

See the following "toy" example

  restart;

#
# Consider a toy example and find all roots
#
  expr:=x^2-3*x+1=0;
  fsolve(expr);

x^2-3*x+1 = 0

 

.3819660113, 2.618033989

(1)

#
# Now search for the roots of the above
# expression in the ranges, 0..1, 1..2,
# and 2..3. Place the output results in
# a sequence. Note that there is no root
# in the range 1..2, so "trap" this case
# and do something "different". For
# illustrative purposes, the value 555 is
# entered into the sequence of "roots"
#
  aSeq:=NULL:
  for j from 0 by 1 to 2 do
      ans:=fsolve(expr, x=j..j+1):
      if   ans=NULL
      then ans:=555
      fi:
      aSeq:=aSeq,ans
  od:
  aSeq;

.3819660113, 555, 2.618033989

(2)

 

Download NULLroots.mw

 

First 126 127 128 129 130 131 132 Last Page 128 of 207