Professional Documents
Culture Documents
ü What is Mathematica?
ü One view...
ü A Complete system
This esample shows how different technologies and Mathematica features can be combined with a minimum effort and high
impact result.
Here I have a time series of tickers from the Stock exchange. I have all series in a database, then I use the front end features
to simplify the query and visualization of data.
2 MathTour2008-NorwayAndDenmark.nb
ü NOTE: this example doesn't work without the database (not provided). It has been left just
as a code example.
In[1]:= << DatabaseLink`;
conn = OpenSQLConnection@JDBC@"odbc", "Ticker"DD;
MyButtonFunction@label_StringD :=
Module@8<,
Get@ToFileName@"C:\\temp\\milano",
"D" <> SQLExecute@conn, "SELECT ∗ FROM Ticker WHERE nomeTicker = '" <>
ToString@labelD <> "'"D@@1, 2DD <> ".mx"DD;
Manipulate@
DateListPlot@8Tooltip@Take@Matrice@@4DD, −mDD, Tooltip@Take@Matrice@@3DD, −mDD,
Tooltip@Take@Matrice@@2DD, −mDD, Tooltip@Take@Matrice@@5DD, −mDD<,
82006, 8, 15<, ImageSize → 300, Filling → 82 → 81<<, FillingStyle → Blue,
PlotMarkers −> 8" ", " ", Style@"− ", Blue, 12, BoldD, Style@" −", Blue, 12, BoldD<D,
8m, 10, Length@Matrice@@4DDD, 10<D,
"Second report" → Manipulate@
ListPlot@Take@Matrice@@9DD, −daysD, Joined → True, ImageSize → 300,
PlotLabel → "123−days mean − values for the last " <> ToString@daysD <> " days"D,
8days, 50, Length@Matrice@@9DDD, 50<D,
"Third report" → Manipulate@
ListPlot@Take@Matrice@@10DD, −daysD, Joined → True, ImageSize → 300,
PlotLabel → "21−days mean − values for the last " <> ToString@daysD <> " days"D,
8days, 50, Length@Matrice@@10DDD, 50<D,
"Fourth report" → Manipulate@
ListPlot@Take@Matrice@@11DD, −daysD, Joined → True, ImageSize → 300,
PlotLabel → "13−days mean − values for the last " <> ToString@daysD <> " days"D,
8days, 50, Length@Matrice@@11DDD, 50<D,
"Show together" → Manipulate@
ListPlot@8Take@Matrice@@9DD, −daysD, Take@Matrice@@10DD, −daysD,
Take@Matrice@@9DD, −daysD, Take@Matrice@@11DD, −daysD<,
ImageSize → 300, Joined → TrueD, 8days, 50, Length@Matrice@@9DDD, 50<D,
"Overall" →
Manipulate@
Manipulate@
"SELECT ∗ FROM Ticker WHERE IDMercato = " <> ToString@nDD, 10DD êê TableForm<D,
8n, 81, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14<<, ControlType → SetterBarD
SetDirectory@NotebookDirectory@DD;
Extract a part of the image data from the Graphics object. The image data consists of a matrix of triples giving the values for
each color channel at each pixel.
888161, 135, 86<, 8150, 121, 65<, 8140, 111, 45<, 8137, 104, 33<,
8125, 91, 19<, 8130, 94, 20<, 8147, 109, 38<, 8154, 116, 45<, 8151, 113, 42<,
8155, 117, 46<, 8159, 123, 49<, 8163, 127, 53<, 8166, 133, 56<,
8170, 137, 60<, 8173, 139, 65<, 8182, 148, 74<, 8179, 145, 71<, 8182, 148, 74<,
, 8198, 161, 93<, 8199, 160, 93<, 8201, 162, 95<, 8201, 161, 91<,
8198, 158, 88<, 8193, 151, 77<, 8190, 148, 74<, 8190, 148, 74<, 8194, 152, 78<,
Out[3]= 65
8199, 157, 83<, 8198, 156, 82<, 8196, 157, 82<, 8194, 155, 80<, 8193, 153, 81<,
8192, 152, 80<, 8194, 156, 83<, 8201, 163, 90<<, 98 , 8 1 <<
Show Less Show More Show Full Output Set Size Limit...
Show the part of the data that was extracted with the true colors.
4 MathTour2008-NorwayAndDenmark.nb
Out[4]=
What I would like to do is get the size and location of the limestone accretion. There are many ways to approach this. The
idea I show below is certainly not the best, but it demonstrates well the ability to explore using the mathematics and interactiv-
ity of Mathematica.
Compute the mean color of all the pixels shown in the image.
I am interested in highlighting those points with color different than the most prevalent dull yellow. Thinking of the color as
a vector in 3-space, I want to highlight the points with different color directions. This can be done by taking the norm of the
cross product with the mean color.
Compute the norm of the cross product of the color vector at each point with the mean color and normalize it so that the
maximum value is 1.
orthogonal = Map@Norm@Cross@meancolor, DD &, imagedata, 82<D;
orthogonal ê= Max@orthogonalD;
In[6]:=
Out[8]=
8100, 97, 0.125922<, 8100, 98, 0.19546<, 8100, 99, 0.177795<, 8100, 100, 0.160276<<
Out[10]=
Show Less Show More Show Full Output Set Size Limit...
In[11]:= fit = FindFit@xydata, Gaussian@a, 8x0, y0<D@8x, y<D, 88a, .1<, 8x0, 50<, 8y0, 60<<, 8x, y<D
8y, 0, 100<, Contours −> 80.5<, ContourShading → False, PlotRange −> AllD,
ListContourPlot@orthogonal, Contours −> 80.5<, ContourShading → False, PlotRange −> AllDD
Out[13]=
ü A Complete system
ü Fully integrated across all functionality
ü "Instantly dynamic": new, unique and important
(...)
Symbolics
Numerics
Documents
Out[15]= Programming
Text
Interfaces
Graphics
F
1
In[16]:= FullFormB
3
Out[16]//FullForm=
Rational@1, 3D
F
1
In[17]:= TreeFormB
3
Out[17]//TreeForm=
Rational
1 3
A binomial
In[18]:= FullForm@a + b xD
Out[18]//FullForm=
Plus@a, Times@b, xDD
In[19]:= TreeForm@a + b xD
Out[19]//TreeForm=
Plus
a Times
b x
A graphic
MathTour2008-NorwayAndDenmark.nb 9
Out[20]=
In[21]:= FullForm@grD
Out[21]//FullForm=
Graphics@List@RGBColor@0, 0, 1D, Circle@List@0, 0DDDD
In[22]:= TreeForm@grD
Out[22]//TreeForm=
Graphics
List
RGBColor Circle
0 0 1 List
0 0
Knowing the internal form is also useful to manage our results without to find complex alternatives or re-write pieces of
code. If I want to replace the circle with a disk, I can use a replacement rule specifying that he objects Circle have to be
replaced by the object Disk.
10 MathTour2008-NorwayAndDenmark.nb
Out[23]=
Even the front end (the Mathematica user interface module) manages objects with the same philosofy.
Out[24]=
4 − 4 x + x2
In[25]:= FullForm@manD
Out[25]//FullForm=
Manipulate@Expand@Power@Plus@x, −2D, nDD, List@n, 2, 10, 1DD
MathTour2008-NorwayAndDenmark.nb 11
In[26]:= TreeForm@manD
Out[26]//TreeForm=
Manipulate
Expand List
Power n 2 10 1
Plus n
x −2
So, if I want to change the x variable, I can use ReplaceAll once again
In[27]:= ReplaceAll@man, x → Hz − 1L ^ 2D
Out[27]=
1 + 4 z + 2 z2 − 4 z3 + z4
Another example.
Here is a list of points of the function Sin and the ListPlot image
0.5
Out[29]=
5 10 15
-0.5
-1.0
With an easy replacemente rule, I generate a list of triple, where starting from the couple {x, y} the third value is a function
of the first two
12 MathTour2008-NorwayAndDenmark.nb
1.0
0.5
Out[31]= 1.0
0.0
-0.5 0.5
-1.0
0 0.0
5
-0.5
10
15
-1.0
In astronomical field, sometimes it is needed to plot functions with reversed x axes (x values decreases from left to right).
The flexibility of Mathematica allows to obtain this kind of result without to increase the complexity or the number of
funtions already built-in.
Out[32]=
4
2 4 6 8 10
MathTour2008-NorwayAndDenmark.nb 13
Out[33]=
4
10 8 6 4 2
ü Examples
Here I generate two results, apparently identical: the solution of an equation with three parameters and the "Dynamic"
version of the same solution
Now we can assign any value to one or more of the variable included in the solution, and see how the above cell change
accordingly
In[35]:= 8a = 0, b = 1, c = −2<
As you have seen, the first result is static, while the second one changes when a/b/c are changed. We can use some facilities
to set their values. For instance a list of SetterBar managing tha parameters values
14 MathTour2008-NorwayAndDenmark.nb
In[36]:= Panel@
Set a -5 -4 -3 -2 -1 0 1 2 3 4 5
Out[36]= Set b -5 -4 -3 -2 -1 0 1 2 3 4 5
Set c -5 -4 -3 -2 -1 0 1 2 3 4 5
Manipulate is a "macro" that allow an immediate generation of a special box where parameters can be manipulated by
controllers.
In[37]:= Manipulate@
Style@Column@8Row@8"Discriminant → ", ToString@b ^ 2 − 4 a cD<D,
Row@8"Solutions → ", Reduce@a x ^ 2 + b x + c 0, x, RealsD<D<, Spacings → 2D, LargeD,
8a, −5, 5, 1, Appearance → "Labeled"<, 8b, −5, 5, 1, Appearance → "Labeled"<,
8c, −5, 5, 1, Appearance → "Labeled"<D
a -5
b -5
c -5
Out[37]=
Discriminant → −75
Solutions → False
Another nice and useful new feature is Mouseover. It allow to overlap two objects and shows the first or the second depend-
ing on the position of the mouse pointer (outside or inside the object's box).
Here is a double face graphic, representing a ListPlot of a random data set and the BinCounts of its values. Mmove the mous
pointer inside/outside the image to see the "side B"
MathTour2008-NorwayAndDenmark.nb 15
10
Out[40]=
4
Another example
1.0
0.8
0.6
Out[42]=
0.4
0.2
Note that in just one line of code we have used random number generation, a graphic function, a quite complex algorithm
finding the shortest tour from a set of points and an interactivy function controlling the mouse position. This is an easy and
intuitive example of Mathematica as an integrated system. The same philosophy for several different tasks and operations.
1.0
0.5
Out[43]=
1 2 3 4
-0.5
-1.0
16 MathTour2008-NorwayAndDenmark.nb
1.0
0.5
Out[44]=
1 2 3 4 5 6
-0.5
-1.0
Mathematica’s plot functions are now fully numeric and as a result allow the specification of WorkingPrecision . This
will help clean up plots that would otherwise display some noise.
In this example the imaginary part of the WeierstrassZeta function is zero on the specified interval but numerical error
creeps in leading to a lot of noise in the plot.
1.5 μ 10-15
1. μ 10-15
Out[45]=
5. μ 10-16
-5. μ 10-16
In[46]:= PlotAz ë 1015 + Im@WeierstrassZeta@z, 83, 4<DD, 8z, 0, 1<, WorkingPrecision → 32E
1. μ 10-15
8. μ 10-16
6. μ 10-16
Out[46]=
4. μ 10-16
2. μ 10-16
x Ix − M
In[1]:= PlotB
1
2
40
20
-20
-40
If we specify the exclusion values, we can also specify a style to use for those values. Giving the two colors, blue and
orange, creates a blue line with orange points at the end.
Here we specify the locations of the singularities. In this case the excluded values are indicated by blue lines with
orange points at the minimum and maximum values.
Ix + M Ix − M
In[2]:= PlotB − ,x
1 1 4 2
30
20
10
Out[2]=
-1.0 -0.5 0.5 1.0
-10
-20
-30
18 MathTour2008-NorwayAndDenmark.nb
, 8x, −4, 4<, 8y, −4, 4<, Mesh → None, PlotRange → 5, Exclusions → 9y x2 =F
2
In[3]:= Plot3DB
y − x2
Out[3]=
In[5]:=
Here is an example of a function that returns complex values on the specified domain.
In[7]:= PlotB 1 − x2 , 8x, −2, 2<, PlotStyle → 88Red, Thick<<, AspectRatio → AutomaticF
1.0
0.8
0.6
Out[7]= 0.4
0.2
-2 -1 1 2
This shows all of the points used in the adaptive sampling routine for Plot.
In[8]:= Plot@Sin@tD, 8t, 0, 2 π<, Mesh → AllD
1.0
0.5
Out[8]=
1 2 3 4 5 6
-0.5
-1.0
20 MathTour2008-NorwayAndDenmark.nb
Adaptive refinement requires repeated sampling of the function which is done recursively. This Manipulate
illustrates the process.
MaxRecursion → n,
Mesh → All, MeshStyle → 8Red, PointSize@0.015D<, PlotPoints → 8D, 8n, 0, 10, 1<D
1.0
0.5
Out[9]=
-3 -2 -1 1 2 3
-0.5
-1.0
Plot3D@Sin@x yD, 8x, 0, π<, 8y, 0, π<, MaxRecursion → r, PlotPoints → 8, Mesh → AllD,
In[10]:= Manipulate@
MaxRecursion
Out[10]=
MathTour2008-NorwayAndDenmark.nb 21
Plot: Filling
A new option, Filling , can be used to shade regions of a plot. This option essentially replaces the functionality that was
present in the pre-Version 6 package, Graphics`FilledPlot`.
Out[11]=
You can fill to the horizontal axis, or the top, or bottom of the plot.
TabView@8"Top" −> Plot@8Sin@xD, Cos@xD<, 8x, 0, 2 π<, Filling → TopD,
"Axis" −> Plot@8Sin@xD, Cos@xD<, 8x, 0, 2 π<, Filling → AxisD,
In[12]:=
Out[12]=
22 MathTour2008-NorwayAndDenmark.nb
We add a different style in this example with the option FillingStyle . The colors change depending on which
function value is greater.
In[13]:= Plot@8Sin@xD, Cos@xD<, 8x, 0, 2 π<, Filling → 81 → 82<<, FillingStyle → 8Yellow, Green<D
1.0
0.5
Out[13]=
1 2 3 4 5 6
-0.5
-1.0
Here is a 3D equivalent
In[14]:= Plot3DBSin@x yD, 8x, 0, π<, 8y, 0, π<,
2 2
Out[14]=
1.0
0.5
Out[1]=
1 2 3 4 5 6
-0.5
-1.0
Out[2]=
1 2 3 4 5 6
-1
-2
-3
In[3]:= ContourPlot@Sin@2 x D Sin@2 yD, 8x, 0, π<, 8y, 0, π<, ContourLabels → NoneD
Out[3]=
24 MathTour2008-NorwayAndDenmark.nb
8x, 0, 3<, 8y, 0, 3<, PlotStyle → Table@Opacity@.7, Hue@i ê 6DD, 8i, 4<DD
Out[4]=
PlotRange → All, Joined → TrueD, ImageSize −> AllD, 8i, 1, 2<, 8t, 1, 2<DD
2.0
2.0
1.5
1.5
1.0
1.0
0.5 0.5
20 40 60 80 100 20 40 60 80
Out[5]=
2.0
2.0
1.5
1.5
1.0
1.0
0.5 0.5
20 40 60 80 100 20 40 60 80
MathTour2008-NorwayAndDenmark.nb 25
Graphics fully integrated into the whole system, just like any
other object
Coin tossing experiments...
Out[1]= : , >
Out[3]= −4 + + −4 +
In[4]:= t = Expand@%D
2 2
Out[4]= 32 − 8 + −8 +
Out[5]= +
:: >,
33 31 33 31
Out[6]= → − , → +
16 16 16 16
: >>
33 31 33 31
→ + , → −
16 16 16 16
26 MathTour2008-NorwayAndDenmark.nb
Instantly dynamic
Out[7]=
20 40 60 80 100
-2
-4
Adding interaction:
Manipulate@ListPlot@Sort@RandomReal@StudentTDistribution@5D, 8points<DD,
PlotRange → 8−4, 4<D, 8points, 100, 1000, 10<D
In[8]:=
points
Out[8]=
20 40 60 80 100
-2
-4
A random walk
MathTour2008-NorwayAndDenmark.nb 27
Out[9]=
1
20 40 60 80 100
-1
-2
points
20 40 60 80 100
-5
Out[10]=
-10
-15
Draw axes
Out[1]=
28 MathTour2008-NorwayAndDenmark.nb
Out[2]=
MathTour2008-NorwayAndDenmark.nb 29
fn ContourPlot Plot3D
Out[4]=
Out[5]=
Suriname Guyana
FrenchGuiana Venezuela
Panama
Brazil Colombia
Out[11]=
Uruguay Paraguay
Peru Ecuador
Bolivia
Argentina
Chile
Out[7]=
MathTour2008-NorwayAndDenmark.nb 31
Out[9]=
In[13]:= ManipulateB
H∗Select the subset of the data according to the checkboxes set by the user∗L
pms = If@showconservative, , DeleteCases@ , 8___, "Conservative"<DD & @
If@showlabour, , DeleteCases@ , 8___, "Labour"<DD & @
If@shownationallabour, , DeleteCases@ , 8___, "National Labour"<DD & @
If@showliberal, , DeleteCases@ , 8___, "Liberal"<DD & @ PrimeMinisterData;
H∗Interface specification∗L
88stack, True, "show names"<, 8True, False<<,
88showconservative, True, "Conservative Party"<, 8True, False<<,
88showlabour, True, "Labour Party"<, 8True, False<<,
88showliberal, True, "Liberal Party"<, 8True, False<<,
32 MathTour2008-NorwayAndDenmark.nb
Initialization
, ControllerLinking → TrueF
MathTour2008-NorwayAndDenmark.nb 35
show names
Conservative Party
Labour Party
Liberal Party
John Major
Margaret Thatcher
Edward Heath
Sir Alec Douglas Home
Out[13]=
Harold Macmillan
Sir Anthony Eden
Winston Churchill
Winston Churchill
Neville Chamberlain
Stanley Baldwin
Ramsay MacDonald
Stanley Baldwin
Stanley Baldwin
Andrew Bonar Law
David Lloyd George
H. H. Asqith
Sir Henry Campbell-Bannerman
Arthur Balfour
10
Out[15]=
-2 -1 1 2
-5
-10
Out[17]=
ü FindFit examples
A first example
MathTour2008-NorwayAndDenmark.nb 37
F;
Sin@b tD
model = WhichBt < 0, 0, True,
−a t
In[3]:= sol = FindFit@data, model, 88a, 1<, 8b, 1<<, 8t<, MaxIterations → 200D
0.6
0.5
0.4
0.3
Out[4]= 0.2
0.1
50 100 150
-0.1
Another example.
In[5]:= MyFunction@a_, b_, c_, x_D := a If@x > 0, Cos@b xD, Exp@c xDD
In[7]:= fit = FindFit@data, MyFunction@a, b, c, xD, 88a, 1<, 8b, 3<, 8c, 1<<, xD
1.0
0.5
Out[8]=
-4 -2 2 4
-0.5
-1.0
How we can discover intermediate steps? The option EvaluationMonitor does this for us
38 MathTour2008-NorwayAndDenmark.nb
In[9]:= Options@FindFitD
There are many other ways to further investigate the intermediate steps and internal algorithms behaviour. Mathematica
provides many tools and in some cases additional documentation and/or packages to allow users "to explore and drive" the
computation of their data.
This is an example of additional functions provided by the package Optimization`UnconstrainedProblems`
In[11]:= Needs@"Optimization`UnconstrainedProblems`"D
>
2
3 4 5 6 7
-2
-4
20
10
22 24 26 28 30 >
-10
-20
-30
Out[14]=
This is the graphic of points used by NIntegrte when the method used is the default Multidimensional
ListPlotA
xys = ReapANIntegrateAAbs@x − yD3ê2 , 8x, 0, 1<, 8y, 0, 1<, EvaluationMonitor
In[15]:=
Sow@8x, y<DEE@@
2, 1DD, AspectRatio → Automatic,
PlotLabel → "Number of points:" <> ToString@Length@xysDDE
Number of points:1530
1.0
0.8
0.6
Out[15]=
0.4
0.2
Number of points:2662
1.0
0.8
0.6
Out[16]=
0.4
0.2
Number of points:9200
1.0
0.8
0.6
Out[17]=
0.4
0.2
There is also another intereting function named Monitor, that provides a temporary image of what is happening during a
calculation
MathTour2008-NorwayAndDenmark.nb 41
values = 8<;
Monitor@NIntegrate@Sqrt@x H1 − xLD, 8x, 0, 1<,
In[18]:=
Out[19]= 0.392699
data = 880.18, −0.13<, 80.84, −0.06<, 80.05, 0.88<, 80.24, −0.63<, 80.67, 0.93<,
80.05, 0.88<, 80.65, 0.92<, 80.01, 0.99<, 80.17, −0.04<, 80.23, −0.55<<;
In[1]:=
Monitor the evolution of the model over the steps with a graph:
LU@A_, p_: 0D := Block@8m, n, L, U<, 8m, n< = Dimensions@AD; 8L, U< = 8IdentityMatrix@nD, A<;
Do@Pause@pD; L@@k ;; n, kDD = U@@k ;; n, kDD ê U@@k, kDD;
In[5]:=
: , 1, 0, 0, 0, 0, 0, 0>, :
1 22 19 8 31 25 69
, , ,− ,−
, 1, 0, 0, 0, 0, 0>, ,−
9 9 16 9 9 16 295
: ,− , 1, 0, 0, 0, 0>, : ,
7 17 17 61 2749 7 28 13 9 541 1938
,− ,− , , , ,− , , 1, 0, 0, 0>,
9 9 16 295 1886 9 9 16 295 1886 5399
:
10 32 64 5191 11 584 5737
,− , −2, − , , , , 1, 0, 0>,
9 9 295 1886 5399 8664
: , , ,
1 7 3 204 1799 3620 1561 655
, , , , , 1, 0>,
3 3 4 295 1886 5399 17 328 887
: , ,− ,−
2 2 3 204 1018 4847 2369 6133 42 577
, , , ,− ,− , 1>>,
:0, 0, >,
16 55 280 10 173 272 122 14
,− ,− , , ,− , ,−
3 9 9 9 9 9 99
:0, 0, 0, >,
295 131 77 77 605
205 175
, ,− ,− , ,− ,
48 6 24 48 3 24 24
:0, 0, 0, >,
1886 2028 700 3244 332 639
0, − , , ,− , ,
295 295 59 295 59 59
:0, 0, 0, >,
5399 6526 2517 1248 26 065
0, 0, − ,− , , ,−
943 943 943 943 1886
:0, 0, 0, >,
17 328 22 160 3916 153 549
0, 0, 0, , ,− ,
5399 5399 5399 10 798
:0, 0, 0, >,
3548 13 069 44 233
0, 0, 0, 0, − ,− ,−
1083 2166 5776
Out[8]=
44 MathTour2008-NorwayAndDenmark.nb
Vertex A
Vertex B
Vertex C
Geometric objects that have the same shape and same size are called congruent. When they have the same shape but
different sizes they are called similar. Here are three similar triangles called Mama Triangle, Papa Triangle, and Baby
Triangle. You can change the position of their vertices with the sliders. Since their angles all change by the same amount
they remain similar.
But notice that even though they are different sizes, the ratio of their areas to the square of ANY linear element is the same
for all three triangles (watch the pink line in the table). A teenage Albert Einstein made use of this quality in his proof of the
Pythagorean theorem.
MathTour2008-NorwayAndDenmark.nb 45
—CAB = 75.9431±
—ABC = 74.295±
—BCA = 29.7619±
total = 180.±
74±
C
30±
76±
A
46 MathTour2008-NorwayAndDenmark.nb
choose an angle
show radians
straight angle
180∞
1
Hx − 1L Ix2 − 4M Ix2 + 1M
In[9]:= poly =
1
H−1 + xL I−4 + x2 M I1 + x2 M
Out[9]=
In[10]:= Apart@polyD
1+x
20 H−2 + xL 6 H−1 + xL 60 H2 + xL
1 1 1
10 I1 + x2 M
Out[10]= − + +
MathTour2008-NorwayAndDenmark.nb 47
In[11]:= ManipulateB
GridB:
In[12]:= TabViewB
"Formula" → ManipulateBGridB:
8a, −5, 5, 1<, 8b, −5, 5, 1<, 8c, −5, 5, 1<F>, 2, ImageSize → AutomaticF
Plot Formula
0.2
Out[12]=
0.1
-4 -2 2 4
-0.1
-0.2
MathTour2008-NorwayAndDenmark.nb 49
Deploy@
Column@8Text @ Style@
Column@8Row@8Switch@conictype, ellipse, "ellipse", hyperbola,
"hyperbola", parabola, "parabola"D, " : ", Style@"e", Italic, 16D,
" = ", If@conictype === parabola, "", Row@8Style@"c", Italic, 16D,
"ê", Style@"a", Italic, 16D, " = "<DD, Round@c ê a, 0.01D<D,
If@conictype === parabola, Row@8Style@Sqrt@Style@"a", Italic, 16D ^ 2 −
Show@
8h, k<<D<L &, 88a, b<, 8−a, b<, 8a, −b<, 8−a, −b<<DD, 8<D,
<D,
88foc1, 81, 0<<, 8−6, −6<, 86, 6<, Locator, Appearance → Style@"Ê", Opacity@0DD<,
88foc2, 8−1, 0<<, 8−6, −6<, 86, 6<, Locator<,
88amult, 1.5, Row@8" ", "adjust ", Text @ Style@"a", Italic, 14D<D<,
1, 3, Enabled → If@conictype === parabola, False, TrueD<,
adjust a
hyperbola asymptotes
Out[3]=
2
-6 -4 -2 2 4 6
-2
-4
-6
In[14]:= Manipulate@
DynamicModule@8h, k, type, label<,
h := center@@1DD;
k := center@@2DD;
ellipse, Hx − hL ^ 2 ê a ^ 2 + Hy − kL ^ 2 ê b ^ 2 1,
type := Evaluate@Switch@conictype,
parabolax, Hy − kL ^ 2 4 c Hx − hL,
parabolay, Hx − hL ^ 2 4 c Hy − kL,
hyperbolax, Hx − hL ^ 2 ê a ^ 2 − Hy − kL ^ 2 ê b ^ 2 1,
hyperbolay, −Hx − hL ^ 2 ê a ^ 2 + Hy − kL ^ 2 ê b ^ 2 1
DD;
labels = 88"ellisse", "ellipse"<, 8"parabola", "parabola"<,
8"iperbole", "hyperbola"<, 8" centro ", " center "<, 8" fuochi ", " foci
8" direttrici ", " directrices "<, 8" asintoti ", " asymptotes "<<;
"<,
DD;
Deploy@
Grid@8
Row@8Style@"a", ItalicD, " = ", a, ", ", Style@"b", ItalicD, " = ", b, "; ",
Style@"h", ItalicD, " = ", h, ", ", Style@"k", ItalicD, " = ", k<D, GrayD<D,
8Dynamic@Show@
Line@888h, k<, 81000 a + h, 1000 b + k<<, 88h, k<, 8−1000 a + h, 1000 b + k<<,
Graphics@8Dashing@MediumD, Orange,
88h, k<, 81000 a + h, −1000 b + k<<, 88h, k<, 8−1000 a + h, −1000 b + k<<<D<D, 8<D,
If@showfoci,
Graphics@8Purple, PointSize@0.02D,
If@showdirect,
Graphics@8Darker@Green, 0.2D, Dashing@MediumD,
ControllerLinking → True
D
54 MathTour2008-NorwayAndDenmark.nb
Hx-hL2 Hy-kL2
Language it
a2
+ =1
ellisse
b2
a = 2, b = 3; h = 0, k = 0
parabola-x
parabola-y
6
iperbole-x
iperbole-y
4
Out[14]=
2
centro
-6 -4 -2 2 4 6
-2
-4
-6