Scot Gould

Scot Gould

747 Reputation

14 Badges

11 years, 171 days
Claremont McKenna, Pitzer, Scripps College
Professor of Physics
Upland, California, United States
Dr. Scot Gould is a professor of physics in the W.M. Keck Science Department of Claremont McKenna, Pitzer, and Scripps Colleges - members of The Claremont Colleges in California. He was involved in the early development of the atomic force microscope. His research has included numerous studies and experiments using scanning probe microscopes, particularly those involving natural fibers such as spider silk. More recently, he was involved in developing and sustaining AISS. This full-year multi-unit, non-traditional, interdisciplinary undergraduate science education course integrated topics from biology, chemistry, physics, mathematics, and computer science. His current interest is integrating computational topics into the physics curriculum. He teaches the use of Maple's computer algebraic and numerical systems to assist students in modeling and visualizing physical and biological systems. His Dirac-notation-based quantum mechanics course is taught solely through Maple.

MaplePrimes Activity


These are answers submitted by Scot Gould

If you are trying to put the (1) as the superscript of A, this works for me using 2d Input:

plots:-textplot([3, 3, A^[1](x)])

restart

Generic ode, which is a function of the ode number:

ode := diff(y(x), x)+n*y(x) = 0

Three odes to solve. Initial conditions provided.

N := 3; y__0 := [a, b, c]; sols := Vector(N)

Loop to generate solutions

for n to N do ice := y(0) = y__0[n]; sols[n] := dsolve({ice, ode}) end do

Report the solutions

sols

Vector[column](%id = 36893489822526843108)

(1)

Download MaplePrimes_dsolve_in_a_loop.mw

I have a few suggestions for reducing the time you experience debugging a problem.

 

1) Normally, in each execution group, write out a single expression with the ";" character at the end to make sure it gets printed.

2) Read the error statement carefully. I agree, Maple error statements can often be confusing, but this one says it pretty clearly - the input is not of the correct format.

 

For dsolve, it expects a set or list of equations.  {}  means a set. [ ] means a list.

 

3) Since you have palettes, I recommend that you take advantage of them. However, I will not so that I repeat as much as you have written,

restart


Write out a sequence of equations, i.e., each equation separately,

OdeSys := F1*(diff(U(Y), Y, Y))/F2+F3*Theta(Y)+N*F4*Theta(Y)*Theta(Y)-(F5*M*M)*U(Y)/F2 = 0, F6*(diff(Theta(Y), Y, Y))/F7 = 0

F1*(diff(diff(U(Y), Y), Y))/F2+F3*Theta(Y)+N*F4*Theta(Y)^2-F5*M^2*U(Y)/F2 = 0, F6*(diff(diff(Theta(Y), Y), Y))/F7 = 0

(1)

 

Writing out a sequence of condition equations

 

Cond := U(0) = la*(D(U))(0), Theta(0) = C1+ga*(D(Theta))(0), U(1) = 0, Theta(1) = D1

U(0) = la*(D(U))(0), Theta(0) = C1+ga*(D(Theta))(0), U(1) = 0, Theta(1) = D1

(2)

 

4) It is best to create a variable that is the output from Maple. Then, it is easier to reference your answers.  


For your problem, notice that the sequence of equations are now all inside the set { } inside the call to dsolve.

solutions := dsolve({Cond, OdeSys})

Note - your answers are not written out because they are long.

 

5) Since you don't know the order of the output, use eval to reference the results.  The procedure allows you to evaluate for the function of interest from the solutions.

 

U_exact := eval(U(Y), solutions); Theta_exact := eval(Theta(Y), solutions)

-Y*(C1-D1)/(1+ga)+(D1*ga+C1)/(1+ga)

(3)

 

6) Unless you use Maple every day, I suggest using a more intuitively named function to make a function from an expression, MakeFunction.

 

U_exact := MakeFunction(U_exact, Y); Theta_exact := MakeFunction(Theta_exact, Y)

proc (Y) options operator, arrow; -Y*(C1-D1)/(1+ga)+(D1*ga+C1)/(1+ga) end proc

(4)

Hopefully some of the suggestions do help you solve Maple problems more efficiently.

Download MaplePrimes_ODE_problem.mw

The problem with the document. is that when you create a variable, sometimes you use atomic variables, which are a variable that possesses a subscript, and sometimes you use an indexed variable, such as the nth element of a vector.

 

It is very easy to tell the difference between the two.

 

To create an atomic variable with a subscript of 110, either write 'name__110', which generates this output:

name__110

name__110

or click on this icon in the Expression Palette:

a__n

(Now fill in the 'a' and the 'n'.)

 

To create an indexed variable, either write 'name[110]' which generates this effect:

name[110]

name[110]

or click on this icon in the Expression Palette:

a[n]

 

By looking at the subscript, you can immediately tell that `#msub(mi("name",fontweight = "bold"),mi("110",fontweight = "bold"))` is not the same as name[110]. The atomic variable possesses an italicized subscript, while the indexed does not.

 

Since you are not creating a vector Q or a vector β, my recommendation:

 

a) Don't bother with subscripts. Hence, if you need Q__110 , call the variable Q110.
b) Or, if you are going to use subscripts, only use atomic variables: a__n. If you want to identify which are atomic variables and which are not, from the menu bar, select "View "->" Atomic Variables".

 

I also recommend switching from using Document mode to using Worksheet mode. When you are experienced with Maple, a Maple document is fantastic. Until then, it tends to lead to more problems.

Are you sure you read the question properly?

 

2a) Plot the function in 3d:

 

"f(x,y) := (sin(x))/(x) + (sin(y))/(y) :  "

plot3d(f(x, y), x = -3*Pi .. 3*Pi, y = -3*Pi .. 3*Pi, size = [500, 500])

 

2b) Limit:

 

limit(limit(f(x, y), y = 0), x = 0)

2

(1)

Download Limit_problem._.mw

Explore procedure will not plot in MaplePrimes, so download the file.

restart

 

Basic SIR model

odes := diff(s(t), t) = -k*s(t)*i(t), diff(i(t), t) = k*s(t)*i(t)-K*i(t), diff(r(t), t) = K*i(t)

Initial condition equations where 1 = 100% of the population.  

ices := s(0) = 1-i0, i(0) = i0, r(0) = 0

 

Numerically solve with parameters to be modified later.

 

solutions := dsolve({ices, odes}, parameters = [k, K, i0], numeric, output = listprocedure)


Extract solutions

s := eval(s(t), solutions); i := eval(i(t), solutions); r := eval(r(t), solutions)

 

Simple example where
"k = 0.1, K = 0.01, i0 = 1E-10.  "

Assign the parameters some values and then plot.

solutions(parameters = [k = .1, K = 0.1e-1, i0 = 0.1e-2])

plot([s(t), i(t), r(t)], t = 0 .. 600, legend = ['s(t)', 'i(t)', 'r(t)'], thickness = [2, 4, 6])

 

Explore the results

1) Create a procedure that substitutes the values sent to it via the Explore procedure into the parameters and then plots.
2) Create an Explore of the Plot procedure.

 

Plot_SIR := proc (k0, K0, i00) solutions(parameters = [k = k0, K = K0, i0 = i00]); plot([s(t), i(t), r(t)], t = 0 .. 1000, legend = ['s(t)', 'i(t)', 'r(t)'], thickness = [2, 4, 6]) end proc

Explore(Plot_SIR(k, K, i0), parameters = [k = 0.1e-1 .. .1, K = 0.5e-2 .. 0.2e-1, i0 = 0.1e-4 .. 0.1e-2], initialvalues = [k = 0.4e-1, K = 0.16e-1, i0 = 0.5e-3])

 

Slide the sliders to vary the constants.

Download SIR_explore_example.mw

Motivated by a very old balance....
 

f := sin((a+(1/10)*a10ths+(1/100)*a100ths)*x)*exp(-(a+(1/10)*a10ths+(1/100)*a100ths)*x)

Explore(plot(f, x = 0 .. 5), parameters = [a = 0 .. 10, a10ths = 0 .. 9, a100ths = 0 .. 9], initialvalues = [a = 1, a10ths = 0, a100ths = 0])


 

Download Explore_fine_detail.mw

Your goal is to make a function from an expression. Hence, the "MakeFunction" procedure is what you need. 

restart

expression := 3.5+4.8*x

3.5+4.8*x

(1)

a := MakeFunction(3.5+4.8*x, x)

proc (x) options operator, arrow; 3.5+4.8*x end proc

(2)

a(24)

118.7

(3)

b := MakeFunction(expression, x)

proc (x) options operator, arrow; 3.5+4.8*x end proc

(4)

b(24)

118.7

(5)

NULL

Download MakeFunction.mw

This may be the single greatest procedure Maplesoft has created in decades. (Available only on version 2023 and greater. So, pay for the upgrade if you can. If you can't, create an alias, alias(MakeFunction = unapply)

Since I don't know what this looks like, let's make a collection of space curve.

 

Copy your text data:

 

restart; xData := [0., 0.4995839572e-1*sin(x), 0.9966865249e-1*sin(x), .1488899476*sin(x), .1973955598*sin(x), .2449786631*sin(x), .2914567945*sin(x), .3366748194*sin(x), .3805063771*sin(x), .4228539261*sin(x), .4636476090*sin(x), .5028432109*sin(x), .5404195003*sin(x), .5763752206*sin(x), .6107259644*sin(x), .6435011088*sin(x), .6747409422*sin(x), .7044940642*sin(x), .7328151018*sin(x), .7597627549*sin(x), .7853981634*sin(x)]


Match with t with the same number of point.

tData := [seq(0.5e-1*n, n = 0 .. upperbound(xData)-1)]

 

Create a function (using the older version of the MakeFunction procedure) from the data:

 

xtPoint := unapply([x, xData[n], tData[n]], x, n)

And from each point, make a spaaaaace curve.

 

xtLine := unapply([seq(xtPoint(x, n), n = 1 .. upperbound(tData))], x)

 

Next, a generic plot of a collection of space curves

 

plots:-spacecurve(xtLine(x), x = -Pi .. Pi, size = [500, 500], color = "xkcd:blue", thickness = 3, labels = ["x", "xData", "tData"], labelfont = ["Times New Roman", 15], orientation = [84, 21, 160])

 


Low-budget version of 3D surface data.

 

Creating a sequence of points without the option numpoints in the sequence function.

From it, we make "Let's go surfing now; everybody is learning how" data.

N := 100; x0 := -Pi; xf := Pi; dX := (xf-x0)/(N-1); surfData := [seq(xtLine(dX*n+x0, round(n*upperbound(xData)/N+1)), n = 0 .. N-1)]

And plot

 

plots:-surfdata(surfData, labels = ["x", "xData", "tData"], labelfont = ["Times New Roman", 15], orientation = [84, 21, 160], size = [500, 500])

 

Note bug in 3D plot. Need to report.

``


 

Download My_3d_plot.mw

Of course, if you don't understand how to use the palettes, that is a different issue. 

Write out A^T as B and each component of the matrix.

 

restart; B := Matrix(2, 2, {(1, 1) = a__11, (1, 2) = a__21, (2, 1) = a__12, (2, 2) = a__22}); I2x2 := Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = 0, (2, 2) = 1}); equation1 := 4/(B+2*I2x2) = (Matrix(2, 2, {(1, 1) = 1, (1, 2) = 1, (2, 1) = -3/2, (2, 2) = 1/2}))

Matrix(2, 2, {(1, 1) = a__11, (1, 2) = a__21, (2, 1) = a__12, (2, 2) = a__22})

 

Matrix(2, 2, {(1, 1) = 1, (1, 2) = 0, (2, 1) = 0, (2, 2) = 1})

 

Matrix(%id = 36893490656581279980) = Matrix(%id = 36893490656581280100)

(1)

 

Solve for each component.

 

answer := solve(equation1, {a__11, a__12, a__21, a__22})

{a__11 = -1, a__12 = 3, a__21 = -2, a__22 = 0}

(2)

 

Assign each component the value in answer and then write out A

 

assign(answer); A := Matrix(2, 2, {(1, 1) = a__11, (1, 2) = a__12, (2, 1) = a__21, (2, 2) = a__22})

Matrix(%id = 36893490656581256964)

(3)

NULL


Download Matrix_Question.mw

Windows: From the menu bar, select Tools followed by Options

Mac: Select Preferences from the menu bar. 

On the first tab, at the bottom of the display, search for auto save every X minutes. Personally, I turn off keep files. I want to keep only those files for which Maple was shut down mid-calculation.  

 

Check out shortcuts in help. Ctrl-d might work since it deletes all output.

Export has a problem in Windows that is corrected by choosing to print to a PDF. Not as convenient, but it fixes the problem. I suggest you try that.

I prefer to use the elementwise operator ~. I find it more readable than using map.

outList := lhs~(eq1)

 

My guess is that the variable x has been assigned a value of 1.71. So, use a different variable in your plot

  plot(f(x1), x1 = -0.667 .. 1.71, -5..20, gridlines)

No need to label the vertical axis because it really isn't the variable in the vertical direction. 

1 2 3 4 5 6 7 Page 3 of 7