Scot Gould

Prof. Scot Gould

392 Reputation

12 Badges

8 years, 228 days
Claremont, California, United States
Dr. Scot Gould is a professor of physics in the W.M. Keck Science Department of Claremont McKenna, Pitzer, 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 making us of scanning probe microscopes, particularly those which involved natural fibers such as spider silk. More recently, he was involved in developing and sustaining AISS, a full-year multi-unit non-traditional interdisciplinary undergraduate science education course which 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 the computer algebraic and numerical system Maple to assist students in modeling and visualizing physical, and biological, systems. His Dirac-notation based quantum mechanics course is taught solely through Maple. An avid baseball fan, during his spare time, Dr. Gould is traveling, particularly to locations where he can bicycle on smooth, traffic-free roads, visit beaches and/or mountains, and enjoy good food and drink.

MaplePrimes Activity


These are answers submitted by Scot Gould

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

 

Whether I use an indexed variable vs. an atomic one depends upon the problem I am trying to solve and how I wish to solve it. For example, if I have wish to write or refer to elements in a sequence, list or vector, being able to use indexed variables is quite valuable in readability and worksheet real estate. E.g. seq(a[n]*x^n, n=0..3). Such choices are made when I am writing code, which I perform nearly always within a Code Edit Region.  

However, if I am writing mathematical equations that I want non-Maple users to be able to read, particularly if including a subscript is informative, then I use an “atomic variable”. For writing mathematical equations and functions I use 2D-input because it makes the equations more readable and reduces the content on a page. The output of a 2D-input is repetative.

I agree with Carl Love, the atomic variable leads to fewer problems, particularly with new users, which, clearly, you are not. Many of the students in my courses prefer the image of the subscript provided within 2D input, such as F__x or F__Earth. However, when constructing such variables, too often they end up with the equivalent of F[x], only to discover that should they assign a value to x, their worksheet starts producing unexpected outcomes. Thus, I encourage them to avoid subscripts until they are more familiar with Maple.

There is a post on the evaluation of subscripts in Maple by Robert Lopez that might be of interest to readers: https://www.mapleprimes.com/maplesoftblog/208838-The-Saga-Of-The-Subscript

Personally, I enjoy atomic variables. They truly do make Maple input more readable, i.e., more aligned with what one sees in papers and textbooks.

 

Use 2D Input. Then, and only then,  the "dot" notation is available and can be found in the Calculus palette. 

 

When I am in your situaiton, I hit enter after the "x" to add another line. Then I hit the "Remove section" button on the Toolbar. (It is on the right in the circled region shown below.) This ends Section 1 and steps-left the cursor into the "Chapter 1" section. Then I hit "Insert section" button to add another section and step-right. I find this step-left / step-right structure logical since it is akin to what one uses in Word. 

If you end up with more lines in a section then desired, <ctrl>-<delete> (or <command>-<delete> for Mac) works to remove the entire line. 

I could see using this plot in my own courses. Others here are likely to give you some slicker ideas, but here is a start. All the plots are "plot", but one is of "style=point". I put the commands in a procedure so that you could pass it different functions.

 

restart


This procedure receives a function, f, that is to be plotted from a to b. N points are shown

NeatPlot := proc (f, a::numeric, b::numeric, N::posint, aclr::string) local x, n, lplot, dx, pts, fplot, pplot; fplot := plot(f(x), x = a .. b, thickness = 4, color = aclr); dx := (b-a)/(N-1); pts := [seq([x, f(x)], x = a .. b, dx)]; pplot := plot(pts, style = point, symbolsize = 20, symbol = solidcircle, color = aclr); x := a; for n to N do lplot[n] := plot([[x, f(x)], [x, 0]], thickness = 3, color = aclr); x := x+dx end do; plots:-display([fplot, pplot, seq(lplot[n], n = 1 .. N)]) end proc

"fsample(x):=cos(0.5*x)*(e)^(-0.1*x^(2)):  a:=evalf(2*Pi):    NeatPlot(fsample, -a, a, 13, "DodgerBlue");"

 

``

``


 

Download NeatPlot.mw

(Note - the grid lines don't show up when you execute it.) More work using textplot is needed to add the values of f(x) at x. 

Snip the image of the Maple output and paste into your document. It requires nanoseconds of effort. 

1 2 3 Page 1 of 3