Scot Gould

Scot Gould

637 Reputation

14 Badges

12 years, 66 days
Claremont McKenna, Pitzer, Scripps College
Professor of Physics
Upland, California, United States
Dr. Scot Gould is a professor of physics in the W.M. Keck Science Department of 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 replies submitted by Scot Gould

@acer 

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" . )   PlotPersistence_Effect.mw

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:


 

restart

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

6.30

 

4

 

4.200000000

 

-6.30, -2.100000000, 2.100000000, 6.30000000

(1)

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

6.273185308

 

-6.273185308, -2.084395102, 2.104395104

(2)

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

6.283185308

 

4.188790206

 

-6.283185308, -2.094395102

(3)

``

``


 

Download seqerror.mw

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

fsolve_example.mw

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

@ogunmiloro 

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

 

@ogunmiloro 

Online help is your best source for such information: https://www.maplesoft.com/support/help/

Search for Fit, which is the command to perform regression and the 2nd listing is this one: https://www.maplesoft.com/support/help/Maple/view.aspx?path=Statistics/Fit

We discover that :

restart; with(Statistics); 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])

Build the X vector with the number of elements (upperbound works too) for the size.

N := numelems(Y); X := Vector([seq(1 .. N)])

110

(1)

The next is to identify a equation to plot. Again, lots to try, but what sort of works well is a power fit of the format:    

   
A*exp(r*x)

Let's try it and plot to see how it looks:

cfit := A*x^r; ScatterPlot(X, Y, labels = ["X", "Y"], tickmarks = [6, 10], symbolsize = 15, symbol = circle, fit = [cfit, x], color = ["DarkRed", "DodgerBlue"], legend = "data")

A*x^r

 

 

To see the values of a basic curve that fits the data, use Fit in the Statistics package.  Let Maple figure out which type of fit command to call. It will output the equation

fiteq := Fit(cfit, X, Y, x)

HFloat(5.506598358224808e-4)*x^HFloat(3.680975408091231)

(2)

Now let's extract the residuals. Same command, but asking for a different output

Yres := Fit(cfit, X, Y, x, output = residuals)


Now you want to plot just the residuals?

Typesetting:-mrow(Typesetting:-mi("ScatterPlot", italic = "true", mathvariant = "italic"), Typesetting:-mfenced(Typesetting:-mrow(Typesetting:-mi("X", italic = "true", mathvariant = "italic"), Typesetting:-mo(",", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("Yres", italic = "true", mathvariant = "italic"), Typesetting:-mo(",", mathvariant = "normal", fence = "false", separator = "true", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.3333333em"), Typesetting:-mo(" ", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.0em", rspace = "0.0em"), Typesetting:-mi("title", italic = "true", mathvariant = "italic"), Typesetting:-mo("=", mathvariant = "normal", fence = "false", separator = "false", stretchy = "false", symmetric = "false", largeop = "false", movablelimits = "false", accent = "false", lspace = "0.2777778em", rspace = "0.2777778em"), Typesetting:-ms("Residual/error for each point"), Typesetting:-mi("")), mathvariant = "normal"))

 

``


 

Download fitting_with_Statistics_package_V2.mw

@nm You are asking for something like the old teletype printer as if the screen were a roll of paper. That might be a potentially useful option because you are correct, that is not how it works currently. For those situations, may I suggest continuously holding down the page-down button?  Using the page-down technique might  be an even more useful than a continuous-scrolling system, since the page-down technique will allow you to stop scrolling when you see a line or set of lines that are particularly interesting. 

First 8 9 10 11 12 13 14 Last Page 10 of 18