Group Abstract Group Abstract

Message Boards Message Boards

[WSG23] Daily Study Group: Wolfram for Mathematics Research and Study

Posted 3 years ago
POSTED BY: Arben Kalziqi
74 Replies

I could use some advice on recommended ways to write functions. The function I am trying to write factors numbers. I am specifically targeting large numbers that have two prime factors. I want to eliminate all of the obvious factors (e.g. 2, 3, 5 etc.) So I started to write the following function, where c is the number being factored. I imagine there are several ways to factor a number by inspection, so far my function only has two tests, but could have more. Should I use Catch[] and Throw[] or Return[] or something different?

factorByInspection[c_]:= (
Catch[
If[EvenQ[c], Throw[{2, c/2}] ]
If[divFiveQ[c],Throw[ {5, c/5}]]
])
POSTED BY: Michael O'Connor

Hi Mike—please check out my answer in the thread for the current Study Group: https://community.wolfram.com/groups/-/m/t/2972173

POSTED BY: Arben Kalziqi
Posted 3 years ago

Arben, in the Elementary Introduction book interactive course chapter 11, there was an exercise about finding how many words in a list-o-words start with [some particular letter]. I answered:

StringContainsQ[StringTake[WordList[],1],"q"] // Counts // Lookup[True]

I thought that was a clever method, but the engine grades my response with a "Try Again". Is there something lacking in my response? Where does one go to report glitches in the exercise-engine for this course?

As an aside, I really like the numerous exercises in that course. It has more of a "practice the scales" component than study group tests. Nothing is as good as your live courses, but this interactive course is pretty darn neat.

POSTED BY: Phil Earnhardt

Hey Phil—that's a totally reasonable solution to that problem, yes. The only issue is that the autograder used there is quite a complicated object, and it doesn't always get everything right. (For quizzes and other assessments, we try to update it whenever we find one of these false negatives, but it's not always possible.)

I thought that Counts[StringContainsQ[StringTake[WordList[], 1], "q"]][True] might be taken a little bit better, but no dice :)

POSTED BY: Arben Kalziqi
Posted 3 years ago
POSTED BY: Phil Earnhardt
Posted 3 years ago

Arben, Thanks for your description of the quiz festivities. I wonder how Wolfram knows to calculate the grade on the download file if it isn't via a live wire. I used your manual copy from my downloaded quiz to the one I thought was the real thing, and neither saved my answers. Bob

POSTED BY: Robert Lyons
Posted 3 years ago

Hi, Arben! I very much appreciate the work that you and your Wolfram colleagues put into this class --and all the other classes I've taken. You make it fun to work on and learn even the most complex topics.

I have some questions about the admin of the final quiz. I downloaded my own copy of the quiz, and I left the original in my collection of web artifacts. I filled in the answers and got an automatic grade for the test. I saved the test back to the collection of web artifacts, but when I open it, it's blank. Did the quiz results make it to you, and where can I find my filled in copy of the quiz? Thanks for a great course! Bob

POSTED BY: Robert Lyons

Hi Robert—thanks for your kind words! I think that the giest of what Phil said is correct—probably you ought to submit the quiz directly online. Let me know if that doesn't work, and we'll look into it!

POSTED BY: Arben Kalziqi

This has been a great course with lots of inspirational gold nuggets. I can only dream of what a mind blowing experience going to college these days could be like with a tool like this at my finger tips.

Quick question: I got tired of the beeps warning me that the class notes were created in a newer version of Mathematica so I downloaded and installed is labeled as the latest version 13.2.1.0 on my current service plan, and I am still getting the beeps that tell me the notebooks I am opening were created on a newer version.

Does anybody know why? Are you working in a newer, perhaps unreleased version?

POSTED BY: Carl Hahn
Posted 3 years ago
POSTED BY: Phil Earnhardt

Hi everybody—the completed Differential Geometry notebook (with my and John's parts in addition to some of the extra references John made live) is now available in the materials folder.

Good luck on the quiz!

EDIT: I should also note that the review, including the "mini-lecture" on the intersection of linear and differential operators, Hamiltonian mechanics, differential eigensystems, and so on has also been uploaded in full.

POSTED BY: Arben Kalziqi
Posted 3 years ago
POSTED BY: John Davidson
POSTED BY: Arben Kalziqi
Posted 3 years ago

WRT Wolfram Study Groups, there's one other administrative detail that could make a difference.

In one of the lecture Q&A sessions last week, Cassidy noted that videos of the lectures will remain online as long as Wolfram Research has a contract with BigMarker (i.e., a long time). However, the lectures are inaccessible unless one has access to the URL for each lecture. Those "recording available" URLs are unique for every lecture and each is e-mailed once to each participant. They come with a tag of "bu=" plus a very long sequence of hexadecimal numbers, which implies the URLs are tagged and unique for each participant.

I have started a practice of assembling all URLs for WL Notebooks and BigMarker Videos in an archive for each SG that I take. As I see it, Wolfram Research could do one of three things for Study Group participants to help them organize an archive of the materials for a course:

  1. Make a specific recommendation during Session 1 of a course to suggest participants to create a document archiving links to the the training materials for the Study Group. The archive would be useful for review for the quiz, and useful for longer-term review of the material.

  2. Provide a WL Notebook with functionality for creating, editing, and saving an archive of the materials for a course.

  3. 2-3 business days after course completion, send an e-mail to course participants providing a document with links to all course materials. This document could be bundled with the "reminder" e-mail about the quiz deadline for the course.

Hmmm. After writing those three, I suppose #1 makes the most sense. #2 would be complicated to make a robust functionality, and #3 may be difficult for Wolfram U to automate adding URLs with any user-specific tags needed in the URLs. If generic URLs could be provided for the videos, then drafting the archive for this e-mail becomes much easier.

CC @Jamie Peterson

POSTED BY: Phil Earnhardt
Posted 3 years ago
POSTED BY: Phil Earnhardt

Yep, I get you! How about this? (It's been a long time since I've heard or thought about Larmour frequencies, so let me know if this is not right.)

POSTED BY: Arben Kalziqi

Thank you Arben. Great study of simple physics. I could not do it, but know I know how.

Really enjoyed the study group. Re-learned a lot I had forgotten and many new capabilities I never knew before. The quiz is fun too. Looking forward to a next time.

Larry

POSTED BY: Laurence Bloxham

Thanks Larry; I'm glad it was helpful! hopefully it paves a path forward for you to analyze and visualize other systems. I'm happy that we were able to to introduce and re-introduce you to various functionality, too!

POSTED BY: Arben Kalziqi
Posted 3 years ago
POSTED BY: Phil Earnhardt
Posted 3 years ago

I figured out my problem. Sorry for the last msg.

POSTED BY: Peter Fedkiw
Posted 3 years ago

I downloaded the notebooks for the study group today, and I found that I receive an error message on opening some of the lesson books. So, for example, I can open and read the notebook file "Linear Algebra and Graphs" but the file "WGS40-Asymptotics" does not open. I receive a Mathematica-generated error dialog box "Why the Beep" that tells me "This notebook was created in a more recent version of the Wolfram System ..." I am running version 13.2.1.0. I hope that you can help me fix the issue.

POSTED BY: Peter Fedkiw

Hi Peter—there's no issue, it's just a warning that the notebooks were made in a newer version so there might be some functionality that doesn't work because it doesn't exist in your installation.

POSTED BY: Arben Kalziqi
Posted 3 years ago

When I open the "Linear Algebra ..." notebook (and others that generate the same error message), the only page that appears in the notebook is the title page. There is no other content in the notebook (well, at least that I can see). BTW .... What version was used to create the "Linear Algebra ..." notebook?

POSTED BY: Peter Fedkiw
POSTED BY: Arben Kalziqi
POSTED BY: Arben Kalziqi

Tuesday's example of the Hamitonian classical mechanics was in 1 dimensional phase space. How should the code be modified to model n-dimensions?

POSTED BY: Laurence Bloxham

It was in two-dimensional phase space, right? Or perhaps you mean that the phase space path was a plane curve with only one parameter? You can use ParametricPlot3D to plot space curves (for, say, a one-parameter three-dimensional phase space, like observing how position, momentum, and energy change as a function of time) or surfaces (for a two-parameter three-dimensional space).

If you mean the equation-solving itself, then you simply add more equations and variables to the (N)DSolve, though that can quickly increase the solution difficulty of course.

POSTED BY: Arben Kalziqi

Help me with the 2d Hamiltonian: H[q1,q1,p1,p1,t]. q1'=dH/dp1, q2'=dH/dp2, p1'=-dH/dq1, p2'=-dH/dq2 all partial derivatives. Hspace i R^2d+1.

POSTED BY: Laurence Bloxham

Thank you for your help. A Hamiltonian for a particle moving in a plane experiencing a magnetic field orthogonal to the planes is: H[q1,q2,p1,p2]= 1/2m (p1-Bq2)^2 +p2^2.

Seek solution to Hamilton's equations and the general solutions for the trajectory of the particle.

POSTED BY: Laurence Bloxham
POSTED BY: Arben Kalziqi

I am trying to describe the dynamics of a particle confined to the plane. There is no q1 dependence. The trajectories should be circles in the plane with the Larmour frequency. Hope I am making sense. Thanks again.

POSTED BY: Laurence Bloxham

enter image description here

Hi, I am trying to work with the notebook from the "Differential Equations" lecture yesterday. For some reason, when I run the DSolve code, it's giving me this error message: I'm not sure if it's because I ran the code out of order but I tried deleting the notebook and redownloading it and it's still showing this. Any idea of how I can fix this? I'm new to mathematica so I'm sure I'm missing something basic.

I also don't understand why the numbering on the In[#] and Out[#] is continuous throughout all the different notebooks I have. Is there a way to make them separate? Thanks so much!

POSTED BY: Allison Byars

Dear Allison, it seems t has ans assigned value/expression in this case a list. Try clearing the variable, write and evaluate:

Clear[t]

above the differential equation.

POSTED BY: José Dordá
POSTED BY: Arben Kalziqi
Posted 3 years ago
POSTED BY: Phil Earnhardt
Posted 3 years ago

Hi Phil, thanks for the suggestion; I will Reload a Community page before I post next time. It's a good practice in general as I also missed the latest post by Arben Kalziqi.

POSTED BY: Dave Middleton

Hi Phil,

Thank you for your feedback. We have sent you a message on your email address.

POSTED BY: Ahmed Elbanna

There were two questions for previous presenters to which I've just received answers:

A question for Lusine, who gave the talk on number theory:

I would be interested in what is the title of the book about number theory and when the new online course is expected to be launched on number theory mentioned during this session.

Lusine notes that the book is not yet complete and the title has not been finalized, but it will probably have a rather traditional name like Introduction to Number Theory.

A question for Jaebum, who gave the talk on linear algebra and graphs:

I would appreciate if you could mention some references (e.g. books, articles, web pages) that contain already accomplished research topics in Wolfram language related to graphs.

Jaebum has provided three examples:

  1. Analyzing Narratives in Social Networks
  2. Operator Calculus on Graphs, Theory and Applications in Computer Science
  3. Functional Networks with Applications
POSTED BY: Arben Kalziqi

Hi, this is an admin Q.: Thanks for the great series! I have not been receiving any of the links to the session recordings (or even email reminders). Who should I contact to correct this? Thanks!

POSTED BY: Claude Pelletier
Posted 3 years ago
POSTED BY: Phil Earnhardt

Phil is right! We did have an issue with another user's email address on BigMarker's end for some reason, so maybe the same thing is happening to you. We're looking into it!

EDIT: Actually, this was fxed during the minute I typed this post. You should be good to go now.

POSTED BY: Arben Kalziqi

Thanks!

POSTED BY: Claude Pelletier

Hi Claude, I have reached out to our event platform and you should now receive the notification emails. It seems you had unsubscribed from the BigMarker emails at some point.

Please let me know if you have further issues or questions.

Best Wishes, Cassidy Hinkle

POSTED BY: Cassidy Hinkle

Great thanks!

POSTED BY: Claude Pelletier
POSTED BY: Arben Kalziqi
Posted 3 years ago

My brain gets lost in bracket hell with deeply nested [[],[[],[[]]],[[]]] even when they are nicely indented. I find that using postfix operations makes these expressions much easier to understand. E.g.

Of the first 1000 primes which ones have a digit sum that is also prime?

Select[Map[Total, AssociationMap[IntegerDigits, Prime[Range[1000]]]], PrimeQ]

Range[1000] // Prime // AssociationMap[IntegerDigits/*Total] // Select[PrimeQ]

To understand the first one you have to work from inside to out. The second one maps naturally to the question in left-to-right, easy to read, and understand order.

POSTED BY: Rohit Namjoshi
POSTED BY: John McNally
Posted 3 years ago
POSTED BY: Phil Earnhardt

Thanks for the hint regarding the HP41C clone! There are of course downloadable Apps that do (all or mostly) the same for less on your i-phone, but there is something magical about holding an HP41C calculator in your hand and not using your cell phone... I did a lot of solid RF Systems Engineering on my HP 41C before PCs and spreadsheets. I may just have to order one...

POSTED BY: Carl Hahn

Indeed, I wind up doing that myself pretty frequently. The only thing to keep in mind is that f[{x,y,z}]!=f[x,y,z], of course, but if you're defining your own functions it isn't a big problem.

However! If you take advantage of Apply (@@) and MapApply(@@@) and understand how slots work, you can mix and match and get the best of both worlds.

POSTED BY: Arben Kalziqi
Posted 3 years ago
POSTED BY: Peter Fedkiw

Hello Peter,

Thank you for these interesting questions.

  1. The PerformanceGoal option for AsymptoticDSolveValue is set to "Quality" by default, and the "Speed" setting is only used to disallow the use of exact methods based on DSolve, for computing an asymptotic approximation. You will probably not need this option very often but the following rather artificial example illustrates its use in AsymptoticDSolveValue:

    In[1]:= deqns = {y'[x] + Sqrt[x]  y'[x]^2 == 1, y[1] == 1};
    
    In[2]:= AsymptoticDSolveValue[deqns, y[x], {x, 0, 3}]
    
    Out[2]= 1/6 (11 + 5 Sqrt[5]) - 2 Sqrt[x] - x + (2 x^(3/2))/3 - x^2 + 
     2 x^(5/2) - (14 x^3)/3
    
    In[3]:= AsymptoticDSolveValue[deqns, y[x], {x, 0, 3}, 
     PerformanceGoal -> "Quality"]
    
    Out[3]= 1/6 (11 + 5 Sqrt[5]) - 2 Sqrt[x] - x + (2 x^(3/2))/3 - x^2 + 
     2 x^(5/2) - (14 x^3)/3
    
    In[4]:= AsymptoticDSolveValue[deqns, y[x], {x, 0, 3}, 
      PerformanceGoal -> "Speed"] // Head
    
    Out[4]= AsymptoticDSolveValue
    
  2. The leading order approximation for the singular perturbation problem is computed using a simple "closed form" for it based on a discussion in Chapter 9 of Bender and Orszag which works well for second-order linear ODEs for which the coefficient of y'[x] is positive on the given interval. However, as you have noted, the boundary condition at x = 1 is only satisfied asymptotically with this formula. One of the "later" perturbation methods in AsymptoticDSolveValue uses the WKBJ method which yields an approximation that is more complicated but does satisfy the boundary conditions (and also works for higher-order approximations). This method can be accessed as follows:

    In[1]:= eqns = {ep y''[x] + c Derivative[1][y][x] + 
         y[x] == 0, y[0] == 0, y[1] == 1/2};
    
    In[2]:= psol = 
     AsymptoticDSolveValue[eqns, y[x], x, {ep, 0, 1}] /. c -> 2
    
    Out[2]= E^(1/2 + 2/ep - x/2)/(2 (-E + E^(2/ep))) - E^(
     1/2 + 2/ep + (-2 x + (ep x)/2)/ep)/(2 (-E + E^(2/ep)))
    
    In[3]:= psol /. x -> 0
    
    Out[3]= 0
    
    In[4]:= psol /. x -> 1 // Simplify
    
    Out[4]= 1/2
    
    In[5]:= dsol = DSolveValue[eqns /. c -> 2, y[x], x]
    
    Out[5]= -((
     E^(1/ep + Sqrt[1 - ep]/
       ep) (E^((-(1/ep) - Sqrt[1 - ep]/ep) x) - 
        E^((-(1/ep) + Sqrt[1 - ep]/ep) x)))/(
     2 (-1 + E^((2 Sqrt[1 - ep])/ep))))
    
    In[6]:= Limit[dsol/psol, ep -> 0, Assumptions -> 0 < x < 1]
    
    Out[6]= 1
    

    Hope this helps.

POSTED BY: Devendra Kapadia
POSTED BY: Arben Kalziqi

A proposed solution to the exercise.

ebook][1]

Attachments:
POSTED BY: José Dordá
POSTED BY: Arben Kalziqi
Posted 3 years ago

Here's a way to get the SpaceArray without the dreaded index scaffolding:

Two comments:

In past classes, I had been opening the Wolfram Language & System Documentation Center in a browser window. I accidentally opened the docs center in a Wolfram Language window. Opening the help docs in the Wolfram Language app is vastly superior! You can run a line or 2 of code immediately right in the documentation window. Also, you're not thrown by the distraction of browser windows in your Wolfram explorations.

I am not a mathematician; I had difficulty brushing off the cobwebs in the recent Wolfram Calculus Study Group. OTOH, I remembered enough about matrix math to remember that the diagonals next to the main diagonal of a matrix were highly useful -- and there must be a way to access them. There had to be a built-in library function to get to them! It took me a couple of days to find Band. If I had looked in the "See Also" section of the docs for SparseArray, I would have found Band much much faster. There is a brilliance in the design of the WL; great minds have laid out a wonderful... array... of functions.

POSTED BY: Phil Earnhardt
POSTED BY: Arben Kalziqi
Posted 3 years ago

I think it's OK to use Abs to see the "distance" from the diagonal. OTOH, your code ends of applying that test to every cell (or, at least, the calculated value of the coordinates of every cell) in the matrix. You're doing a bunch of superfluous computation; it should be slower:

I'm gonna give that a No Pass.

POSTED BY: Phil Earnhardt
POSTED BY: Arben Kalziqi
Posted 3 years ago

Dear Arben,

Just missed your reply with the solution of Part 1 (no browser refresh).

I joined the Study Group in the second week. Apparently, I posted my solution as someone else (Vitaliy Kaurov, WOLFRAM Research) which is very weird (I used a VPN). The impersonated post is below. I reported the issue to Wolfram Support.
[Update] WR has restored my post attribution.

POSTED BY: Dave Middleton

Thanks for letting us know, Dave—there's a strange issue with Community which sometimes occurs where the original username gets removed, and our "default" username in cases like those is Vitaliy's (ostensibly because he's the Director of Community Engagement).

POSTED BY: Arben Kalziqi
POSTED BY: Carl Hahn

Hi Carl—starting with a recent version of the language, fresh installs no longer come with the documentation by default. If I remember correctly, the user is asked during the installation process whether they would like to download and install local documentation. If not (or if they choose "no"), it's as simple as going to the menu and choosing something like "Download and Install Documentation". You don't—and as far as I know, never will—need a persistent internet connection to access documentation. It's just that the documentation is now on the order of a few gigabytes, so it was decided to leave it out by default and make it an optional installation.

POSTED BY: Arben Kalziqi
Posted 3 years ago

Is it this Arben for the Part 1 code?

Normal@SparseArray[{{i_, j_} /; (Abs[i - j] <= 1) -> 
     PrimePi[i + j]}, {10, 10}] // MatrixForm
POSTED BY: Dave Middleton
Attachments:
POSTED BY: José Dordá

Yes José, that's basically the idea—the only difference is that I used Abs instead of checking whether it was between ±1. I'll check out your notebook when I have the chance, hopefully today.

POSTED BY: Arben Kalziqi

I am curious about the automated proof system you mentioned on Tuesday. Can it detect statements that are unprovable in the current set of axioms (re: Goedel)? Or is that function not computable (Turing/Kleene) hence not doable by computer?

Hi Alexander, in the details section of the documentation of FindEquationalProof, it clarifies this somewhat. In cases where the function is able determine it is not possible to prove the given theorem from the axioms, it will return a Failure object. However, as you mention, in full generality it is not possible to decide this and the only option is to let the program run to see if it terminates. For this reason there is also a TimeConstraint option to impose an artificial limit on how long the function will keep running. You can also manually stop any ongoing evaluation by clicking Abort Evaluation under the Evaluation menu in the user interface.

POSTED BY: John McNally
Posted 3 years ago

In Tuesday's presentation on Special Functions and Visualization, John McNally noted the use of Simplify or FullSimplify but cautioned that FullSimplify can take more time.

Is that really still the case? On modern processors, doesn't FullSimplify simply run fast enough? Do you have a real example where FullSimplify would make a noticeable difference?

POSTED BY: Phil Earnhardt

Hi Phil—hopefully John and Charles were able to answer your question in the webinar chat today. To wit, they mentioned that certain trigonometric simplifications were available via FullSimplify which wouldn't be tried with Simplify, and that this could result in simpler results at the cost of slower speeds. John also mentioned that there are trig-specific simplification functions like TrigExpand which can work several orders of magnitude faster than either of the more general simplification functions.

POSTED BY: Arben Kalziqi
Posted 3 years ago
POSTED BY: Phil Earnhardt

Hi Phil! That's a lovely suggestion; I'll see if I can work it in.

POSTED BY: Arben Kalziqi
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard