Scot Gould

Scot Gould

1039 Reputation

15 Badges

12 years, 95 days
Claremont McKenna, Pitzer, Scripps College
Professor of Physics
Upland, California, United States
Dr. Scot Gould is a professor of physics at 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

@Ronan Thank you. However, the process is the same one proposed by @nm . All I did was upload a document that I provide to the students. For them, it has to be readable. That is why I listed it as a reply and not an answer. 

While there may be good coding reasons for using evalf[n] over evalf(...,n), it is my experience in showing new users the two options, the first option is more confusing. At no other time in learning Maple can I think of a situation where we commonly use "indexed" procedure options.  New users are used to the format of Maple procedure calls being: procedure_name(main_entity, option_1, option_2, etc.). 

While folks may be confused by your last example, I cannot think of a time when it has come up. However, what usually comes up is using simplify, as in the example:

   L := equation_1, equation_2;

   simplify(L);

New users, and I've done this, assumed that each equation in the sequence is simplified independently of the other, which is not how simplify works. (Nor should it.)

Finally, I can assure you my biggest beef with evalf is that it does not work if one has changed the display precision value. I find 10 sig. figs. too many, so I limit the display to 5. But when I want 20 sig. figs for a value, I expect evalf to list all 20. 

Off soap box.

@Aung Plotting the integrand and calculating numerically each integral may be your only choice.

MaplePrimes_Integral.mw

@paolam, I have uploaded a document, which is shown here. I suggest you download the document to see everything in the document. 
 

While you say you are a beginner, your code suggests you have far more experience

in coding than one would expect. Hence, I assume you were just being modest.

 

I suspect you are using the default type of input of Maple. This is 2d input.

It is the input that allows one to write math equations as one sees them in

a document. For example:

 

sum(exp(-n)/n, n = 1 .. infinity)

-ln(1-exp(-1))

(1)

If this is the case, then the code that Carl recommended cannot be read by

Maple.

 

" interface(rtablesize= [81,24]):  M:= Matrix(      (81,24),       (i,j)-> local k; [seq](indice(C[i][1][k], rorder(orders[j], Sets[k])), k= 1..4)  ):"

Error, invalid arrow procedure

" interface(rtablesize= [81,24]):  M:= Matrix(      (81,24), (i,j)-> local k; [seq](indice(C[i][1][k], rorder(orders[j], Sets[k])), k= 1..4)  ):"

 

 

Because of the word "local" without the proc command, the 2d input fails to work

 

Hence, he proposed a different technique, which included the proc command. He also suggested

sequence making procedure, seq over a for/do loop. I too prefer the seq procedure. It is clean

and incredibly useful.

M := Matrix(81, 24, proc (i, j) local k; ([seq])(indice(C[i][1][k], rorder(orders[j], Sets[k])), k = 1 .. 4) end proc)

 

Personally, I prefer to write the procedure separately and the square brackets that make the list at the beginning
and the end of the sequence expression.

Mindex := proc (i, j) local k; return [seq(indice(C[i][1][k], rorder(orders[j], Sets[k])), k = 1 .. 4)] end proc; M := Matrix(81, 24, proc (i, j) options operator, arrow; Mindex(i, j) end proc)

 

However, one can use his original code if one clicks on the Text button at the top when entering

information in the execution group (the group with the > character.)

 

 

In "text mode" in the execution group, the code is entered as 1D input, which Maple can use the latest

modifications to the language.

 

M:= Matrix(
    (81,24),
    (i,j)-> local k;
            [seq](indice(C[i][1][k],
            rorder(orders[j], Sets[k])), k= 1..4)
):

 

An alternative to using lots of 1d input, is to insert a Code Edit Region. (From the menu

at the top: Insert "->" Code Edit Region )

interface(rtablesize= [81,24]):

 

 

The advantage of a code edit region is that it can find errors and give you warnings before you hit Enter

to execute it.

 

My last comment is that if you want to see some videos on the basics of Maple, using the 2d input,

may I suggest the website gould.prof/learning-maple. The videos are not entertaining, but they

cover the key concepts within 12 minutes. I go over how to enter input line-by-line. There are also

documents that accompany the video that include info on troubleshooting.


 

Download Maple_Primes_-_Entering_input_in_Maple.mw

@paolam Carl assumed that you are using 1D input. The code works if you switch to "text" as the input at the execution line. Better yet, embed the code into a Code Edit Region. 

Just an FYI, if you see yourself writing a fair amount of Maple code, not just math commands, may I suggest a nice presentation that occurred during the Maple 2023 Conference by Jürgen Gerhard, Senior Director of Research at Maplesoft. 

https://www.youtube.com/watch?v=k8fdbZg_nDg

Dr. Gerhard covers exactly the type of list construction inefficiency that @Carl Love noted in his reply to you. This issue can be found in his discussion of an inefficiently written quicksort procedure. 5:20 into the video. 

Even though I've written code for years in Maple, I continue to go back and rewatch parts of the video. 

Note that the conference has been virtual and free for the past several years. 

 

@nm

1) Why do your uploaded files contain the number 35788?

2) Did you set the conditions in Mathematica such that it returns only results that apply to variables in the real domain, or is the solution that Mathematica returned the only solution that it provided?

@C_R Your analytic solution makes the most sense and has the highest accuracy. What counts here is SA_1 and not the derivative of SA_1. 

@SwissMapleBeginner I've decided that my answer is both correct and wrong simultaneously. The piecewise procedure does play the role of the if-then-else. However, notice my solution does not produce the same results as the others.

IMO, C_R provides the best solution. You don't want the derivative of SA_1 to suddenly become the dosage value; rather, you want the actual value of SA_1 to become the dosage value.

The other solution that is superior is dharr's solution, which includes the event option.  Notice the event option states explicitly what is going to happen at t = 1. 

I apologize for misleading you. I do like my solution because it is readable, but readability does not make it correct.

@sursumCorda Yes, I see that a plot of the real part of the difference is valid for negative values of x. Of course, that is true for Re(ln(x)), Re(Ci(x)).

@sursumCorda I know virtually nothing about hypergeometric functions and the hypergeometric series, but it seems to me that given that the variable is (- (x/2)^2)), shouldn't one be able to calculate the function for negative values of x? However, it looks like the conversion to standard functions is limited to only positive values of x. (Yes, by symmetry, one can plot for negative values of x.) 

My question is: Does Mathematica make such assumptions? Does Maple punt because it makes no assumptions about x? 

This issue has come up before when folks have written, "Mathematica can solve this problem, but Maple cannot." In response, it has been often pointed out that Mathematica's answer applies only under some assumptions, and if those assumptions are provided to Maple, it returns the same answer. 

 

@acer Testing with 2024 (even though I'm annoyed about the editing problems in the 2d input). 

* Yes, with $1..N, the technique no longer produces an error in 2d input. However, the are no results calculated. Rather, I get this:

 * I removed the [] to create a list, not a sequence. So, I've added it back in with a [ ] around the entire statement. I cannot tell if that move makes any difference. 

Can you provide me a short primer on the difference between   list_making_expression[] vs. [list_makeing_expression]? 

@acer@Ronan ​​​​​​​, @nm ​​​​​​​, @sursumCorda ​​​​​​​, @Carl Love ​​​​​​​ 

Thank you, everyone, for contributing. The discussion led me down a rabbit hole, so I wrote some simple code to compare the efficiencies of the techniques.

As predicted, using a listlist conversion is the least efficient technique, requiring 50 times longer to execute than the most efficient. That's okay; the process taught me something. 

The next least efficient technique, by nearly an order of magnitude to the most, is seq(Column(M, i), i=1..N), which is understandable given the number of times Column is called for a large matrix. 

I like the techniques of using a single call to Column, i.e., in my preferred notation, [Column(M, [1..-1])]. It is highly efficient. However, it would be slicker if one didn't have to include the 1 and -1. This one was new to me.

Equally efficient is the call to convert the matrix into a list. I have seen this one before and very much like this approach. It is highly readable by most folks, which is important to me since I often have to show my work to non-Maple users. 

The most efficient method uses no calls to a named procedure, (i->M[.., i])~($N). Yes, there is still a call to obtain the dimension of the matrix, but it is about seven times quicker than the convert call. It either receives high marks or demerits for being the least readable and the only form that cannot be implemented using 2D input. 

In the end, while I truly learned more about Maple coding from the experience, it is likely I will continue to use the seq(M[.., i], i=1..N) expression. It is readable, but it does rely upon a reader's understanding of indexing matrices. It is the most efficient technique that can be implemented using 2D input. (Though not by much.) However, I am likely to include the convert-to-list technique because of its sweet spot of being both highly efficient and readable.  

 

@Ronan But I was thinking of trying to employ an elementwise-of-a-procedure approach. I should have stated that in the question. 

First 11 12 13 14 15 16 17 Last Page 13 of 31