Scot Gould

Scot Gould

517 Reputation

14 Badges

10 years, 152 days
Upland, 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 replies submitted by Scot Gould

@achreftabet  Just hit the !!! button at the Toolbar at the top of the program,  and everthing will be executed. By adding a "restart" at the beginning, all values are reset to 'unassigned'.

I'm guessing you are new to Maple. Hence I encourage you to look at the Maple Portal. It includes lots of "How do I" examples. 


@Kitonum I'm curious why you chose 'sum' in your solution. Given what one assumes is a discrete value for n, my first inclination was not to use 'sum', but rather 'add' . In comparing the two, I examined some typical examples I have encountered. For me, the most important question was how does one use S if the array elements are assigned values. Here sum failed for me. I would appreciate your thoughts.


restart; randomize():

Define S and test it:

S := n -> sum( sum( a[i, j]*x^i*y^j, j = 0..n-i), i=0..n);

proc (n) options operator, arrow; sum(sum(a[i, j]*x^i*y^j, j = 0 .. n-i), i = 0 .. n) end proc



x^2*a[2, 0]+x*y*a[1, 1]+y^2*a[0, 2]+x*a[1, 0]+y*a[0, 1]+a[0, 0]


Define A and test it:

A := n -> add( add( a[i,j]*x^i*y^j, j=0..n-i), i=0..n);

proc (n) local i, j; options operator, arrow; add(add(a[i, j]*x^i*y^j, j = 0 .. n-i), i = 0 .. n) end proc



x^2*a[2, 0]+x*y*a[1, 1]+y^2*a[0, 2]+x*a[1, 0]+y*a[0, 1]+a[0, 0]


Assign values random values to the elements  in the array `a`.

N := 10:
a := Array(0..N, 0..N, (i,j)->rand(-1.0..1.0)()):


Problem: testing S with n = 2.


Error, (in S) bad index into Array


Hmm, no longer symbolic.


As opposed to A:




S can't be plotted even if the function is delayed:

plot3d( 'S(10)', x=0..1, y=0..1)

Warning, unable to evaluate the function to numeric values in the region; see the plotting command's help page to ensure the calling sequence is correct



But this does work.

newS := (x,y,n) -> sum( sum( a[i, j]*x^i*y^j, j = 0..n-i), i=0..n);

proc (x, y, n) options operator, arrow; sum(sum(a[i, j]*x^i*y^j, j = 0 .. n-i), i = 0 .. n) end proc


plot3d('newS(x,y,10)', x=0..1, y=0..1);


A behaves as a I would expect.

plot3d(A(10), x=0..1, y=0..1)







1) The explaination in your response helps me understand what the ':-' in  ':-size' is. I completely misunderstood that part of your code. 

2) Between reading your discussion of "plot persistence" and simplifying your code, I was able to understand why the wrapper worked. Thanks again.  (This post also lead me down a rabbit hole of odd plotting outcomes that I can now attribute to "plot persistence" . )

PS. Your suggestion to me, and to others, to concentrait on evaluation of names process in Maple was probably the most paradigm-shifting moment of the year for me.  I believe much of my misunderstandings come from decades of coding using numerically based environments and thus "assuming" I know what I'm doing.   

@acer I like your idea. It matches MATLAB's version of the command: linspace.

(I noticed this 2 miss when a looked at the failing of seq in the plot of my solution to the original question.)

That said, the step size in seq requires a type numeric, (yes?). So what is the type for Pi, which appears to be not numeric?  I ask because if I were to write procedure that accepts numeric and Pi, how would I write the acceptable types?   x::{numeric, and what ever Pi is.}


@acer I like seq, and I see you used it. But I noticed there was an unexpected behavoir when I used it. I can sort of understand line 2, but I don't understand line 3:



a := 2*3.15; N := 4; dx := 2*a/(N-1); seq(-a .. a, dx)







-6.30, -2.100000000, 2.100000000, 6.30000000


a := evalf(2*Pi); seq(-a .. a, dx)



-6.273185308, -2.084395102, 2.104395104


a := evalf(2*Pi); dx := 2*a/(N-1); seq(-a .. a, dx)





-6.283185308, -2.094395102






@acer This workaround certainly useful, but hallenging to understand.  My current expectation is that "size" is "size" is "size" regardless where it is displayed, but if I read your code correctly, the "size" used in a procedure can be different than the size in the global section, hence the use of the terminology ":-size".  And yet, when the image is actually displayed in the global section (is this the correct terminology), it resorts to the :-size, not the size that it was used to generate the image. 

Agreed, I have seen the problem in 2020.1 as well, but I noticed it in the Print-Preview.  (Windows 10).

Yes, forcing a page-break does appear to eliminate the lack of content given that the content is forced onto the next page.  

@Carl Love Completely understandable. I was hoping it would work in all cases. But since my problem has been solved, I don't have an environment to test your idea. I hope it works for krobe8. 


New question which stems from seeing your idea: is it possible to be notified about an answer/posting within a question without having to contribute to the question?   

@krobe8  What I eventually did was to perform a clean install for a subsequent year version, as if Maple had never been on my computer. This fixed the problem.  So far, when exporting a  mw file from some directory, the "Export As" window first lists the directory from where the mw file resides.

However, if I create a new worksheet and try to export it before saving it to a mw file, like you, default directory Maple shows is my Documents folder, regardless what the curdir is.  I tried the suggestion by @Carl Love , which looked promising (and if I understand what he is suggesting), that did not alter the undesired behavior.  

@ReactionUra Based on these chemical reactions, I'm guessing x is NOT a constant, but rather a variable. However, since I'm not a traditionally trained chemist, this answer includes x = 0. 

Since what you want are numerical values, i.e., floating point values, for the unknowns, I suggested fsolve

(To save space, I have made a sequence (seq) of equations which Maple reads as as eq||n where n is an integer that counts from 1 to 12 by increments of 1. 12 equations, 12 unknowns.) 

That said, many of the values are negative. Does this make physical sense to you? (Because it does not to me.)  I'm wondering if there may be sign problems in the equations.

@Carl Love I appreciate your review of my answer. Could you explain in more detail part 2 of your comment, please? 

I am not concerned about the first problem. In my view, readability and comprehension of what is being asked is more imporant than execution speed since it is likley it is more helpful to the person in understanding why drdt:=t->diff(r(t),t) does not work.  

@acer This is all appreciated.  From your fun exercise, I can already envision how it will be useful to me in the future.

@acer And yep, for the ASCII characters I desire, I'll have to pull out of the Unicode (not UTF-8) set of characters. So I truly appreciate both bits of info. 

An aside: what frustrates me in this example, as it does for other examples, is that after conducting mutilple searches, and combing through pages of help and the programming manual, other than Chapter 2, I was unable, and am still unable, to locate an example that says something like printf("&#%a;", c) or  printf("&#%d;", c). How did you know to inlcude the  semi-colon? 

(And a question more of style/intent - why sscanf in the first line and not convert to decimal from hex?)


@tomleslie Thanks for the advice. I've edited the question to include an example. Unfortunately, HTML input/output is not what I want, but the command did educate me on unicodes. 


What tends to work for me is to write out one line a time and see if there are errors in the line before moving on. Notice all the lines in your calculation are in one execution group (>). 

For what you post, the error occurs in the 3rd line of the big execution goup  where you write something with "z". As @gkokovidis points out, there appears to be a missing "mutiplication" sign between the "z" and the "x". While I don't think you need to convert to Maple input mode, (I use 2D input all the time), I do agree it should say "z * x(t)" 

The rest suggests you have copied from some other source. My experience is that it is best to understand each line well before moving on to the next.  There are some incredibly smart and gifted folks here who are likely to help you out before I have a chance to look at the rest.  

(P.S. Thank you for the complement.) 


5 6 7 8 9 10 11 Last Page 7 of 15