Scot Gould

Scot Gould

717 Reputation

14 Badges

11 years, 140 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

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

Maple 2020.1 in Windows 10 - worksheet mode. 

I tried to reproduce your situation. I wrote a do loop to print out 10,000 lines of numbers.  Yes, the scrollbar did shrink, but it never reached the microscopic size you are describing. The scrollbar was still manageable. 

For me, when the Maple output is beyond a 100 lines, I find it so extensive that it is incomprehensible.   I’m pleased how quickly ‘ctrl-d’ cleans up the mess.

 

@acer I understand your explaination and your example. I wonder how the numbers are represented in 2D-Input so that the simplification process never occurs.

Regardless, it appear that this happens, and it is an unexpected outcome. (So much for my attempt understand Carl's discussion about evalf.) Much thanks.

@Rouben Rostamian  At my institution, multiple students were suspended for a semester for receiving answers to questions like these on Chegg.   (Interestingly, it was the students who had turned in nonsensical solutions who were caught.)   

evalf[30](3^(6/5)) in Maple Input does produce all 30 digits. 

However, I may have found a possible answer from a post by @Carl Love from 5 years ago regarding the output of evalf. That is, the output of evalf is not accurate to n digits, rather that all subcomputations are performed using approximately n digits. I recongize there is a limit, but I thought 15 digits is attainable and the output shown would be to at least 15 digits, regardless of the type style of input used. Certainly, I have seen many Maple examples by Maplesoft imply evalf does produce the output of "give me the value to n digits." 

@tomleslie I noticed the units in your output are enclosed by double brackets. According to help, the double brakets were shown prior to Maple 2015. Is this the case for you because 2019, 2020, do not show double brackets? I would like them to be displayed and I can't figure out how to show them. 

Since you do have access to Maple 2020, I encourage you to look at the Maple Portal.  It has lots of great help, and is organized to assume that the person using Maple has no experience with it. I encourage you to spend time watching the very short introductory videos and clicking the numerous useful links under "How do I..." 

I assure you - it is worth the effort. (I'm guessing you are a student. My students feel sorry for the students in other could who don't spend time becoming able to implement the power of Maple.) 

@acer Yes, this clarrifies why StringBuffer is not defined as an object or Object. even though the wording in the help does tend to mix terms:

 

 

The StringBuffer constructor returns a string buffer object.

The StringBuffer object returned by the constructor is a module with six methods: clear, append, appendf, newline, space, and value.

The first line in help is basically is the same wording in the Today command, without mentioning the word module. Hence the source of confusion. 

Anyway, I'm working toward chapter 9 of the programming manual, and currently view modules as "static classes" while objects are "dynamics classes".  Your example below matches my interpretation of these ideas in an OOL. 

 

First 13 14 15 16 17 18 19 Last Page 15 of 23