2
Math 1A: introduction to functions and calculus Oliver Knill, 2011 A random function of complexity n is obtained by taking n random basic functions
f1 , . . . , fn , and n random basic operators ⊕1 , . . . , ⊕n and forming fn ⊕n fn−1 ⊕n−1
· · · ⊕2 f1 ⊕1 f0 where f0 (x) = x and where we start forming the function from the
Lecture 36: Artificial intelligence right.
Today, we study the intriguing question in AI: 1 Visitor: ”Give me an easy function”: Sofia looks for a function of complexity one: like
x tan(x), or x + log(x), or −3x2 , or x/(x − 3).
What does it take to build an artificial calculus teacher? 2 Visitor: ”Give me a function”:
√ √
Sofia returns a random function of complexity two:
Machines assist us already in many domains: heavy work is done by machines and robots, x sin(x) − tan(x), or −e x + x or x sin(x)/ log(x) or tan(x)/x4 .
accounting by computers and fighting by drones. Lawyers and doctors are assisted by artificial 3 Visitor: ”Give me a difficult function”: Sofia builds a random function of complexity four
√
intelligence. There is no reason why teaching is different. The web has become a ”gigantic brain” like x4 e− cos(x) cos(x)+tan(x), or x− x−ex +log(x)+cos(x), or (1+x)(x cot(x)−log(x))/x2 ,
to which virtually any question can be asked or googled: ”Dr Know” in Spielberg’s movie ”AI” or (−x + sin(x + 3) − 3) csc(x)
is humbled: enter symptoms for an illness and get a diagnosis, enter a legal question and find Now, we can build a random calculus problem. To give you an idea, here are some templates for
previous cases. Enter a calculus problem and get an answer. Building an artificial calculus integration problems:
teacher involves calculus itself: such a bot must connect dots on various levels: understand
questions, read and grade papers and exams, write good and original exam questions, know about A random integration problem of complexity n is a sentence from the sentence
learning and pedagogy. Ideally, it should also have ”ideas” like to ”make a lecture on artificial list { ”Integrate f (x) = F (x)”, ”Find the anti derivative of F (x)”, ”What is the
intelligence”. But first of all, our AI friend needs to know calculus and be able to generate and integral of f (x) = F (x)?”, ”You know the derivative of a function is f ′ (x) = F (x).
solve calculus problems. 1 Find f (x).” }, where F is a random function of complexity n.
4 Visitor ”Give me a differentiation problem”. Sofia: Differentiate f (x) = x sin(x) − 1
x2
.
Generating calculus problems The answer is x23 + sin(x) + x cos(x).
5 Visitor: ”Give me a difficult integration problem”. Sofia: Find f if f ′ (x) = 1
x
+
Having been involved in a linear algebra book project once, helping to generating solutions to 3 sin2 (x) + sin(sin(x)) cos(x). The answer is log(x) + sin3 (x) − cos(sin(x)).
problems, I know that some calculus books are written with help of computer algebra systems.
They generate problems and solutions. This applies mostly to drill problems. In order to generate
6 Visitor: ”Give me an easy extremization problem”. Sofia: Find the extrema of f (x) =
problems, we first must build random functions. Our AI engine ”sofia” knew how to generate x/ log(x). The answer is x = e.
random problems with solutions. Random functions are involved when asked ”give me an example 7 Visitor: Give me an extremization problem”. Sofia: Find the maxima and minima of
of a function”. This is easy: the system would generate functions of reasonable complexity: f (x) = x − x4 + log(x). The extrema are
v !
√ √ u √ √
u
Call the 10 functions {sin, cos, log, exp, tan, sqt, pow, inv, sca, tra } basic functions.
q 2/3 2/3 r
3 3 2
√ 9 + 3153 − 8 6 + 8 6 − 9 + 3153
t 1+6 √ q √
9+ 3153−8 3 6(9+ 3153)
Here sqt(x) = x and inv(x) = 1/xk for a random integer k between −1 and −3, pow(x) = xk for
a random integer k between 2 and 5. sca(x) = kx is a scalar multiplication for a random nonzero − √ p 6
√ .
integer k between −3 and 3 and tra(x) = x+k translates for a random integer k between −4 and 4. 225/6 3 3 9 + 3153
The last example shows the perils of random generation. Even so the function had decent com-
Second, we use addition, subtraction multiplication, division and composition to build more com-
plexity, the solution was difficult. Solutions can even be transcendental. This is not a big deal:
plicated functions:
just generate a new problem. By the way, all the above problems and solutions have been gen-
A basic operation is an operation from the list {f ◦ g, f + g, f ∗ g, f /g, f − g }. erated by Sofia. The dirty secret of calculus books is that there are maybe a thousand different
type of questions which are usually asked. This is a reason why textbooks have become boring
The operation xy is not included because it is equivalent to exp(x log(y)) = exp ◦(x · log). We can clones of each other and companies like ”Aleks”, ”demidec” etc exist which constantly mine the
now build functions of various complexities: web and course sites like this and homework databases like ”webwork” which contain thousands
of pre-compiled problems in which randomness is already built in.
1In the academic year of 2003/2004, thanks to a grant from the Harvard Provost, I could work with under-
graduates Johnny Carlsson, Andrew Chi and Mark Lezama on a ”calculus chat bot”. We spent a couple of Automated problem generation is the ”fast food” of teaching and usually not healthy.
hours per week to enter mathematics and general knowledge, build interfaces to various computer algebra systems But like ”fast food” has evolved, we can expect more and more computer assisting
like Pari, Mathematica, Macsyma and build a web interface. We fed our knowledge to already known chat bots in calculus teaching.
and newly built ones and even had various bots chat with each other. We conceptionally explored the question of
automated learning of the bots from the conversations as well as to add context to the conversation, since bots Be assured that for this course, the problems have been written by hand (I sometimes use Mathe-
needs to remember previous topics mentioned to understand some questions. We learned how immense the task is.
In the mean time it has become business. Companies like Wolfram research have teams of mathematicians and
matica to see whether answers are reasonable). Handmade problems can sometimes a bit ”rough”
computer scientists working on content for the ”Wolfram alpha” engine. Having recently seen a group at work here but hopefully some were more interesting. I feel that it is not fair to feed computer generated
in Cambridge on Mass Av, I guess they generate probably in one day as much content as our Sofia group could do problems to humans. It is possible to write a program giving an answer to ”Write me a final
in a week for our ”pet project”. exam”, but the exam would be uninspiring.
1
3 4
One such a step defines a Chaikin step. The limiting curve is called the Chaikin curve defined
Corner detection by the original points. The picture should explain how we get the new points from the old ones:
divide each segment into 4 pieces and use the two outer points to get new points.
How do we detect corners in pictures? This is necessary to understand pictures, drawings. It
might also be needed to see whether a given function is reasonably shaped. There should not be
too many ”wiggles” for example. There are various techniques to measure that. One of the best
methods in computer vision uses the notion of curvature:
Given a function f (x), define the curvature as
f ′′ (x)
k(x) = .
(1 + f ′ (x)2 )3/2
Is is a measure on how much the curve is bent at the point (x, f (x)). Positive curvature means
the curve is concave up, otherwise concave down.
The Chaikin steps produce a smooth curve approximating a given set of points.
8 For a quadratic function f (x) = x2 , we have κ(x) = 1/(1 + x2 ). We see that the curvature
is maximal at the lowest part of the parabola.
√ √
9 For the function f (x) = 1 − x2 , we have f ′ (x) = −2x/ 1 − x2 and f ′′ (x) = −(1−x2 )−3/2 .
We have (1 + f ′ (x)2 ) = 1/(1 − x2 ) and k(x) = −1.
10 Problem: Find the curvature for the graph of f (x) = x5 /5 − x. Where is the curvature
maximal?
4
1.0
6
4
3 0.5
2
The pictures show curves in two and three dimensions after applying the method a few times.
2
-1.0 -0.5 0.5 1.0 -1.0 -0.5 0.5 1.0
The method can be used for example to study the complexity of random knots. To answer the
-2
question stated initially: like artists have become better using computers it could well be that
1 -0.5
-4 AI will assist teachers in the future and help them to be more efficient.
In any way, the AI dragon breathing down our necks will force us all to stay creative.
-6
-1.0
-2 -1 1 2
Connecting the dots Homework
We want to connect points P1 , . . . , Pn by a smooth graph. This ”connecting the dots” problem
is quite frequent. Our brain does this automatically. We need to see a few glances to ”see” the
1 A calculus bot wants to build a differentiation problem by combining log and sin and exp.
motion of an object and predict where it will end. We need to connect dots if we drive a car, if we Differentiate all of the 6 combinations log(sin(exp(x))), log(exp(sin(x))),exp(log(sin(x))),
interpret a picture etc. On a more abstract level, we need to connect dots in the landscape of ideas exp(sin(log(x))), sin(log(exp(x))) and sin(exp(log(x))).
whenever we solve a problem. We want to go from A to B and need to construct intermediate 2 Four of the 6 combinations of log and sin and exp can be integrated as elementary functions.
steps. Do these integrals.
Here is a simple method found by G. Chaikin in 1974 2 which generates a smooth curve through 3 Find the curvature of the sin curve at x = 0, x = π/2 and x = 3π/2.
a few points.
4 Draw the points (0, sin(0)), (π/2, sin(π/2)), (π, sin(π), (3π/2, sin(3π/2)), (2π, sin(2π)) and
Given a sequence of n points P1 , ..., Pn define a new sequence of 2n − 2 points connect them with lines. Now do Chaikin iteration for at least 2 generations on paper.
R2 , ..., R2n−1 by 5 Answer each of the following 5 human questions in one sentence:
3 1 1 3
R2i = Pi + Pi+1 , R2i+1 = Pi + Pi+1 a) What is calculus for you?
4 4 4 4 b) What is the nicest application of calculus?
for i = 1, ..., n − 1.
c) Who invented calculus and why?
d) What is the fundamental theorem and why is it useful?
2G. Chaikin, An algorithm for high speed curve generation. Computer Graphics and Image Processing 3 (1974),
346-349.