Scot Gould

Prof. Scot Gould

372 Reputation

12 Badges

7 years, 314 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 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. 



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)


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





is(u__sol = d2u__sol)



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





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.





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.


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])




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".





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

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.)

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:

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.



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");"






(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. 

I wasn't sure which form you used, so I prefer the worksheet mode, using 2d-input...
Maple expects you to differentiate first with respect to t, but then use a different variable to substitute in the values...

restart; with(plots)

"r(t) :=< cos(t), sin(t), t>;"

proc (t) options operator, arrow, function_assign; `<,>`(cos(t), sin(t), t) end proc


spacecurve(r(t), t = -1 .. 1, thickness = 5, color = "DodgerBlue")


Differentiate first with respect to t, but t1 is the value that you are inserting

"drdt(t1) := eval(diff(r(t), t), t= t1);"

proc (t1) options operator, arrow, function_assign; eval(diff(r(t), t), t = t1) end proc


spacecurve(drdt(t), t = -1 .. 1, thickness = 5, color = "DarkMagenta")





As an alternative to using a Matrix, might I suggest using DataFrames. They are particularly useful if you plan to continue on with analyzing your data as if it were entered in a spreadsheet. And it is way more readable in manipulation than any spreadsheet.


I'm going to guess that the second column is generated by the probability of an outcome from a binomial distribution: (x choose 8?)   Hence I'll create the formula:

"restart;   P(x) := ((8) ? (x))/(2^(8)):"


Now to create the DataFrame, it is just like a Matrix, but one can label columns (and rows). The columns counter will help you catch the error that Carl Love points out.

Column 1 is a sequence of numbers from 0 to 8

Column 2 is a sequence of values from the P(x) formula

Column 3 is just of Vector of 0.
'columns' option is the list of labels.


m1 := DataFrame(`<|>`(`<,>`(seq(0 .. 8)), `<,>`(seq(P(x), x = 0 .. 8)), Vector(9, 0)), columns = ["# girls", "P(x)", "x*P(x)"])



If you prefer the "P(x)" column to be floating point values and not rational numbers, all you need to do is to say is that you want to evaluate (individually) as a floating point:

m1["P(x)"] := `~`[evalf](m1["P(x)"])



Here is what m1 looks like now:




To see if what we have makes sense, let's add up the "P(x)" column. It should be 1.




Looks good. Time to move on.


To solve for "x*P(x)" This is "#girls"  multiplied (individually) with "P(x)"

m1["x*P(x)"] := `~`[`*`](m1["# girls"], m1["P(x)"])


Now the DataFrame looks like this:




At this point, you can add up the values in the "x*P(x)" column


By the way, sum explicity says it is designed for symbolic summations. Hence the command of add was created. (This can be frustrating until one gets used to it.)



While I understand your reasoning, as it has been mine, from the help of ?sum:

      The sum command (sum) is for symbolic summation.

The italicized term is their emphasis. Hence, it sounds like even for "short" sums of discrete terms, don’t expect logical outputs from sum even if the command doesn’t reject the input. (If you are coming from MATLAB, remembering to switch to add can be maddening.)

1 2 3 Page 1 of 3