This is a wonderful resource with lots of video lectures in science and mathematics

# Tag Archives: math

## Creating a Mathematica demonstration on Fermat’s Theorem on Stationary Points

One of the new features of Mathematica 6.0 and above is that it allows you to create a new type of Mathematica notebook called a Mathematica Demonstration.

A Mathematica Demonstration usually consists of some sort of animation that can be manipulated thru some windows controls on the notebook. This is created using some new Mathematica 6.0 code.

The main part of the code is contained within

**Manipulate[]**

The Manipulate command resembles the Animate [] command of prior Mathematica versions. The main differences is that with Manipulate you may be able to use all the control types while with the Animate[] you may control one or multiple parameters with slider control.

When I got Mathematica I wanted to try my hands at creating a new Demonstration and I decided to create a demonstration on Fermat’s Theorem on Stationary Points.

This is a very beautiful theorem that states

*If c is a local extremum in the interval (a,b) and f is differentiable at c, then f’(c)=0.*

There is a very simple geometric interpretation of this theorem. As we know the first derivative of a function f could be interpreted as the slope of the tangent line thru the point (c,f(c)) if such derivative exist. When the slope of the tangent line is zero f’(c)=0.

My basic idea for the demo was to build a line segment tangent to a point c and I could vary the position of the point c and the line segment tangent will get redraw.

I wanted to build the segment so that the length from (c,f(c)) to each of the ends of the segments was the same or that (c,f(c)) was the mid point of the segment. To accomplish this I figure the derivative of f at a point c and then computed the equation of the tangent line to f at c and then found the intersection of that line with a unit circle center on (c,f(c)). So the resulting Mathematica code looks like this nightmare!

**Manipulate[
Plot[2 Sin[x] + x, {x, 0, 2 Pi},
Epilog -> {{Line[{{(
2 c + 4 c Cos[c] + 4 c Cos[c]^2 -
Sqrt[2] Sqrt[1 + 2 Cos[c] + 2 Cos[c]^2])/(
2 (1 + 2 Cos[c] + 2 Cos[c]^2)), (2 Cos[c] + 1) ((
2 c + 4 c Cos[c] + 4 c Cos[c]^2 -
Sqrt[2] Sqrt[1 + 2 Cos[c] + 2 Cos[c]^2])/(
2 (1 + 2 Cos[c] + 2 Cos[c]^2))) + 2 Sin[c] +
c – (2 Cos[c] + 1) c}, {(
2 c + 4 c Cos[c] + 4 c Cos[c]^2 +
Sqrt[2] Sqrt[1 + 2 Cos[c] + 2 Cos[c]^2])/(
2 (1 + 2 Cos[c] + 2 Cos[c]^2)), (2 Cos[c] + 1) ((
2 c + 4 c Cos[c] + 4 c Cos[c]^2 +
Sqrt[2] Sqrt[1 + 2 Cos[c] + 2 Cos[c]^2])/(
2 (1 + 2 Cos[c] + 2 Cos[c]^2))) + 2 Sin[c] +
c – (2 Cos[c] + 1) c}}]}, {Darker@Red, PointSize[0.015],
Point[{c, 2 Sin[c] + c}]}},
PlotLabel ->
Style[StringJoin["slope: " , ToString[N[2 Cos[c] + 1]]], 12],
AspectRatio -> Automatic, ImageSize -> {500, 400},
AxesLabel -> {Row[{Style["x", Italic], ” value”}],
TraditionalForm[2 Sin[x] + x]}], {{c, 2.08979, “value c”}, 0,
2 Pi}]**

I have decided to simplify the code a bit to make the code more readable.

**f[x_] = 2 (Sin[x]) + x;
d[x_] = D[f[x], x];
r = 1.5;
p1 := x /. Solve[(x -
c)^2 + ((d[c]) x + (f[c] – (d[c]) c) – (f[c]) )^2 == r^2,
x][[1]];
f1[c_] = p1;
p2 := x /. Solve[(x -
c)^2 + ((d[c]) x + (f[c] – (d[c]) c) – (f[c]) )^2 == r^2,
x][[2]];
f2[c_] = p2;
SetOptions[Plot,
Ticks -> {{-1, 0, 1, 2, 3, 4, 5, 6, 7}, {-1, 1, 2, 3, 4, 5, 6, 7}},
PlotRangePadding -> 1.5, AspectRatio -> Automatic,
Background -> Black, ImageSize -> {640, 480}, AxesLabel -> {x, y},
AxesStyle -> Directive[20, Thick, Orange]];
Manipulate[
Show[Plot[f[x], {x, -1, 2 Pi},
Epilog -> {
Inset[
Style[StringJoin["value:", ToString[N[c]]], Yellow, 20], {2, 7},
Alignment -> Center],
Inset[
Style[StringJoin["Slope:" , ToString[N[d[c], 5]]], Yellow,
20], {2.5, 6.5}],
If[lin, {Thick, Dashed, Green, Line[{{c, 0}, {c, f[c]}}]}, {}],
If[lin && der, {Thick, Dashed, Green,
Line[{{c, 0}, {c, d[c]}}]}, {}],
If[circle, {White, Circle[{c, f[c]}, r]}, {}], {Thick, Yellow,
Line[{{f1[c], (d[c]) (f1[c]) + f[c] – (d[c]) c}, {f2[
c], (d[c]) (f2[c]) + f[c] – (d[c]) c}}]},
If[der, {Red, PointSize[0.02], Point[{c, d[c]}]}, {}],
{Red, PointSize[0.02], Point[{c, f[c]}]}}
,
(*PlotLabel->Style[StringJoin["value:",ToString[N[c]],” “,
“Slope:” ,ToString[N[d[c],5]]],Yellow,20],*)
PlotStyle -> Directive[Red, Thick]
], If[der,
Plot[d[x], {x, -1.001, c}, PlotStyle -> Directive[Blue, Thick]
], {}
]
], {{c, (2 \[Pi])/3, “Value c”}, -1, 2 Pi,
0.001}, {{circle, False, “Show Circle”}, {False, True}}, {{der,
True, “Show Derivative”}, {False, True}},
{{lin, True, “Show line”}, {False, True}}]**

And I also added three check boxes to be able to see the graph of the derivative of the function f(x) and also to be able to see the circle.

The original mathematica demonstration I created is at Wolfram demonstration.

Filed under math, Mathematica

## One easy problem and One not so easy problem.

A few post ago we used Mathematica to draw the altitudes of an arbitrary triangle of given coordinates. Now we are solving these other two problems The first figure the red lines represent the medians and on the second figure the yellow lines represent the angle bisectors. So our problem consist in finding the Mathematica code to produce these figures.

Let us do the easy one first. To draw a triangle and the medians we will use the Lineal Bezier equation we have use before and since we are interested in finding the mid points on each side the resulting Mathematica code is very simple.

**a = {0, 0};
b = {3, 0};
c = {1, 2};
BAB[t_, a_, b_] := (1 – t) a + t b;
Graphics[{Background -> Black,
{{Thick, Blue, Line[{a, b, c, a}]},
{Thick, Red, Line[{c, BAB[1/2, a, b]}]},
{Thick, Red, Line[{a, BAB[1/2, c, b]}]},
{Thick, Red, Line[{b, BAB[1/2, c, a]}]}
},
Inset[Text[Style["A", White, Italic, Large]], {-.1, 0}],
Inset[Text[Style["B", White, Italic, Large]], {3.1, 0}],
Inset[Text[Style["C", White, Italic, Large]], {1.1, 2.1}]}]**

Now for the angle bisectors it is a bit harder. We are going to need some property the bisectors satisfy that will allow us to get the coordinates of the intersection of each bisector with each of the sides. One property that could help us is this one.

**Theorem:** For a triangle *ABC* If *CQ* is the bisector thru the angle *ACB *then *AC/CB*=*AQ/QB*.

Notice we will need to find some distances between sides that are given by coordinates so the function EuclideanDistance will be of help. Since we can easily compute AC/CB we need to find Q in AB such that AQ/QB is equal to AC/CB but this is not difficult to achieve if we use the function Nearest. We can guess the best value of Q by building a table where Q is going from A to B and then we pick the best value that approaches to the ratio AC/CB. We can accomplished that with the following Mathematica Code.

**a = {0, 0};
b = {3, 0};
c = {1, 2};
ac = EuclideanDistance[a, c];
bc = EuclideanDistance[b, c];
ab = EuclideanDistance[a, b];
cc = ac/bc;
BAB[t_, a_, b_] := (1 – t) a + t b;
N[cc];
tabl = Table[
EuclideanDistance[a, BAB[t, a, b]]/
EuclideanDistance[b, BAB[t, a, b]], {t, 0.000001, 1, 0.001}];
nearest = Nearest[tabl, N[cc]];
Flatten[Position[tabl, First[nearest]]] **

that will give us the value 443 that we will use in conjunction with the 0.001 doing similarly for the other sides of the triangle we get the very compact solution

**a = {0, 0};
b = {3, 0};
c = {1, 2};
BAB[t_, a_, b_] := (1 – t) a + t b;
Graphics[{Background -> Black,
{{Thick, Blue, Line[{a, b, c, a}]},
{Thick, Yellow, Line[{c, BAB[443*0.001, a, b]}]},
{Thick, Yellow, Line[{a, BAB[428*0.001, c, b]}]},
{Thick, Yellow, Line[{b, BAB[486*0.001, c, a]}]}
},
Inset[Text[Style["A", White, Italic, Large]], {-.1, 0}],
Inset[Text[Style["B", White, Italic, Large]], {3.1, 0}],
Inset[Text[Style["C", White, Italic, Large]], {1.1, 2.1}]}]**

Again this time Nearest comes to the rescue and helps us get the best value from a list of possible values!

Filed under geometry, math, mathematics

## Some Phun Links!

These are the links to the Phun scenes on our lecture

Are you having phun Yet?

Filed under math

## Livio’s Mathematical Creations with Phun

## Are you having Phun Yet?

In my last Post I mentioned the incredible physics sand box or physics reality simulator Phun . Here I will explain in some detail one scene created with Phun.

When you build physical simulations in Phun you are creating a visual representation that is attached virtually near physical behavior. In a way you are actually building graphically a very sophisticated computer program where each element have physical properties. Like being able to move, collide, bounce, gravity, velocity, acceleration etc. Naturally the simulation is no perfect but is very close to reality and that is what makes it very surprising and I believe useful. It’s almost like using Lego blocks but this time you can build the building blocks by yourself!

I will name the process of building scenes “* Phun programming*” for the above reason and by extension a Phun programmer is he who creates a scene.

While many of the Phun programmers restrict them self to creating rockets and tanks some others have dedicated their time to create ingeniously intricate mechanism. I am still in complete awe by some of the mechanical things that people have created with Phun. Between those prolific creators I have found Livio Zucca from Turin Italy the home of world fame mathematician Giuseppe Peano. I believe Livio’s creations deserve more attention for his ingenuity.

In my prior post about the Pascal triangle with Phun I extended a prior idea from Livio. The machine in question is a binary mechanical counter.

The main component to perform computations in this particular device is what is know as a latch and it should not be confused with a flip-flop. The main difference between latch and flip-flop is that latches are transparent storage elements while flip-flops are not. Wikipedia point out this new distinction.

In the above picture you can see a magnified section of the machine. This we called the ** ball feeding mechanism** and it’s function is to collect balls and feed them up the two dimensional vertical tube on the left.

Let us explained in a bit of detail how this is achieve with Phun.

In Phun you can simulate gravity and can also simulate movement. You can define two types of hinges. The normal kind that is just a hinge that hinges and there is the one that can act as an engine or motor. This is just a programmatic simplification on Phun’s designer part. It will be nice if there was some visual differentiation between them but at the moment there is none.

The crosses are used to attached things so they will not fall off the scene when gravity acts upon them.

Notice the green bar at the bottom of the picture. That bar acts as the collector of balls and it does have a very slight inclination this is useful in this design as it makes the balls roll slowly towards the left where the feeding mechanism is located.

You can also see a spring and I guess you must probably already know what a spring does!

and at last the actual latch

The latch acts like a balance and there is a hinge that can be visible if you magnify the picture a little bit more. The numbers have a double function in this particular case. They act as stoppers for the balancer and also as indicators of the state of the latch. As portrait above this latch is in 0 state.

As you probably know latches have two states. One can be use to represent 0 state as in this case and the other can be use to represent 1.

The latch alternates between this two states as you can see in the animation below.

You may also appreciate the mechanism for translating circular motion into linear upward motion on the left side. This mechanism brings back memories of the mechanism that provided steam locomotive with motive power in time past.

As you may have already guess by the picture of the machine and the name the function of this particular mechanism is to count balls dropping down from the device and this is done using the binary numerical system. The binary system is a numerical positional system that uses only two digits instead of the 10 digits we use in our decimal numerical system.

For educators Phun will be a source of inspiration. I believe it is very useful for the instruction and motivation of Mathematics,Physics, Computer Science, Mechanical Engineering,Electronics. Phun is opening a new universe of interactive learning and should I dare also say FUN!

If you like to play,run or modify the Scene above in the Phun simulator you can download the Phun program and the scene from

If you like to see a short video of my modification then go

Filed under math

## Triangular Numbers (Part III)

Going back once more to the original problem of finding a formula to compute the triangular number.

Triangular numbers suggest by their name the idea of geometry and it should be interesting to try apply some geometric reasoning to solve the problem. As we explained in the first lecture triangular numbers are obtained when we arrange a number of stones in an equilateral triangular shape. It just happens that it is very convenient for us to re arrange those stones in another triangular shape. That is right angle triangle. In that way we are able to produce triangular numbers and it become very simple to arrange the stones in a two dimensional array of stones that could be easily counted. Now we will see how the geometric demonstration works for

First, we duplicate the number of stones so we have and conveniently rotating the second we can joint the first and we have as a result a rectangular shape.

The number of stones in that rectangular shape is very easy to compute. It will be the product of the number of stones in two sides. In this case and since we have duplicated the original number now we need to divide by 2 and that will us the value The same procedure could be carry out for 100 stones or any other number. We do not suggest you do this literally for 100 stones, but you should be able to play this same argument in your mind.

In the previous example we were extremely close to form a square number. We actually missed this by just one row. That is why we have the factor. A natural question to ask is.

What should we add to any triangular number to get a square number?

We can see it in the diagram. What we need is to add the prior triangular number! We can express this algebraically with the following relation

What this formula is saying is that the sum of two consecutive triangular numbers is an square number. We can verify that this is true since and also It is easy to see from the geometric configuration why the sum of two consecutive triangular numbers is an square. Since is something we are interested in finding then the relation seems to be also a kind of equation where the unknown to be found is . Notice also that appears on the equation. Naturally if we know how to compute we then also know to compute Equations of this type are known as recursive equations. The last row of will be the diagonal since subtracting the diagonal the resulting triangular number is equal to We can also write another relation

Now these two equations are defining in terms of the prior triangular number These type of relations are called recurrence equations and we will discussed them in more detail in some other lecture. For now let us try and see if we can solve the first equation.

(This is a partial transcription of the Video Lecture Triangular Numbers (III) the video continues displaying a Solution)

Filed under math, mathematics, number, triangular number

## Triangular Numbers (Part II)

In the prior lecture we have shown how Gauss solved the problem of

**finding the sum **

In Gauss solution we reduce the problem of finding the sum of different natural numbers to the problem of finding the sum of 50 equal numbers. It is very natural in mathematics to generalized concepts and results. A natural small generalization of the prior result will be to

**find the sum **

of the first natural numbers. It is also a natural impulse to try and solve similar problems with analogous solutions. In this case we will try to solve the problem using the same idea as Gauss with a very small modification. As in the prior lecture let us call the triangular number. We can easily re arrange the order of the elements in the addition in reverse order. Therefore we can write If we add this two equalities we get

as in Gauss solution to the problem we have found again that adding a number from the beginning of the sequence to one number from the end of the sequence the sum stays constant. The right hand side of the equality is also very easy to compute. Since we have of those terms therefore

This solution was easy to find because the solution is base on the same idea as Gauss’s solution. For the special case we have already point out why Gauss’s solution works and the same is true here. The solution works by translating the problem of finding the sum of different numbers to the problem of finding the sum of equal numbers and we are able to produce the equal numbers by conveniently re arranging the numbers in the sequence. In both cases we are dealing with sequences of consecutive natural numbers.

Could we generalize this a little bit more?

Yes, we can. What if instead of a sequence that starts on one we get a sequence that starts on and we obtain the next element by adding a constant natural number So the elements of this progression will be

this progression is a bit more general than the sequence of natural numbers. First, it does start on an arbitrary number and the difference of two consecutive terms is instead of 1. Progressions that satisfy this conditions are called arithmetic progressions. Example of arithmetic progressions are

In this case the first element is 1 and the value for is also 1.

Another example is

In this other example the first element is 2 and the increment is by . So we obtained each term by adding 2.

Can we find a formula for the sum of the first terms of the arithmetic progression?

That is to find

where for from 1 to to find this formula we suspect that we may be able to find some invariant as before …

(This is a partial transcription of the Video Lecture Triangular Numbers (II) the video continues displaying a Solution)

Filed under math, mathematics, number

## Triangular Numbers (Part I)

Going back in history more than two thousand years. Pythagoras and the Pythagoreans were interested in establishing relations between geometric figures and numbers.

If you take one, one and two, one two and three stones and arrange them in a particular way. You may be able to produce triangular figures. This is now believe to be the origin of the *“ triangular numbers“, “*

*and other*

**the square numbers**“**.**

*figured numbers*Triangular numbers are obtained when we arrange a number of stones in an equilateral triangular shape. As we can see in the figure we have the first three triangular numbers. One, three and six. The first triangular number is one. The second triangular number is three. To obtained three we need to add one and two. To get the third triangular number. We add one plus two plus three.

Can you guess now the next triangular number?

Yes, you guess right!

The next triangular number is ten. Ten is the result of adding one plus two plus three plus four. So there is an intimated relationship between triangular numbers and the sum of consecutive natural numbers.

If we call the triangular number, then we can define the triangular number to be the number obtained when we add the natural numbers . From our definition of triangular numbers, we can see a direct link between triangular numbers and the sum of the first consecutive natural numbers.

It will be nice to find a short-cut that will allow us to compute easily the sum of the natural numbers . A problem similar to this was solve a long time ago by a very young child. He became later in life one of the greatest mathematicians in history.His name was Carl Friedrich Gauss.

The story goes that his teacher Butner, wanted the students busy working on additions for a while so he asked the students to compute a lengthy sum and for that he choose the numbers in a way that he could easily verify the answers himself, without having to do the full computation.

To his astonishment one of the students finished the addition with the correct answer in a very short time. Obviously that student could not have possibly added the one hundred numbers in such a short time. That student had to have a very simple and brilliant idea that allowed him to easily solve the problem.

The teacher immediately understood how bright this student was and from that moment forward pay special attention to develop that student’s talent.

If you have not seen this problem before. Now you have the opportunity to solve the same problem that Gauss solved when he was young! Stop the lecture and try finding the sum of the first one hundred natural numbers. That is,

Find the sum

(This is a partial transcription of the Video Lecture Triangular Numbers (I) the video continues displaying Gauss’s Solution)

Filed under math, mathematics, number, triangular number, video podcast

## San Gaku (Sangaku)

**Japanese Temple Geometry**

During the Edo period Japan was isolated from other countries. In this period of isolation Japanese mathematical results flourished mainly in the form of geometric theorems written in tablets offered in temples.

The majority of the problems appearing on tablets are geometric problems and most of them are problems where certain geometric configuration of circles and triangles are given and it is asked to find a quantity like the radius of a circle or the side of the triangle or the diagonal of a quadrilateral.

Many of these Japanese problems are available in English in a Canadian book now out of print.

The book is

Japanese Temple Geometry (San Gaku) by Hidetosi Fukagawa and Dan Pedoe

There is also a publication available for free in PDF form of many problems that can be obtained from

Japanese Temple Mathematical problems in Nagano Pref. Japan

This publication is divided into 5 PDF files and contain many problems

Some more links to Sangaku

Filed under geometry, math, mathematics

## Inexpensive Modern Geometry Books by Dover

One of the things I hate and I am talking hate here, is when wonderful books go out of print and they become hard to get. I spend a considerable amount of time looking for two geometry books that I have seen and wanted to owned for a very long time. This two books are amazingly beautiful Geometry books. The books are

and

Advanced Euclidean Geometry by Roger A. Johnson

I was able to find College Geometry by Nathan by chance, while I was browsing thru stacks of old neglected books in a used book store close to my home and I got it for just about 10 dollars (hard cover edition from 1925) in very good condition!

I have seen on used book sites people selling this amazing books for about 100 dollars or more but I was not willing to depart with my price book! Not for 100 or even more.

As for the second book I place a search want at a used books internet seller and was able to get it after some years from some book seller in California for about 6 dollars. Never mind that I have seen people asking more than ten times that value somewhere in the internet.

But wait no more. Dover books has published both books again. In paper back at a very reasonable price! each about 16 dollars but amazon will sell them both for about 28 dollars.

If you do like theorems like the nine point circle, Ptolemy’s theorem, Simson line, Menelaus Theorem, Ceva’s theorem then these are the books to get.

This is a blog posting from www.isallaboutmath.com

Comments Off

Filed under geometry, math, mathematics