Scot Gould

Scot Gould

912 Reputation

14 Badges

11 years, 294 days
Claremont McKenna, Pitzer, Scripps College
Professor of Physics
Upland, California, United States
Dr. Scot Gould is a professor of physics at 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

Uninstall and reinstall to version 2021.1  Just a suggestion if possible.

One can control the number format given that the default is 3 values after the decimal, but it appears that changing the Digits does nothing. I have attempted to reproduce Figure 3.7 at the bottom of page 11. 

Regardless, I would hope the next version allows for one to change the interface

If you have several lines of code, you can insert a code-edit-region into your worksheet with the icon to the left of the "T" icon in the icon toolbar. Then, copy and paste the 2d-Math into the code-edit-region.  When you hit enter, it executes.

I was not able to reproduce this error.

However, to work with complex numbers in MapleFlow, the expression is 1+2i, not 1+2*i. (Also, 1+2I is viewed as 1+2i). If one types 1+2*i, MapleFlow interprets the letter "i" as a variable. 

What I don't understand is given that the letter "I" is defined as sqrt(-1) in Maple, why the expression (1+2*I) in MapleFlow is not interpreted as a complex number. Instead, "I" is interpreted as a variable. 

(And I don't understand why my pasted response can't be unbolded.) 
 

Carl Love is spot on with his response. And I appreciate the fact he listed a help page for more reference.

 

I'm adding my comments because I sense you are a new user.  Even as an experienced user of Maple, I found learning about DataFrames as, well, not always intuitive. However, now I find DataFrames are wonderful. They are far more useful and powerful than trying to work with spreadsheets. (Alternatively, you can work with R, yet another programming language.)

 

The reason I suspect you are a new user is because you are using 2d Input with the Document mode, Hence I have some suggestions, which you are welcome to ignore.

 

* Until you become an expert, I encourage you to switch to "Worksheet" mode. Go to "Tools" -> "Option", select "Interface" tab and choose "Worksheet" option under "Default format for new worksheets".  

 

"Document" mode is great for writing... documents. They were was heavily used at the recent Maple Conference of 2021:

        https://www.maplesoft.com/mapleconference/2021/agenda.aspx  

And, in the new journal "Maple Transactions":  https://mapletransactions.org/index.php/maple.   

 

But for general use, most new users I work with usually find worksheet mode useful in organizing their ...work.

 

* Maplesoft has a useful guide to DataFrames. See:

      https://www.maplesoft.com/support/help/Maple/view.aspx?path=DataFrame%2fGuide

 

* Two possibly useful examples of working with DataFrames can be found at these postings:

  - https://www.mapleprimes.com/posts/209845-Dataframes--Looking-For-A-New-Flashlight

  - https://www.mapleprimes.com/posts/213367-Timely-DataFrames-Example-2020-US-Presidential

 

 With regards to your problem,

1) may I suggest you reduce some of your work by "Import"ing directly from the CSV file from the website (rather than downloading it first to a separate file.)

 

restart; with(Statistics); rawdata := Import("https://health-infobase.canada.ca/src/data/covidLive/covid19-download.csv")

 

2) In terms of the question you ask, as an alternative to Carl Love's answer,  you may want to refer to the select/remove question in Maplesoft's "A Guide to Data Frames".  https://www.maplesoft.com/support/help/Maple/view.aspx?path=DataFrame%2fGuide#SelectRemoveValues

 

In this example, you want to "select" all data for which the value in the prname column of rawdata for is equivalent to name = "Ontario". Hence you want to evaluate (as a boolean) if the name in the column is "Ontario".

 

ont_data := select(proc (name) options operator, arrow; evalb(name = "Ontario") end proc, rawdata, prname)

module DataFrame () description "two-dimensional rich data container"; local columns, rows, data, binder; option object(BaseDataObject); end module

(1)

NULL

Download DataFrames_Select.mw

I won't solve your problem, but I get you started with the Maple problem - Explore command. You are missing the "parameters" parameter. (I also suggest adding the "initialvalues" parameter.")  The trough appears correctly for only certain values, so you might want to check the equations. (I added a bogus area function.) If you don't like the area in the caption, it could be put into the title. Trough.mw

Excuse the jpeg, but Mapleprimes will not display the 2021.1 code. 

 

Download simplify_example.mw

 

The protocal is to have Maple solve for y(t) and diff(y(t), t) and use the definition of diff(y(t), t, t) to plot both it and higher order derivatives. Kitonum's answer is the most efficient, but this one allows the reader to see how high order derivatives are generated.

(Note: I wrote this in Document mode with 2021 to try it out.)NULL

 

restart; plots:-setoptions(size = [500, 300], thickness = 2)

 

The second derivative of y(t) with respect to t is defined as:

"y2dot(t):=-y(t)*|y(t)|:"

 

Create the system:

ode := diff(y(t), t, t) = y2dot(t)
conditions := y(0) = 1, (D(y))(0) = 0

diff(diff(y(t), t), t) = -y(t)*abs(y(t))

(1)

 

I prefer to have Maple generate the procedures for each variables because it makes subsequent use of the "functions" more readable (and requires fewer commands to memorize)

solutions := dsolve({ode, conditions}, numeric, output = listprocedure)

 

Extract the functions from the solutions variable

y := eval(y(t), solutions); ydot := eval(diff(y(t), t), solutions)

 

plot([y(t), ydot(t), y2dot(t)], t = 0 .. 10, legend = ['y(t)', 'diff(y(t), t)', 'diff(y(t), t, t)'])

 

 

Calculate all higher derivatives which are defined in terms of lower derivatives. For example:

Y3dot := simplify(diff(y2dot(t), t)); Y4dot := simplify(diff(Y3dot, t))

(-abs(1, y(t))*y(t)-abs(y(t)))*(diff(diff(y(t), t), t))-(diff(y(t), t))^2*(y(t)*signum(1, y(t))+2*abs(1, y(t)))

(2)

NULL

 

Thus the higher order derivative functions are defined as:

"y3dot(t) :=-ydot(t)*(abs(1,y(t))*y(t)+|y(t)|):    y4dot(t):=(-abs(1,y(t)) y(t)-|y(t)|)*(y2dot(t))                            -(ydot(t))^2 *(y(t)* signum(1,y(t))+2*abs(1,y(t))):"

 

plot([y(t), y3dot(t), y4dot(t)], t = 0 .. 10, legend = ['y(t)', 'diff(y(t), t, t, t)', 'diff(y(t), t, t, t, t)'])

 

NULL


 

Download Plotting_higher_derivatives_numerically.mw

I think if the conditions are satisfied, it is solvable. I rewrote the integral in the form of constants. 

print(G) is probably the simpliest to show all the values within G. 

@tomleslie's was spot on. May I suggest an slight modification when you use dsolve - use the "output = listprocedure". Then you can extract out the procedure for x(t) and use it like a function. 

For fun, I tried out your toy problem. In the end, I agree with Tom - I don't see the difference and neither does Maple. I used pdsolve, not dsolve. 
 

restart

 

Write out differential equation and boundary value conditions

eq := diff(u(x), x, x) = u(x); bvc := u(0) = 2, u(1) = 1

sol := pdsolve({bvc, eq})

u(x) = (-2*exp(2*x-1)+2*exp(1)+exp(2*x)-1)*exp(-x+1)/(exp(2)-1)

(1)

u__sol := eval(u(x), sol); d2u__sol := simplify(diff(u__sol, x, x))

(-2*exp(2*x-1)+2*exp(1)+exp(2*x)-1)*exp(-x+1)/(exp(2)-1)

 

(-2*exp(2*x-1)+2*exp(1)+exp(2*x)-1)*exp(-x+1)/(exp(2)-1)

(2)

is(u__sol = d2u__sol)

true

(3)

plot(u__sol, x = 0 .. 1, 0 .. 3)

 

``


 

Download pdsolve.mw

Here is alternative approach that may mimic what you read in the textbooks...

Maple solves everything exactly unless instructed to solve numerically. Here is an alternative way to extract the numerical solution.

 

 

restart

 

Hmm, start with the equation for which we want the area within the ellipse...

eq := y^2 = x^3-3*x-1

 

Now, solve for the algebraic values for the "end points" along the x-axis of this ellipse... ( A tip of the hat to Kitonum for the plot.)

 

xpts := solve(rhs(eq) = 0)

(1/2)*(4+(4*I)*3^(1/2))^(1/3)+2/(4+(4*I)*3^(1/2))^(1/3), -(1/4)*(4+(4*I)*3^(1/2))^(1/3)-1/(4+(4*I)*3^(1/2))^(1/3)+((1/2)*I)*3^(1/2)*((1/2)*(4+(4*I)*3^(1/2))^(1/3)-2/(4+(4*I)*3^(1/2))^(1/3)), -(1/4)*(4+(4*I)*3^(1/2))^(1/3)-1/(4+(4*I)*3^(1/2))^(1/3)-((1/2)*I)*3^(1/2)*((1/2)*(4+(4*I)*3^(1/2))^(1/3)-2/(4+(4*I)*3^(1/2))^(1/3))

 

What does this mean numerically? Let's evaluate "floating point", i.e. numerically.

evalf(xpts)

1.879385242-0.1e-9*I, -1.532088886+0.2732050808e-9*I, -.3472963554-0.732050808e-10*I

 

It looks like the most negative value is the 2nd one, and the next most negative value is the 3rd one..

 

Let us "simplify" the extreme points before performing the calculation.

x__0 := simplify(xpts[2]); x__f := simplify(xpts[3])

-2*3^(1/2)*sin((4/9)*Pi)+2*cos((1/9)*Pi)

2*3^(1/2)*sin((4/9)*Pi)-4*cos((1/9)*Pi)

 

With this, I'll calculate the area within the ellipse. "x : `x__0` -> `x__f`  y = - sqrt(x^(3)-3 x-1) to sqrt(x^(3)-3 x-1)".

area := int(int(1, y = -sqrt(rhs(eq)) .. sqrt(rhs(eq))), x = x__0 .. x__f)

-(12/5)*3^(1/4)*(-3^(1/2)*cos((1/9)*Pi)+2*sin((4/9)*Pi)+sin((1/9)*Pi))^(1/2)*2^(1/2)*sin((4/9)*Pi)^(1/2)*(2*sin((1/9)*Pi)*3^(1/2)*EllipticE((-3^(1/2)*cos((1/9)*Pi)+2*cos((1/18)*Pi))^(1/2)/cos((7/18)*Pi)^(1/2), I*2^(1/2)*sin((1/9)*Pi)^(1/2)/(3^(1/2)*cos((1/9)*Pi)-sin((1/9)*Pi))^(1/2))+4*cos((1/9)*Pi)*EllipticF((-3^(1/2)*cos((1/9)*Pi)+2*cos((1/18)*Pi))^(1/2)/cos((7/18)*Pi)^(1/2), I*2^(1/2)*sin((1/9)*Pi)^(1/2)/(3^(1/2)*cos((1/9)*Pi)-sin((1/9)*Pi))^(1/2))-6*cos((1/9)*Pi)*EllipticE((-3^(1/2)*cos((1/9)*Pi)+2*cos((1/18)*Pi))^(1/2)/cos((7/18)*Pi)^(1/2), I*2^(1/2)*sin((1/9)*Pi)^(1/2)/(3^(1/2)*cos((1/9)*Pi)-sin((1/9)*Pi))^(1/2))+EllipticF((-3^(1/2)*cos((1/9)*Pi)+2*cos((1/18)*Pi))^(1/2)/cos((7/18)*Pi)^(1/2), I*2^(1/2)*sin((1/9)*Pi)^(1/2)/(3^(1/2)*cos((1/9)*Pi)-sin((1/9)*Pi))^(1/2)))/((3^(1/2)*cos((1/9)*Pi)-sin((1/9)*Pi))^(1/2)*(36*sin((4/9)*Pi)^2-24*3^(1/2)*sin((4/9)*Pi)*cos((1/9)*Pi)+12*cos((1/9)*Pi)^2-3)^(1/2))

 

Well, that is the exact value. What Paul is asking for is the numerical value. Again evaluate, "floating point".

evalf(area)

1.848519839-0.*I

NULL

Download Ellipse.mw

Substitute the { } for [ ] and it will be a list of lists.

@wolowizard
And here is the follow up to my terse reply late last night. It adds on to what @Carl Love nicely stated.

If you want to learn more about "lists" vs. "sets" vs. other data types, I recommend chapter 4 of the programming manual. (And one does not require switching out of 2D math to use it.)

https://www.maplesoft.com/support/help/Maple/view.aspx?path=ProgrammingGuide/Chapter04

f''(w) = 0

For a first derivative condition: 

f'(w) = diff_f_at_w_expression

 

4 5 6 7 8 Page 6 of 8