Scot Gould

Prof. Scot Gould

382 Reputation

12 Badges

8 years, 96 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

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

Dr. Lopez correctly states, the output that you label as answer5[1] are a list of two equations: x = 553,  y = 455.  Since the goal is to calculate the value of the arctan, one wants to use "just the values". Hence a technique that I use frequently is to extract the right-hand-side (RHS) of the equations, i.e., the values, and use that output, for the calculations: 

answer5 := { x= 553.6, y = 455.0 }, {x = 553.6, y = -455.0 };

{x = 553.6, y = 455.0}, {x = 553.6, y = -455.0}


theta1 := arctan( rhs(answer5[1][2]) / rhs(answer5[1][1]) );




And for future angles, use the fact that arctan can identify the quadrant using 2 parameters: y, x. So for the other angle:

theta2 := arctan( rhs(answer5[2][2]), rhs(answer5[2][1]) );






Since you appear to want to use the Statistics package, which is a good choice for plotting one data set against another, this approach might be more useful. It uses 2 commands: ScatterPlot and Fit.  I've added some options to make it more interesting, but are not required.

restart; with(Statistics); X := Vector([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 8, 12, 12, 22, 30, 40, 44, 51, 65, 70, 97, 111, 131, 135, 174, 184, 210, 214, 232, 238, 254, 276, 285, 305, 318, 323, 343, 373, 407, 442, 493, 542, 627, 665, 782, 873, 981, 1095, 1182, 1273, 1337, 1532, 1728, 1932, 2170, 2388, 2558, 2802, 2950, 3145, 3526, 3912, 4151, 4399, 4641, 4787, 4971, 5162, 5445, 5621, 5959, 6175, 6401, 6677, 7016, 7261, 7526, 7839, 8068, 8344, 8733, 8915, 9302, 9855, 10162, 10819, 11166, 11516, 11844, 12233, 12486, 12801, 13464, 13873, 14554, 15181, 15682, 16085, 16658, 17148, 17735]); Y := Vector([1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 2, 2, 2, 2, 2, 3, 8, 12, 12, 22, 30, 40, 44, 51, 65, 70, 97, 111, 131, 135, 174, 184, 210, 214, 232, 238, 254, 276, 285, 305, 318, 323, 343, 373, 407, 442, 493, 542, 627, 665, 782, 873, 981, 1095, 1182, 1273, 1337, 1532, 1728, 1932, 2170, 2388, 2558, 2802, 2950, 3145, 3526, 3912, 4151, 4399, 4641, 4787, 4971, 5162, 5445, 5621, 5959, 6175, 6401, 6677, 7016, 7261, 7526, 7839, 8068, 8344, 8733, 8915, 9302, 9855, 10162, 10819, 11166, 11516, 11844, 12233, 12486, 12801, 13464, 13873, 14554, 15181, 15682, 16085, 16658, 17148, 17735])


The following is the more common way using the "Statistics" package - ScatterPlot

ScatterPlot(X, Y, labels = ["X", "Y"], tickmarks = [5, 5], symbolsize = 20, symbol = solidbox)


This looks like a straight line. Are the two "vectors" truely identical?

LinearAlgebra:-Equal(X, Y)



Yes, hence the confusion as to why you might want to plot the two against each other.


As others have pointed out, you have a sequence of 110 points. Here is the way I prefer to extract this information: numelems

N := numelems(Y)



Let us create a new X variable to plot against the Y made up of a sequence of numbers from 1 to 110:

newX := Vector([seq(1 .. N)])


Now we plot, and we can add a possible curve fitting line. I tried a few examples, and this one looks possible given the information provided:

cfit := a3*x^3+a2*x^2+a1*x+a0; ScatterPlot(newX, Y, labels = ["X", "Y"], tickmarks = [6, 10], symbolsize = 15, symbol = circle, fit = [cfit, x], color = ["DarkGreen", "Magenta"], legend = "data")




To see the values of a basic curve that fits the data, use Fit in the Statistics package.

sfit := Fit(cfit, newX, Y, x)



May I suggest "Getting Started with Maple" 4th edition, by Doug Meade, et. al.. for other examples.




See if the command to evaluate an expression over a complex field,  evalc, does the operation that you asking for. 

Thank you Paul for posting this question. I feel your post is important because it identifies a problem with the Context Panel.

The reason your projectile doesn't land is because, in the Context Panel option for "2D-plot", the default range for the horizontal term is from -10 to +10.  I suspect that you changed the properties of the axes, "2-finger click>Axes>Properties", and thus were able to change the display to the limits: from 0 to 24. (And the same for the vertical as well.) Unfortunately, that didn't cause the program to calculate the values beyond t = 10.  Until Maplesoft updates/fixes/provides alternative to this property for the graph, I see no other option for this type of problem than for one to write the command that @tomleslie  states: "plot(ex11(t), t=0..30)" 

And if you want to know when the function is 0, there appears to be no easy shortcut in the Context Panel. Hence I suggest you try this command: "solve(ex11(t))". I rewrote the expression and used the solve sommand.  You are correct, the final t for it to "return to ground" is 24 time-units.

Example: Height of a Projectile


"ex11(t):=-16 t^(2)+384 t;"

proc (t) options operator, arrow, function_assign; -16*t^2+384*t end proc




This is the default image shown using the Context Panel...


Continuing with this problem:


-16*t^2+384*t"(->)"[[t = 0], [t = 24]]


plot(ex11(t), t = 0 .. 24)






I unitentionally deleted my answer to note that I do tend to think more along the lines of @tomleslie

Using document mode


-3 <= 6*x-1

0 <= 6*x+2


6*x-1 < 3

6*x < 4


Here I will use <ctrl>-<L> (for Windows), or <command>-<L> (for Mac) to insert labels

solve(0 <= 6*x+2 and 6*x < 4, x)

RealRange(-1/3, Open(2/3))


Or we can do in one line:


solve(`and`(-3 <= 6*x-1, 6*x-1 < 3), x)

RealRange(-1/3, Open(2/3))


Or my personal preference, assign each equation to a variable, and then solve

eq1 := -3 <= 6*x-1

0 <= 6*x+2


eq2 := 6*x-1 < 3

6*x < 4


solve(eq1 and eq2, x)

RealRange(-1/3, Open(2/3))





For some reason, the website is unable to upload my Maple sheet, so I will leave this comment in the form of a PDF that you should be able to download and read.



For the occasional time that I wish to write "code", i.e., 1-D math input, I prefer to insert a Code Edit Region (CER), and enter the code there. Then, when I wish to paste the code to a Word document, I copy and paste the image of the CER. This process doesn't exactly do what you are asking, but with the coloring and bolding, it does tend to generate a prettier pretty-print. 


@mikerostructure  For what it is worth, I generated an eps file version of the plot. As @acer pointed out, it took Maple 2020 more than a minute to generate both the first plot and the second plot. 

To reproduce the image, I sent the file to an online EPS viewer and it worked fine.


If what you want is Maple code to appear as "real math", have you considered using "2D Input" to input content?  But if you are committed to "Maple Input", does that mean some data that will be entered will not be in SI units?


Note - I would have uploaded the file and the content of the file, but this is what I received multiple times trying to upload this very simple file:

Maple Worksheet - Error

Failed to load the worksheet /maplenet/convert/ .



I use Feedly on Android and other OSes. And then just "add content" -> "MaplePrimes".  My only complaint about the RSS feed is that the spam  still gets through before someone deletes it. 3 of the last 5 posts have been for pain killing medication, wallpaper and mole removal products. 

Or did you not want to use an app like that?

A quick glance suggests a missing divide command in the "parameters = " expression on the last line.

See attached.

Note, this document was constructed as part of my experiment with Maple Cloud. 

As someone who spends time trying to get students to use Maple to solve physics / engineering problems because I would rather have them work on those problems, and not math problems, I can understand your frustrations. There are many times I find Maple coding to be less than "math intuitive."

However, for this situation, let me say, what are you trying to do ? Are you trying to take the derivative of f(x) with respect to x and then set the x in the outcome to be equal to 3? This outcome would be 3.  Or, are you trying to take the derivative of f(x) after you have put in the value of 3 for x? Because that is how I initialy read it. (Think arcsin(sin(x)). Pass x to sine, do the calculations, then do the arcsin of the resulting calculation.) For this reading, the outcome is 0. 

Since I'm going to assume the former, then what one needs to know, when Maple sees g(x), x is a variable. However, when Maple see f'(x), it sees the " ' " as the derivative with respect to the variable x.  So for me, the most readable and understandable way to write these statements is:

" f(x):=3 x+2;"

proc (x) options operator, arrow, function_assign; 3*x+2 end proc


"g(x1):= f'(x1);"

proc (x1) options operator, arrow, function_assign; eval(diff(f(x), x), x = x1) end proc






It performs the calculation of the derivative before it evaluates the outcome using x1 as the value for x. 



1 2 3 Page 2 of 3