Mathematics is Beautiful...
It should be explored and enjoyed !

WOLFRAM MALAYSIAN TECHNOLOGY TOUR
SCHOOL OF MATHEMATICAL SCIENCES, USM
18 NOVEMBER 2016

| Yazariah Mohd Yatim

Visualizing mathematics...
Overcoming a fear of math

- Fear of numbers, symbols, etc.

- Maths has no relevance in daily life

- Memorizing the formulas without completely understanding the underlying concept

- People cannot ‘see’ maths

But, maths is one of the most beautiful things in the world!
And maths is all around us!

Please watch this Youtube video: 
The Catenary - Mathematics All Around Us (by James Grime - singingbanana)
https://youtu.be/AYIQYZuQNMw

Finding the intersection points

We have two functions: 
		r(θ)=2(1+cos(θ)) for 0⩽θ≤2π, and 
s(θ)=6 cos(θ)  for –π/2⩽θ⩽π/2

Clear[r,s];
r[θ_]:=2(1 + Cos[θ]);
P1=PolarPlot[Tooltip[r[θ]],{θ,0,2π},PlotStyle->{Thick, Green}];

s[θ_]:= 6 Cos[θ];
P2=PolarPlot[Tooltip[s[θ]],{θ,-π/2, π/2},PlotStyle-> {Thick,Red}];
Show[P2,P1]

How many intersection points of the two curves? Only two!

Sol=Solve[r[θ] == s[θ],θ]/.C[1]->0

In polar coordinate: The two points are (3,-(π/3)) and (3,(π/3))

rPol1={r[θ]/.Sol[[1, 1]], Sol[[1,1,2]]}
sPol1={s[θ]/.Sol[[1, 1]], Sol[[1,1,2]]}

rPol2={r[θ]/.Sol[[2,1]],Sol[[2,1,2]]}
sPol2={s[θ]/.Sol[[2,1]],Sol[[2,1,2]]}

In Cartesian coordinate: The two points are (1.5, –2.59808) and (1.5, 2.59808).

rCart1={rPol1[[1]]Cos [rPol1[[2]]],rPol1[[1]]Sin [rPol1[[2]]]}//N
sCart1={sPol1[[1]]Cos [sPol1[[2]]],sPol1[[1]]Sin [sPol1[[2]]]}//N

rCart2={rPol2[[1]]Cos [rPol2[[2]]],rPol2[[1]]Sin [rPol2[[2]]]}//N
SCart2={sPol2[[1]]Cos [sPol2[[2]]],sPol2[[1]]Sin [sPol2[[2]]]}//N

What happens at (0, 0)?

Collatz sequence

This sequence starts from a given positive integer n and proceeds iteratively. 
At each step, if the current value n is even, the next value is n/2.
If the current value n is odd, the next value is 3n + 1.

Hypothesis: All Collatz sequences sooner or later get the value 1.

CS[n_ ]:=Module[{a = n, seq = {n}}, 
While[a ≠1,a=If[EvenQ[a],a/2,3a+1];seq={seq,a}];Print[p=seq//Flatten];ListLinePlot[p,PlotMarkers->{"◆", 14}]]
CS[5]

A shorter version using functional programming:

CS[n_]:=FixedPointList[If[EvenQ[#], #/2, 3 # +1] &,n, SameTest ->(#2==1&)];
CS[5]

We can find out how many times one needs to apply the conditions for a range of number.

CScond[n_]:=Length/@(NestWhileList[If[EvenQ[#], #/2, 3 # +1] &,#,!#==1&]&/@Range[n])-1;
y=CScond[50]
Show[{Graphics/@{Red,PointSize[.04],Point[{Position[y,Max[y]][[1,1]],Max[y]}]},ListLinePlot[Tooltip[y],PlotRange-> All,Filling-> Axis,Mesh->Full]}]

Understanding secant method

Secant method is used in root finding problem. 

A secant line is defined using two points on the graph of f(x). Thus, it is necessary to choose two initial iterates (Subscript[x, 0]) and (Subscript[x, 1]). Then, the next iterate (Subscript[x, 2]) is then obtained by computing the x-value at which the secant line passing through the points ((Subscript[x, 0]),f((Subscript[x, 0]))) and ((Subscript[x, 1]),f((Subscript[x, 1]))) has a y-coordinate of zero. 
This yield
			(Subscript[x, 2])=(Subscript[x, 1])-((f((Subscript[x, 1]))((Subscript[x, 1])- (Subscript[x, 0])))/(f((Subscript[x, 1])) - f((Subscript[x, 0]))))
or can be written as
			(Subscript[x, 2])=(((Subscript[x, 0])f((Subscript[x, 1])) - (Subscript[x, 1]) f((Subscript[x, 0])))/(f((Subscript[x, 1])) - f((Subscript[x, 0])))).

Clear[f];
Secant[X0_,X1_,tol_]:=
Module[{x0=N[X0],x1=N[X1],k=1,g=1},
f0=f[x0];f1=f[x1];pts={{{x0,f0},{x1,f1}}};
While[g>tol,
x2=((x0 f1-x1 f0)/(f1-f0));g=Abs[f[x2]];
x0=x1;f0=f1;x1=x2;f1=f[x2];
pts=Append[pts,{{x0,f0},{x1,f1}}]];
pts2=Flatten[pts,1];Print[pts2]];
f[x_]:=(x^4)-5;
Secant[.5,2,(10^(-4))];

Using the two initial iterates (0.5 and 2) and with tolerance value (10^(-4)), 
we find that x≃1.4953 (when f(x)≃0). 
We can check the root using the built-in function NSolve.

NSolve[f[x]==0,Reals]

How the secant method works?

xmax = Max[Cases[pts2[[All, 1]], Except[Indeterminate]]];Animate[Show[Plot[{0, f[x]}, {x, 1/2, xmax}, Frame -> True, PlotRange -> All,PlotStyle-> {Black, {Blue, Thickness[.006]}}],Graphics[{Green,PointSize[Large],Point[Last[pts2]]}],Graphics[{Green,Line[{{Last[pts2][[1]],Min[pts2]},{Last[pts2][[1]],Max[pts2]}}]}],ListLinePlot[pts2[[1 ;; n]], PlotRange -> All, PlotStyle -> Red, PlotMarkers -> {Automatic, Small}]], {n, 1, Length[pts2], 1},AnimationRunning->False,AnimationRepetitions->2]

Vector equation: Drawing a line

We can see the process of generating a line L=r+t v, with vectors r = (2, 5) and v = (4, 1).

Clear[r,v];
r={2,5};v={4,1};
T=Thick;
Animate[ListLinePlot[{Table[r+t v,{t,0,i}],
{{0,0},r},{{0,0},v},{{0,0},r+i v}},PlotStyle->{{T,Black},{T,Green},{T,Red},{T,Dashed,Blue}},Frame->True,PlotRange->{{0,23},{0,10.2}}],{i,0,5},AnimationRepetitions->2,AnimationRunning->False]

Seeing nature in Mathematica

Phyllotaxis spiral



Sources:
http://demonstrations.wolfram.com/PhyllotaxisSpirals/
http://blog.wolfram.com/2011/07/28/how-i-made-wine-glasses-from-sunflowers/

Spirals with n = 200,  400,  600, 800, 1000 and 1200.

PC[r_,t_]:=r {Cos[t],Sin[t]};
Table[{Graphics[{Hue[.8],Point[Table[PC[(Sqrt[n]),2 π (1-1/GoldenRatio) n],{ n,200i}]]}]},{i,6}]

Final example..

Missing a payment

For[i=1;aw[i]=600;latefee=(1/100)600,i<20,i++,aw[i+1]=aw[i]+(11/(100 365))  aw[i];Print[i+3, " September:  ", "RM ",s=aw[i+1]+latefee//N]]

Last but not least...

https://www.wolframalpha.com/

A computational knowledge engine. 

Generates output by doing computations from its own internal knowledge base, instead of searching the web and returning links.

Gives access to the world’s facts and data and calculates answers across a range of topics.

Free-form natural language input.

Can be used on computer, ipad and smartphone.