Mathematica project
The mathematica project is
online. It is a file lab2025.nb.
Save it and use Mathematica to open it. We will use part of the lecture on Tuesday 7/29
for a mathematica workshop.
The project is due at midnight on Saturday August 2, 2025. The 4 problems are located at the
end of the notebook.
AI
While AI has become ubiquitous, you shall not use it
to solve your homework problems nor do your final project. There might be one or the other
problems, were we explicitly ask you to use it however. We were more lenient
years ago, when agents were still stupid but these times are now long gone.
The reason is common sense: you simply do not learn to think nor how to solve problems
by just having somebody else solve the problems for you. This is no more education, it is is becoming a dependent.
We all know what AI can do by now. The world has in the last 3 years seen emerge more and more powerful agents.
Almost the entire population of our planet has used it and knows what it can do. You are even forced to use it without
consent because it has crept into search engines and our phone, for the better and worse. You never will get a job by
claiming that "you know AI". Since fall 2022, everybody who can read and write knows that.
After years of experience using AI in education (for me now
22 years now, see
See this talk from 2007 for high
school students), we all know that it eventually could make us dependent. Like
drugs, it temporarily can made us feel high and powerful. Once the "high" is over, it makes
us depressed and weak and powerless. The tools have started to enslave us. Writing a paper or a homework
using AI is like doing a mountain climb with the helicopter or running a marathon with the car. It is not
an achievement at all. In this course, we have in class proctored assessments (midterms and finals) that must be done
without any tools. It will be important to keep human intelligence alive. Why? Because once, the drug dealers giving the
stuff away for free will start charging for ``stronger stuff" and
``stretch the material" with advertisement, propaganda and spin, to whoever party pays most. The investments
of course will have to give a return. This return will also be control and power and influence.
We need to learn and relearn again and again to think for ourselves. Our future might depend on it.
Computers have helped us more and more in the last decades. It started to explode
in the 1940ies when the first mechanical, electric and then electronic computers
became available. Computer algebra systems developed in the 1960ies have grown more and more sophisticated.
[I personally have used technology related to math since more than 50 years: calculators first around 1973,
I used programmable calculator since 1977, the first PC in 1980, used the first Unix machine and email
in 1984, had course websites since 1994 and experimented with math AI bots in 2003].
AI developments started in the 1970ies too. After a shorter AI winter, it reemerged at the beginning
of the 21st century.
The last few years, large language models or stable diffusion type transformer
production tools have surprised everybody with their abilities. We have
learned enough during the last 3 years, that we need to refrain from using it for homework or projects and
test abilities in person without any access to technology. Doing the thinking on your own is like doing a hike
in person without car, it is like climbing a wall without taking the cable car. Of course, it is fun too to
climb a mountain with the helicopter, it is just that one can quickly observe whether a person can run a marathon
or whether the person can drive a marathon with the car.
The project
Using computer algebra systems can also be seen as part of AI, but there is a big difference: writing code by yourself
is like writing mathematical text. Writing beautiful code is like writing a poem.
Coding is using a language. Of course, AI has become great also in programming computer
algebra systems, but again, also here in Math S 21a, we do not want students to use it. When modern AI had been less than 1 year old
(like summer 2023), we had experimented with allowing students to use it. It turned out that the learning experience for
those who have, has been diminished considerably.
The
Toothbrush example from 2003 is
documents how stupid AI still had been back in 2023. It has since increased its abilities continuously.
Again, it is no achievement to know, how to copy-paste. It is like claiming
that you can speak a language and have a translator do it for you, or claim to be able to play the piano and have the piano
play it for you or have a machine summarize or even write a book for you. As for the future of computer science:
I predict that we will get back to evaluating students having to write code in in-person exams without
any tools. (Remote exams are today trivial to beat even if students are monitored with video)
I myself had to write code as a student in proctored in-person exams. (It was a CS 50-like two semester course at ETH).
We were given a task to program something and we had - with paper and pen - write down the Pascal code (without any
notes or references. We had to demonstrate not only to read the language but to write it, by heart).
Back to the project: also this year, we will have - as usual - a creative Mathematica project
in Math S 21a at the end of the course: the focus is on creativity and it is take-home but
discussion among students and student-faculty interaction is strongly encouraged for doing the project.
Most students have in the last 22 years been able to do the project quickly, once they know what to do.
There will be the usual support: a short workshop and special office hours.
Mathematica Installation
Harvard has a site licence available
also for Summer school students.
You need a
Harvard Student email.
If you have trouble with that, HUIT in the science center can help you.
Here is a website about IT and Email services.
- You can get Mathematica from here.
There are instructions there to download and install Mathematica. Use the latest Mathematica version 14.1.
- Go here
to make an account (use your Harvard summer school email address).
Once you start Mathematica the first time, you need to log in to the portal. The activation
should then go automatic.
- Please network around if you have trouble. Time before class, during the break or after class are
good opportunities to help each other.
Mathematica
- Here is an example to check that a function satisfies a differential equation.
In this case we check that a Gaussian with variance t satisfies the heat equation.
f[t_,x_]:=(1/Sqrt[t])*Exp[-x^2/(4t)];
FullSimplify[D[f[t,x],t] == D[f[t,x],{x,2}]]
|
One can do the same computation but give the function f as an expression
and not a rule. We add Clear[f] before so that the
previous definition does not interfere.
Clear[f];
f=(1/Sqrt[t])*Exp[-x^2/(4t)];
FullSimplify[D[f,t] == D[f,{x,2}]]
|
Extrema
Here is the procedure mentioned this morning to
get a list of critical points of a function. Just copy paste
the following lines into a notebook and evaluate:
f = x^3 y + y^3 x - 4 x*y; X = {x, y};
ClassifyCriticalPoints[f_, {x_, y_}] := Module[{X, P, H, g, d, S},
P = Solve[ {D[f, x] == 0, D[f, y] == 0}, {x, y}];
H = Outer[D[f, #1, #2] &, {x, y}, {x, y}]; g = H[[1, 1]]; d = Det[H];
S[d_, g_] := If[d < 0, "saddle", If[g > 0, "minimum", "maximum"]];
TableForm[{x, y, d, g, S[d, g], f} /. P,
TableHeadings -> {None, {x, y, "D", "f_xx", "Type", "f"}}]]
ClassifyCriticalPoints[f, {x, y}]
To solve a Lagrange problem
F[x_,y_]:=2x^2+4 x y; G[x_,y_]:=x^2 y;
Solve[{D[F[x,y],x]==L*D[G[x,y],x],
D[F[x,y],y]==L*D[G[x,y],y],G[x,y]==1},{x,y,L}]
Plotting
Plot3D[ Sin[x*y],{x,-2,2},{y,-2,2}]
ParametricPlot3D[ {z Cos[t],z Sin[t],z},{t,0,2Pi},{z,-1,1}]
ContourPlot3D[ Abs[x]+Abs[y]==1,{x,-2,2},{y,-2,2},{z,-2,2}]
|
PDE simplification
Here is an example on how to check a PDE with mathematica.
Sometimes, one has to use Full Simplify rather than simplify.
Here is one possibility to do things
f[t_,x_]:=(1/Sqrt[t])*Exp[-x^2/(4t)];
FullSimplify[D[f[t,x],t] == D[f[t,x],{x,2}]]
|
Here is the same computation, where the function g is just given
as an expression. I was putting a Clear[f] before so that the
previous definition would not interfere.
Clear[f];
f=(1/Sqrt[t])*Exp[-x^2/(4t)];
FullSimplify[D[f,t] == D[f,{x,2}]]
|