Springfield Holding B.V

151
by N. Roos MathGrapher Help and Manual

Transcript of Springfield Holding B.V

Page 1: Springfield Holding B.V

by N. Roos

MathGrapher Help and Manual

Page 2: Springfield Holding B.V

MathGrapher 2A mathematical graphing tool

by Nico Roos

Page 3: Springfield Holding B.V

All rights reserved. No parts of this work may be reproduced in any form or by any means - graphic, electronic, ormechanical, including photocopying, recording, taping, or information storage and retrieval systems - without thewritten permission of the publisher.

Products that are referred to in this document may be either trademarks and/or registered trademarks of therespective owners. The publisher and the author make no claim to these trademarks.

While every precaution has been taken in the preparation of this document, the publisher and the author assumeno responsibility for errors or omissions, or for damages resulting from the use of information contained in thisdocument or from the use of programs and source code that may accompany it. In no event shall the publisherand the author be liable for any loss of profit or any other commercial damage caused or alleged to have beencaused directly or indirectly by this document.

Printed: october 2013 in Katwijk, the Netherlands

MathGrapher 2

copyright N. Roos

PublisherSpecial thanks to:

My wife and children who know who they are. They were often ableto ignore my zombie-like absent mindedness when trying to fixbugs in the code.

Cover Designer

N. Roos

Page 4: Springfield Holding B.V

MathGrapher v24

Springfield Holding B.V.

Table of Contents

0

Part I About MathGrapher 9

Part II Copyright Notice 11

Part III Introduction 13

................................................................................................................................... 131 Summary

................................................................................................................................... 162 Demonstrations

................................................................................................................................... 173 Examples

Part IV Functions 20

................................................................................................................................... 201 Definition

......................................................................................................................................................... 20(Sub)Functions

......................................................................................................................................................... 21Constants

......................................................................................................................................................... 22Variables

......................................................................................................................................................... 22Operators / (sub)Functions

......................................................................................................................................................... 23Special Functions

.................................................................................................................................................. 24Random numbers

.................................................................................................................................................. 25Modulo function

.................................................................................................................................................. 25Fresnel integrals

.................................................................................................................................................. 26Exponential integrals

........................................................................................................................................... 26Exponential integral

........................................................................................................................................... 26Exponential integral En

........................................................................................................................................... 27Logarithmic integral

........................................................................................................................................... 27Sine integral

........................................................................................................................................... 28Cosine integral

........................................................................................................................................... 28Hyperbolic sine integral

........................................................................................................................................... 29Hyperbolic cosine integral

.................................................................................................................................................. 29Gamma function

........................................................................................................................................... 30Gamma function

........................................................................................................................................... 30Incomplete Gamma function

........................................................................................................................................... 31Complementary incomplete Gamma function

.................................................................................................................................................. 31Riemann Zeta function

.................................................................................................................................................. 32Bessel functions

........................................................................................................................................... 32Bessel function (1st kind)

........................................................................................................................................... 33Bessel function (2nd kind)

.................................................................................................................................................. 33Airy functions

.................................................................................................................................................. 34Elliptic integrals

........................................................................................................................................... 34Elliptic integral of the first kind

........................................................................................................................................... 35Elliptic integral of the second kind

.................................................................................................................................................. 35Poisson probability function

.................................................................................................................................................. 36Binomial probability function

.................................................................................................................................................. 37Distribution functions

........................................................................................................................................... 37Binomial distribution function

........................................................................................................................................... 37Poisson distribution function

........................................................................................................................................... 38Error function

Page 5: Springfield Holding B.V

5Contents

Springfield Holding B.V.

........................................................................................................................................... 39Gaussian distribution function

........................................................................................................................................... 40Beta distribution function

........................................................................................................................................... 41Chi squared distribution function

........................................................................................................................................... 41Student's t distribution function

................................................................................................................................... 422 2D Functions: F(x)

......................................................................................................................................................... 42Variable

......................................................................................................................................................... 43X-Y coordinates

......................................................................................................................................................... 44Calculus

......................................................................................................................................................... 45Graph Window

......................................................................................................................................................... 46Edit: 2D Graph

......................................................................................................................................................... 47Examples: Parameter Function

......................................................................................................................................................... 48Examples: Polar Coordinates

......................................................................................................................................................... 49Examples: Damped Sine wave

................................................................................................................................... 493 3D Functions: F(x,y)

......................................................................................................................................................... 49Variables

......................................................................................................................................................... 50Function: Calculus (3D)

......................................................................................................................................................... 50Function: Drawing a 3D Graph

.................................................................................................................................................. 54Surface Graph

.................................................................................................................................................. 55Contour Plot

.................................................................................................................................................. 56Cross-section

.................................................................................................................................................. 56Examples: Shaded surface

......................................................................................................................................................... 58Graph Window

......................................................................................................................................................... 59Edit: 3D Graph

......................................................................................................................................................... 603D Viewer Window

................................................................................................................................... 614 Import / Export: Functions

Part V Data 64

................................................................................................................................... 641 Data: panel

................................................................................................................................... 642 Import: Data

................................................................................................................................... 653 Data: Drawing a Graph

................................................................................................................................... 654 Data: Statistics

......................................................................................................................................................... 65Statistics panel

......................................................................................................................................................... 66Statistics

......................................................................................................................................................... 68Statistical measures

................................................................................................................................... 685 Graph Window

................................................................................................................................... 706 3D Viewer Window

................................................................................................................................... 717 Edit: 2D Graph

................................................................................................................................... 728 Edit: 3D Graph

................................................................................................................................... 739 Examples: Data Graphs (2D)

................................................................................................................................... 7410 Read data from the Graph into a Grid

................................................................................................................................... 7411 Calculate Function values for column 1

................................................................................................................................... 7512 Examples: Read Data from Imported Graph Image

Part VI Curve fitting 77

................................................................................................................................... 771 Curve Fitting introduction

................................................................................................................................... 782 Curve Fitting: Levenberg-Marquardt

................................................................................................................................... 793 Curve Fitting: Predefined functions

Page 6: Springfield Holding B.V

MathGrapher v26

Springfield Holding B.V.

................................................................................................................................... 794 Curve Fitting: Linear combination of Functions and Data sets

................................................................................................................................... 805 Curve fitting - Examples

......................................................................................................................................................... 80Straight Line

......................................................................................................................................................... 81Levenberg-Marquardt

......................................................................................................................................................... 83Linear combination of Functions and Data sets

Part VII Iterations 85

................................................................................................................................... 851 Iterations: Definition

................................................................................................................................... 862 Iterations: Start / End Conditions

................................................................................................................................... 863 Iterations - Type I: Standard Iteration

................................................................................................................................... 874 Iterations - Type II: Vary one parameter

................................................................................................................................... 895 Iterations - Type III: Mandelbrot and Julia

................................................................................................................................... 896 Type I Iterations: Analysis

......................................................................................................................................................... 89Iterations: Analysis

......................................................................................................................................................... 90Iteration sequence

......................................................................................................................................................... 91Power spectrum

......................................................................................................................................................... 91Projections in 2D

......................................................................................................................................................... 93Projections in 3D

......................................................................................................................................................... 93Fixed points

......................................................................................................................................................... 94Lyapunov exponents

......................................................................................................................................................... 95Lyapunov exponents - Definition and calculation

................................................................................................................................... 967 Edit: Iterations / ODEs

................................................................................................................................... 978 Pixel Graph Window

................................................................................................................................... 989 Iterations: Examples

......................................................................................................................................................... 99Algebraic series

......................................................................................................................................................... 100Logistic map

......................................................................................................................................................... 104Henon map

......................................................................................................................................................... 107Standard map

......................................................................................................................................................... 107Mandelbrot and Julia sets

Part VIII Ordinary Differential Equations 111

................................................................................................................................... 1111 ODEs: Definition

................................................................................................................................... 1122 ODEs: Start / End Conditions

................................................................................................................................... 1123 ODEs: T - Range

................................................................................................................................... 1134 ODEs: Analysis

......................................................................................................................................................... 113Time Series

......................................................................................................................................................... 114Power spectrum

......................................................................................................................................................... 114Projection in 2D

......................................................................................................................................................... 115Projection in 3D

......................................................................................................................................................... 116Surface of Section

......................................................................................................................................................... 117Phase portrait

......................................................................................................................................................... 118Linearization

......................................................................................................................................................... 118Equilibrium points (Fixed points)

......................................................................................................................................................... 119Lyapunov exponents

......................................................................................................................................................... 120Lyapunov exponents - definition

......................................................................................................................................................... 120Lyapunov exponents - calculation

................................................................................................................................... 1215 Edit: Iterations / ODEs

Page 7: Springfield Holding B.V

7Contents

Springfield Holding B.V.

................................................................................................................................... 1216 ODEs: Examples

......................................................................................................................................................... 123Lorenz attractor

......................................................................................................................................................... 125Henon-Heiles potential

......................................................................................................................................................... 127Rossler equation

......................................................................................................................................................... 127Duffing oscillator

Part IX Matrices 130

................................................................................................................................... 1301 Matrices: screenview

................................................................................................................................... 1302 Matrices : operations

................................................................................................................................... 1313 Matrices: Solve A.X=B

Part X Lindenmayer systems 134

................................................................................................................................... 1341 L-systems

................................................................................................................................... 1352 L-systems: Screenview

................................................................................................................................... 1353 L-systems: Examples

Part XI Cellular automata 139

................................................................................................................................... 1391 Cellular Automata: 1D rule

................................................................................................................................... 1402 Cellular Automata: 2D rule

................................................................................................................................... 1413 Cellular Automata: Life

Part XII Add drawing objects 144

................................................................................................................................... 1441 Add: Draw Lines, Symbols, Text

Part XIII Import / Export 146

................................................................................................................................... 1461 Import / Export: Functions

................................................................................................................................... 1462 Import / Export: Data

................................................................................................................................... 1463 Import: Images

................................................................................................................................... 1474 Export: Save Graphs

................................................................................................................................... 1475 Export: Results

Index 148

Page 8: Springfield Holding B.V

MathGrapher

Part

I

Page 9: Springfield Holding B.V

9About MathGrapher

Springfield Holding B.V.

1 About MathGrapher

MathGrapher is freeware

You may download MathGrapher from MathGrapher's web site: www.mathgrapher.com.[****] To keep track of

all users we ask you to register first.

PRODUCT SUPPORT

Please send your comments, questions etc. to [email protected][****]

Page 10: Springfield Holding B.V

MathGrapher

Part

II

Page 11: Springfield Holding B.V

11Copyright Notice

Springfield Holding B.V.

2 Copyright Notice

LICENCE

Installing, copying, or otherwise using this product indicates your acknowledgement that youhave read the licence agreement and agree to its terms. The full text of the licence agreement isavailable at www.mathgrapher.com[****]

Copyright N. Roos., Boulevard 18, 2225 AB Katwijk, the Netherlands. All rights reserved.

MathGrapher is a registered trademark owned by N. Roos, Boulevard 18, 2225 AB Katwijk, theNetherlands. All rights reserved.

Page 12: Springfield Holding B.V

MathGrapher

Part

III

Page 13: Springfield Holding B.V

13Introduction

Springfield Holding B.V.

3 Introduction

Mathgrapher is a mathematical graphing tool for 2D and 3D functions and data. It includes linearand nonlinear curve fitting, integration and analysis of coupled ordinary differential equations(ODE's) and multi-dimensional iterative maps, matrix operations, Lindenmayer systems and somecellular automata.

MathGrapher's basic functionalities are given by the first 8 buttons in the button bar at the top ofthe main window. Choose one of the modules: Functions, Data, Curve fitting, Iterations, ODEs(Ordinary differential equation), Matrices, Lindenmayer systems, Cellular Automata. Thebuttons on the right side open windows in which you may set parameters, adjust graph propertiesadd drawing elements to your graph.

Drawing a Graph generally involves three steps

Push one of of the 8 buttons on the left side of the button bar (or choose from thecombo-box). Define your Functions, Data etc.

Push the Prepare Graph button to open the Prepare / Draw Graph window and theGraphics window. Make the necessary preparations to calculate and draw the Graph.

Push the Draw button in the Prepare / Draw window to produce the Graph

N.B. The quickest way to get acquainted with MathGrapher is to start theDemonstrations[****] in the main menu bar. You may also browse through theSummary[****] to get an Overview or look at a few Examples[****] in this Helpfile or at the website www.mathgrapher.com [****]

3.1 Summary

Functions

MathGrapher is a graphical calculator for functions of the form F(x) and F(x,y) containing upto 20 subfunctions. Many special functions are included. Cartesian as well as polarcoordinates can be chosen and functions can be represented in patametrized form (2D).F(x,y) can be represented in 2D and 3D by Shaded surfaces, Contour plots andCross-sections through Contourplots. In the 3D viewer you may rapidly vary the viewingangle, distance and shading of the 3D surface using your mouse.

You can define and plot 2D and 3D functions (F(x) and F(x,y)). Up to 20 (sub)functions can be defined containing up to 100 symbolic, 140 numericalconstants, 50 mathematical and physical constants and more than 30 special functions.

Function Definition[****] or Import[****]

Special functions[****]

Constant Definition[****]

2D FunctionsPreparing and Drawing the Graph

Variables[****]

Examples: Damped Sine wave[****].

X-Y coordinates [****]

Page 14: Springfield Holding B.V

14 MathGrapher v2

Springfield Holding B.V.

Examples: Polar coordinates[****], Parameter functions[****].

Calculus [****]

Examples: Zeroes, Extrema[****], Differentiation, Integration[****].

Graph window[****]

Editing the Graph[****]

Position[****], Axes[****], Lines / Symbols[****]

3D FunctionsPreparing and Drawing the Graph[****]

Variables[****]

Calculus[****]

Graph window[****]

Editing the Graph[****]

Shaded surface[****].

Surface[****], Axes, Line of sight[****]

Examples: Surface[****], Contour plot[****], Cross-section[****].

Contour plot

Cross-section through contour plot

3D Viewer[****]

Data

Edit and draw graphs of your 2D or 3D Data. Just select the Data in one of the Data gridsand push the Draw button. 3D surfaces can be previewed in the 3D viewer (OpenGL).Shaded surfaces, Contour plots and Cross-sections through Contour plots can be drawn insame way as 3D Functions. Some statistical tests (Chi-squared and Kolmogorov-Smirnov)are included.

Data can be typed[****] or Imported[****] into grids containing up to 100.000 cells

Data from a Grid can be plotted as separate lines in a 2D graph, or as a surface in a 3Dgraph. In 3D mode you can also make Contour plots and Cross-sections through Contourplots (see 3D Functions).

Preparing and Drawing the Graph

Some Statistics (Calculus)[****]

Graph window[****]

Example: 2D data[****].

You may adjust the properties of Data Graphs just as in the case of 2D or 3D FunctionGraphs. Just push the Graph properties button in the main button bar.

Editing in 2D mode.[****]

Editing in 3D mode[****]

3D Viewer[****]

Curve Fitting

A number of least squares curve fitting methods can be selected: You may choose thegeneral and powerfull (non-linear) Levenberg-Marquardt method to fit your data to anycontinuous function you define. You may fit your data to a number of predefined functionssuch as e.g. linear regression, polynomials, trigonometric polynomials or cubic splines.Finally you may fit the data to a linear combination of Functions and Data sets provided byyou.

Page 15: Springfield Holding B.V

15Introduction

Springfield Holding B.V.

Curve fitting[****]

General nonlinear least squares Levenberg Marquardt method[****]

Example: fit to Fermi Distribution[****].

Predefined functions[****]

--Straight Line[****]

Example: fit data to a straight line[****].

--Some special curves (method of data linearization)[****]

--Polynomials[****]

--Trigonometric polynomials[****]

--Cubic splines[****]

Linear combination of Functions and Data sets [****]

Example: fit to a combination of known spectra[****]

Iterations / Maps

Calculate algebraic series or study iterative multi-dimensional maps. Several mathematicaltools are available to analyse the results (zie ODE's below): draw orbits, calculte powerspectra, bifurcation diagrams, Lyapunov exponents.

Definitions[****]

Preparing and Drawing the Graph[****]

Start/End Conditions[****], Iteration type[****]:

1) Standard[****]2) Vary one parameter (bifurcation diagram)[****]3) Vary two parameters or initial values (Mandelbrot and Julia sets)[****]

Pixel graph window[****]

Analytical tools:[****]

1) Time series[****]2) Power spectrum[****]3) Projection in 2D[****] or 3D 4) Fixed points[****]5) Lyapunov exponents[****]

Examples : Algebraic series, Logistic map[****].

Henon map, Mandelbrot and Julia sets[****]

Standard map[****]

Editing the Graph[****]

Ordinary Differential Equations

The evolution of dynamical systems in physics, chemistry, electronics, economics andpopulation dynamics can often be described with a set of coupled ODE's. Mathgrapher usesan accurate Adams-Bashforth variable order, variable step predictor-corrector algorithm tointegrate systems of up to 20 coupled ODE's. Several tools are available to analyse theresults of the integrations (and iterations) such as: Graph of the time evolution, Projections in2 or 3 dimensions, Phase portraits, Surfaces of Section, Power spectrum, Equilibrium points,

Lyapunov exponents.

Definition[****]

Preparing and Drawing the Graph[****]

Start/End Conditions[****], T-Range[****] , Analytical tools[****]:

1) Time series[****]2) Power spectrum[****]

Page 16: Springfield Holding B.V

16 MathGrapher v2

Springfield Holding B.V.

3) Orbit in 2D[****] 4) Phase portrait[****], 5) Orbit in 3D[****], 6) Poincaré section[****], 7) Equilibrium points[****], 8) Lyapunov exponents[****]

Examples: Lorenz attractor, Henon potential[****].

Editing the Graph[****]

Matrices

The most important matrix operations can be performed: addition, multiplication, tranposition,inversion, solution of AX=B, calculation of eigenvalues, eigenvectors and determinants.

Matrices (screenview)[****]

Operations[****] (addition, multiplication, tranposition, Inversion, determinant)

Eigenvalues / vectors[****]

Solution of AX = B and applications[****].

Lindenmayer systems

Experiment with iterative string rewriting methods (sometimes called turtle graphics) asinvestigated by Lindenmayer. Create fractal curves, space filling curves and simulatebiological growth patterns

Definition[****]

Cellular automata

Experiment with 1D and 2D cellular automata such as the Game of Life

One[****]- and two[****]- dimensional. Game of Life[****]

Add Lines / text / Symbols to the graphA simple edit panel is launched when the Add[****] button is pushed. Here you can choosesome drawing elements such as text, lines and symbols.Use your mouse to place them onthe graph.

Import / ExportFunctions[****]

Data[****]

Results from mathematical operations[****]

Import Images[****] / Export Graphs[****]

3.2 Demonstrations

Demonstrations

The quickest way to become familiar with MathGrapher is to look at the Demonstrations. Startwith demonstration 1 from the main menu bar, lean back and learn what MathGrapher can dofor you. Enjoy!

Page 17: Springfield Holding B.V

17Introduction

Springfield Holding B.V.

Mathgrapher provides 23 Demonstrations covering the main topics

Subject Demonstration

Define and Plot F(x) Define and Plot

Zeroes, Extrema

Special functions

Define and plot F(x,y) Shaded surface, Contour plots

Data (2D and 3D) Draw Graph

Statistics

Curve Fitting Levenberg-Marquardt (non-linear)

Functions and Data sets (linear combination)

Iterations Algebraic series

Logistic map

Henon map

Standard map

Mandelbrot / Julia sets

Fixed points

Lyapunov exponents

ODEs Lorenz attractor

Henon-Heiles

Phase portrait

Equilibrium points

Lyapunov exponents

Matrices examples

Lindenmayer systems examples

Cellular Automata examples

3.3 Examples

Functions2D

Damped Sine wave / zeroes / extrema

Gauss distribution / integration

Polar coordinates

Parametrization

3D

Shaded surface

Contour Map / Cross-section

Data2D

Single curve / multiple curves

Read Data from (Imported) Graph Image

3D

Shaded surface / Contour Map / Cross-section

Curve Fitting

Page 18: Springfield Holding B.V

18 MathGrapher v2

Springfield Holding B.V.

Levenberg-Marquardt method

Straight line

Spectrum

Iterations Algebraic series / Logistic map

Henon map

Mandelbrot and Julia sets

Fixed points / Lyapunov exponents (see the example in the demonstrations)

ODE's Lorenz attractor / Henon potential

Phase portrait

Equilibrium points / Lyapunov exponents (see the example in thedemonstrations)

Matrices Solve AX=B

Lindenmayer systems Fractal curves

Area filling curves

Botany

Cellular Automata 1D

2D

Game of Life (2D)

Page 19: Springfield Holding B.V

MathGrapher

Part

IV

Page 20: Springfield Holding B.V

20 MathGrapher v2

Springfield Holding B.V.

4 Functions

4.1 Definition

4.1.1 (Sub)Functions

Open the Function definition panel by pushing the Function button in the main button bar

Select the function you want to define in the function list box. It will appear in the text entryabove the list.

Function Definition: Type the Function in the text entry above the Read F button. You may use

variables x, y, F1, F2, ... ,

operators (see the list),

Special functions,

named constants and numerical constants (scientific notation allowed).

After typing a (sub)Function push the Read F button, or hit Enter, to place it in the list.

Note that the functions are evaluated in the order given in the list. So you may use F2 inthe definition of F3 but not vice versa. You may change the order using the up and downarrows to the right of the list box.

A valid function definition would be:

F1=x

F2=sin(x)

F3=exp(-x)

F4=F1+ 2.45*F3*F2*F1^^2+ b*Erf(x) +3.4E+1

If you want to calculate F4 you have to select all 4 Functions

Comments: You can add a comments at the end of the definition. The comment should startwith either # or | as shown in the example above

Page 21: Springfield Holding B.V

21Functions

Springfield Holding B.V.

4.1.2 Constants

Constants are defined by selecting the constant from the list, editing the constant in the textentry box above the list and pushing the Read Constant button or hitting Enter. Note that thetext entry must be in the form of const= followed by the numerical value. Scientific notation isallowed. When you define a constant name that is not in one of the lists it will be placed at theend of the list.

There are two lists of Constants. Both may contain up to 50 entries. Both lists will be saved aspart of the Functions you have defined by choosing the File => Save => Function from the menubar.

The list of mathematical / physical constants is your personal list. You may save it separately bypushing the Save button on the right side. It will be loaded the next time you start MathGrapher.

Vary the constant with the slider.

The slider to the right of the constants list can be used to see the effect of changing theconstant value. The slider becomes active when the Function has been drawn. Select theconstant you want to vary and move the slider. The constant value changes in 20 stepsbetween the maximum and minimum values given in the value entries.

Page 22: Springfield Holding B.V

22 MathGrapher v2

Springfield Holding B.V.

4.1.3 Variables

These variables may be used in the function definition. Note that the functions are calculatedfrom F1 upward. So use only Fj with j lower than i in the definition of Fi.

n is the iteration number which may be used in the definition of algebraic series or iterativemaps (Iterations).

4.1.4 Operators / (sub)Functions

The operators and functions above may be used in the Function definition.

Page 23: Springfield Holding B.V

23Functions

Springfield Holding B.V.

4.1.5 Special Functions

The following Special Functions may be used in the Function definition: Click on the function to see its definition.

Random numbers

Ran(a) and Random(a,x)

Modulo function

Modulo function

Fresnel Integrals:

Sine Fresnel Integral

Cosine Fresnel Integral

Exponential integrals and related functions

Exponential integral Ei

Exponential integral En

Logarithmic integral

Sine integral

Cosine integral

Hyperbolic sine integral

Hyperbolic cosine integral

Gamma function and related functions

Gamma function

Incomplete gamma function of the first kind

Incomplete gamma function of the second kind

Riemann Zeta function

Zeta function

Bessel functions

Bessel functions of the first kind

Bessel functions of the second kind

Elliptic integrals

Page 24: Springfield Holding B.V

24 MathGrapher v2

Springfield Holding B.V.

Elliptic integral of the first kind

Elliptic integral of the second kind

Airy functions

Airy functions (first and second kind)

Probability function

Poisson probability function

Binomial probability function

Distribution functions

Binomial distribution function

Poisson distribution function

Error Function

Gaussian distribution function

Beta distribution function

Chi squared distribution function

Student's t distribution function

4.1.5.1 Random numbers

Random numbers: Random(a), Randstep(a,x) Random numbers: Random(a)

Random(a) Generates a series of random numbers between 0 and 1 from seed a.Below an example is given F1=Random(0.5) calculated for 100 x-values (F is not a function of x here)

Random steps with probability x: Ranstep(a,x)

Generates a random series of 0's and 1's from seed a. The average fraction (orprobablity) of 1's is given by x. Below an example is given of an Iteration (100 iterations):F1=F2F2=F1+ Ranstep(0.5,0.3)

Page 25: Springfield Holding B.V

25Functions

Springfield Holding B.V.

4.1.5.2 Modulo function

Modulo function: Mod(a,x)Mod(a,x) = x - k.a where k is chosen such that 0 < Mod(a,x) < a for a > 0 and a < Mod(a,x) < 0 for a < 0

4.1.5.3 Fresnel integrals

Fresnel integrals: C(x), S(x)

More information

Page 26: Springfield Holding B.V

26 MathGrapher v2

Springfield Holding B.V.

4.1.5.4 Exponential integrals

Exponential integral Ei(x)

Exponential integral En(x)

Logarithmic integral

Sine integral

Cosine integral

Hyperbolic sine integral

Hyperbolic cosine integral

4.1.5.4.1 Exponential integral

Exponential integral: Ei(x)

More information

Mathworld

4.1.5.4.2 Exponential integral En

(scaled) Exponential integral: En(n,x)

Page 27: Springfield Holding B.V

27Functions

Springfield Holding B.V.

Note the exponential integral is often defined without the scaling factor exp(x)

More information

4.1.5.4.3 Logarithmic integral

Logarithmic integral: li(x)

More information

4.1.5.4.4 Sine integral

Sine integral: S(x)

Page 28: Springfield Holding B.V

28 MathGrapher v2

Springfield Holding B.V.

More information

4.1.5.4.5 Cosine integral

Cosine integral: C(x)

More information

4.1.5.4.6 Hyperbolic sine integral

Hyperbolic sine integral: Shi(x)

Page 29: Springfield Holding B.V

29Functions

Springfield Holding B.V.

More information

Wikipedia

4.1.5.4.7 Hyperbolic cosine integral

Hyperbolic cosine integral: Chi(x)

More information

wikipedia

4.1.5.5 Gamma function

Gamma function

Incomplete gamma function

Complementary incomplete gamma fuction

Page 30: Springfield Holding B.V

30 MathGrapher v2

Springfield Holding B.V.

4.1.5.5.1 Gamma function

Gamma function: Gamma(x)

Wikipedia

Mathworld

4.1.5.5.2 Incomplete Gamma function

Incomplete (lower) Gamma function: gammi(a,x)

Mathgrapher calculates the normalized function:

Page 31: Springfield Holding B.V

31Functions

Springfield Holding B.V.

More information

4.1.5.5.3 Complementary incomplete Gamma function

Complementary (or upper) incomplete gamma function: Gammi(a,x)

Wikipedia

4.1.5.6 Riemann Zeta function

Riemann Zeta function: Zeta(x)

This series is convergent for all numbers s>1. This holds for all complex numbers with realpart >1. Euler showed that it is connected with the prime numbers by the relation

where the product runs over all prime numbers p.

Riemann found an anallytical continuation to this function for all s except 1

the integral runs from infinity to zero just above the real axis, turns aorund zero and runsback to infinity just below the real axisMathgrapher calculates this function along the real axis (s=1 excluded)

The famous Riemann hypothesis states that all (non-trivial) zeroes of this function are onthe line Re(s)=1/2. This Riemann hypothesis is unproved although more than 10^13 zeroeshave been found all of which ly on this line.

Page 32: Springfield Holding B.V

32 MathGrapher v2

Springfield Holding B.V.

More information

4.1.5.7 Bessel functions

Bessel functions of the first kind (real order and argument)

Bessel functions of the second kind (idem)

4.1.5.7.1 Bessel function (1st kind)

Bessel functions of the first kind: BesselJ(a,x)

Page 33: Springfield Holding B.V

33Functions

Springfield Holding B.V.

More information

4.1.5.7.2 Bessel function (2nd kind)

Bessel functions of the second kind: BesselY(a,x)

More information

4.1.5.8 Airy functions

Airy functions: AI(x), BI(x)

The Airy functions AI(x) and BI(x) are the two linearly independant solutions of the second-orderdifferential equation: y'' -xy=0For real values these functions are equal to the following integrals:

Page 34: Springfield Holding B.V

34 MathGrapher v2

Springfield Holding B.V.

and

More information

4.1.5.9 Elliptic integrals

Elliptic integral of the first kind

Elliptic integral of the second kind

en.wikipedia.org/wiki/Elliptic_integral

4.1.5.9.1 Elliptic integral of the first kind

Elliptic integral of the first kind: K(x)

Page 35: Springfield Holding B.V

35Functions

Springfield Holding B.V.

More information

4.1.5.9.2 Elliptic integral of the second kind

Elliptic integral of the second kind: E(x)

More information

4.1.5.10 Poisson probability function

Poisson probability function (or probability distribution function): Ppf(a,x)

Example: The distribution gives the probability for m radioactive decays in some fixed time interval,

Page 36: Springfield Holding B.V

36 MathGrapher v2

Springfield Holding B.V.

where a is the mean number of events in that interval (for example: a = np, the product ofthe the number of radioactive nuclei in a source and the probability for a nucleus to decay ina that interval of time).

More information

4.1.5.11 Binomial probability function

Binomial probability function: Bpf(a,b,x)

Gives the probability of m successes in n trials when the chance of success is p.In Mathgrapher this fuction is Bpf(a,b,x) where a=n, b=p, x=m

More information

Wikipedia

Page 37: Springfield Holding B.V

37Functions

Springfield Holding B.V.

4.1.5.12 Distribution functions

Binomial distribution function

Poisson distribution function

Gaussian distribution function

(Incomplete) Beta distribution function

Chi squared distribution function

Student's t distribution function (cumulative)

4.1.5.12.1 Binomial distribution function

Binomial (cumulative) distribution function: Bin(a,b,x)

Gives the probability that m or fewer successes occur in n independant trials when thechance of success is p.In Mathgrapher this is Bin(a,b,x) where a=n (integer), b=p and x=m (integer)

More information

Wikipedia

4.1.5.12.2 Poisson distribution function

Poisson (cumulative) distribution function: Pdf(a,x)

Page 38: Springfield Holding B.V

38 MathGrapher v2

Springfield Holding B.V.

Gives the probability of m or less events in some fixed time interval, where a is the meanrate of events.

More information

Wikipedia

4.1.5.12.3 Error function

Error function: Erf(x)

Page 39: Springfield Holding B.V

39Functions

Springfield Holding B.V.

More information

Wikipedia

4.1.5.12.4 Gaussian distribution function

Gaussian (standard normal) distribution function: Gausdf(x)

A random distribution is often described by the Gauss probability distribution function

Mathgrapher gives the standard cumulative Gauss distribution function, which is similar to theError function.

Page 40: Springfield Holding B.V

40 MathGrapher v2

Springfield Holding B.V.

More information

idem

4.1.5.12.5 Beta distribution function

(Incomplete) Beta distribution function: Betadf(a,b,x)= the cummulative probability of the Beta distribution

More information

idem

Wikipedia

Page 41: Springfield Holding B.V

41Functions

Springfield Holding B.V.

4.1.5.12.6 Chi squared distribution function

Chi squared distribution function (cumulative): Chidf(a,x)

the denumerator contains the Gamma function

In Mathgrapher this is Chidf(a,x) where a is the number of degrees of freedom (a= 0.5or larger).

More information

4.1.5.12.7 Student's t distribution function

Student's t distribution function (cumulative): Tdf(a,x)

the (de)numerator contains the Gamma function

In Mathgrapher this is Tdf(a,x) where a is the number of degrees of freedom (a= 1.0 orlarger).

Page 42: Springfield Holding B.V

42 MathGrapher v2

Springfield Holding B.V.

More information

4.2 2D Functions: F(x)

4.2.1 Variable

Push the Prepare / Draw button in the main button bar to open the Graph window and thePrepare / Draw graph window.

Set the minimum and maximum value of the free variable and the number of equidistantintermediate points where the function will be calculated.

There are 3 ways to give the number and values of the free variable (abscissa).

Choose equidistant x-values give specific values for the abscissa.

Selecting "x values from Grid below" gives a grid where you may give the number and valuesfor the abscissa (see below).

Page 43: Springfield Holding B.V

43Functions

Springfield Holding B.V.

You may also give the abscissa in the first column of one of the Data grids. The results of thefunction calculation will be placed in another column. This is done as follows: After definingand selecting the function go to Data. Give the abscissa in the first column of a Grid. Selectthe Extra tab in the Tabbox below the Grid, select the column where you want the functionvalues to be placed and push the button: F (column 1) => column Y

4.2.2 X-Y coordinates

Set Cartesian coordinates, Polar coordinates or Parameter functions

Polar coordinates:F(x) is defined as the radial distance as a function of some variable x. This implies that F.cos(x) is plotted along the X-axis and F.sin(x) along the Y-axis. => example

ParametrizationIn this case we have 2 functions F1(x) and F2(x) of a some variable x. F1 is plotted along the X-axis F2 is plotted along the Y-axis=>example

Page 44: Springfield Holding B.V

44 MathGrapher v2

Springfield Holding B.V.

4.2.3 Calculus

Calculation of Function Values, Zeroes, Extrema, Differentiation andIntegration.

Function Values

You may calculate F(x) or F(x,y) for single values of x (and y).Assign an x (and y) value and press the = button.

Select Integrate or Differentiate in the combo box to calculate the integral from xmin (set in theVariables tab) to x or the differential dF(x)/dx in x respectively (2D only).

Zeroes and Extrema

Find solutions of F(x) = 0 in some interval [xmin, xmax]

Define the function and draw the draw a Graph in the desired interval. Next push Calculus,select Zeroes or Extremaand push the Go button.

The results are written in a file in the working directory called 'Results.dat'. The contents of thisfile are shown in a separate window. The zero points and extrema are also drawn in the graph.The type, size and color of the symbol can be changed in the Add panel.

=> example

Differentiation

To calculate and plot the derivative of a function:

Define and select the function you want to differentiate numerically. Open the Prepare / Drawwindow and open the Calculus tab

Choose the interval [xmin, xmax]. You may also calculate dF/dx at a single point (see below).

Select Differentiate from the calculate list box and Press Go.

Press Draw dF/dx in the main button bar of the Prepare / Draw graph window.

You have to press the Stop button that appears under the Go button to switch to normalFunction mode.

Page 45: Springfield Holding B.V

45Functions

Springfield Holding B.V.

Single values for dF(x)/dx may be obtained by inserting a value for x in the the entry next to thex button on the function panel and pressing the = button.

=>back

Integration. Follow the same steps as in Differentation to integrate a function over some interval.

Example: Gaussian Distribution Function

4.2.4 Graph Window

The Graph window is opened by pushing the Prepare Graph button in the main button bar.

For 2D graphs it looks like the picture below. The range of the variable x is set in the Prepare /Draw window. The axis range is given in the Graph window and the other graph propertiessuch as graph position, axis annotation, line color etc. may be changed in the Graph propertiespanel (push the button in the main button bar).

Click on the hotspots in the image for more explanation

Page 46: Springfield Holding B.V

46 MathGrapher v2

Springfield Holding B.V.

In the case of 3D graphs the Graph window looks slightly different (see the example below).Here too the range of the variables (x,y) is set in the Prepare / Draw Graph window and thegraph type (shaded surface, contour map and/or cross-section) and the other graph propertiessuch as colors, line ratios etc. are set in the Graph properties panel.

4.2.5 Edit: 2D Graph

If you are not satisfied with the default settings for the Axes and the Lines / Symbols push the Graph properties button in the main button bar. Note that the contents of this Graph propertieswindow depend on your choice of 2D or 3D in the Prepare/Draw window.

Page 47: Springfield Holding B.V

47Functions

Springfield Holding B.V.

Click on the hotspots in the image for more explanation

4.2.6 Examples: Parameter Function

Choose the X-Y coordinates panel in the Prepare / Draw Graphwindow and activatethe Parametrizationcheck box. Define X(x) by selecting a Function in the Functionspanel and pushing the F1 button. Define Y(x) by selecting another Function andpushing F2

The "little man from planet Math" was made by choosingX(x)= F1=Sin(2*x), Y(x)=F2=Cos(4*x)*Cos(x)

Page 48: Springfield Holding B.V

48 MathGrapher v2

Springfield Holding B.V.

This Graph (Lissajous figure) was produced bydefining X(x) = F1 = Sin(2*x) and Y(x) = F2 =Sin(3*x)

4.2.7 Examples: Polar Coordinates

Example:

Define Function F1 as F1=sin(3*x). Open the Prepare / Draw window and open the X-Ycoordinates panel. Choose Polar coordinates.

The function F1(x) is now interpreted as a radial distance. The X-coordinate is then given byF1.sin(x) and the Y-coordinate as F1.cos(x)

F(x)=Sin(3*x) in radial coordinates

Ofcourse the same result can be achieved by activating the Parametrization check box anddefining F1 = x* Sin X and F2 = x*Cos(x) and choosing X(x) => F1 and Y(x) => F2.

Page 49: Springfield Holding B.V

49Functions

Springfield Holding B.V.

4.2.8 Examples: Damped Sine wave

Open the Function panel and define the Functions F1=e^(-a*x) and F2=F1*sin(x) with a=0.7(see the Damped Sine Wave example)

Push the Prepare Graph button to open the Graphical window and the Prepare / DrawGraph Window. Push Draw to produce the graph.

Next push Calculus, select Zeroes and push the Go button.

See also Extrema

4.3 3D Functions: F(x,y)

4.3.1 Variables

Push the Prepare / Draw button in the main button bar to open the Graph window and thePrepare / Draw graph window.

Set the minimum and maximum value of the free variable and the number of equidistantintermediate points where the function will be calculatedChoose equidistant x-values or give specific values for the abscissa.

Page 50: Springfield Holding B.V

50 MathGrapher v2

Springfield Holding B.V.

Set the minimum and maximum value of the free variable and the number of equidistantintermediate points where the function will be calculatedChoose equidistant x-values or give specific values for the abscissa.

4.3.2 Function: Calculus (3D)

calculation of function values

4.3.3 Function: Drawing a 3D Graph

Define and select the Function and its subFunctions in the main window using the keys Shift orCtrl. The functions are evaluated from F1 up to the selected one, so make sure that thesubfunctions are placed in the right order.

Push the Prepare Graph button in the main button bar to open the Prepare / Draw window andthe Graph window.

Prepare draw window

Page 51: Springfield Holding B.V

51Functions

Springfield Holding B.V.

Choose 2D or 3D in the upper left corner for a graph of F(x) or F(x,y) respectively.

If necessary adjust minimum and maximum values of x and y and the number of Nx and Ny,the number of points along the X-and Y-axis where F is calculated.

Press Draw Graph to produce the graph. The type of Graph and the Graph properties are set inthe Graph properties window which is opened by pushing the Graph properties button in theMathgrapher's main button bar. Several Graph types can be drawn: shaded surface, contourmaps and cross-sections through a contour map. Colors, orientation, axis notation, size,position can all be altered in thus window. A shaded surface and contour map for the Function F(x,y) = sin(x)-y is given below

Graph window

Page 52: Springfield Holding B.V

52 MathGrapher v2

Springfield Holding B.V.

Below you see an example of an contour map with cross-section through the line drawn in thecontour map.

Page 53: Springfield Holding B.V

53Functions

Springfield Holding B.V.

It is often useful to look at the surface from different angles and distances in the 3D Viewerwindow. Push the Open 3D Viewer button and push the Draw in 3D Viewer button tomanipulate the 3D object with your mouse and to choose an appropriate orientation.

Page 54: Springfield Holding B.V

54 MathGrapher v2

Springfield Holding B.V.

4.3.3.1 Surface Graph

Click on the hotspots in the image for more information

Example of shaded surface graph with contour maps (perpspective and top view).This is thefunction given by F=cos(0.7*r) (x-5)^2/r, where r=sqrt[(x-5)^2 + y-5)^2)].

Page 55: Springfield Holding B.V

55Functions

Springfield Holding B.V.

4.3.3.2 Contour Plot

Click on the hotspots in the image for more information

Example of shaded surface graph with contour maps (perpspective and top view)

Page 56: Springfield Holding B.V

56 MathGrapher v2

Springfield Holding B.V.

4.3.3.3 Cross-section

Click on the hotspots in the image for more information

Example of 2D contour plot with cross-section below. The 2D contourplot is drawn first. Then the cross-section toggle button is pushed, the begin andendpoints are chosen in this plot using the mouse cursor and the Draw button is pushed again.

4.3.3.4 Examples: Shaded surface

The shaded surface and the contour plots below are representations of the function

Page 57: Springfield Holding B.V

57Functions

Springfield Holding B.V.

This graph is made in the following steps

Define the Function or get it from the File => Open => Function => Examples-2D.fct

Push the Prepare Graph button and select 3D in the Prepare / Draw window. Set Nx =50, Ny= 50, set the x- and y-range from -4 to 4 and push Draw to produce the shaded surface

Push the Graph preperties button. Push the Surface button (checked) and open the Line ofsight panel to set the orientation angles. You may also change the orientation in the 3DViewer. Push the Position button if you want to change the corner positions of the SurfaceGraph.

Push the Contour Map button and select Contour Map (2D) and the Contour Map inperspective view (under the surface graph). Set the number of contours equal to 8 andchoose the colors you like

Choose the corner positions of the 2D Contour Map, Erase the old drawing and push Draw

Contour plot

Page 58: Springfield Holding B.V

58 MathGrapher v2

Springfield Holding B.V.

Flat contour plot (8 contours) with Cross-section

This Graph was made as follows:

Push the Graph preperties button and select the Contour Map and Cross-section togglebuttons.

Push the Contour Map button and select Contour Map (2D). Uncheck the Contour map inperspective view. Push the Position button to choose new corner positions for the Contourmap

Push the Draw button.

Next push the Cross-section button and choose begin/endpoint of the section by clicking onthe Contour Map and push the Position button to choose the position of the Cross-sectiongraph.

Finally push the Draw button again to make the Graph

4.3.4 Graph Window

The Graph window is opened by pushing the Prepare Graph button in the main button bar.Below you see a surface graph and a contour plot of Function F4 in the Example3d.fct file. Thestatus bar gives the position of the cursor in the contour plot.

In the Graph window you may draw shaded surface graphs, contour plots and cross-sectionsthrough contour plots. Push the Graph properties button in the main button bar to choose thegraph type and to set its properties.

Click on the hotspots in the image for more information

Page 59: Springfield Holding B.V

59Functions

Springfield Holding B.V.

4.3.5 Edit: 3D Graph

After pushing the Graph properties button in the main button bar the panel below appears.Here you may choose the type of Graph and change its properties.

Four different Graph types may be drawn in one drawing action:

1. Shaded or contoured surface plot in perspective

2 a. Contour map in perspective view (drawn under the surface plot) b. Flat (2D) Contour map

3. Cross-section through the contour map

The 3 tabs in the upper row give acces to the properties panel of the these Graph types. Use thetoggle buttons to choose which Graph you want to draw.

Page 60: Springfield Holding B.V

60 MathGrapher v2

Springfield Holding B.V.

Click on the hotspots in the image for more information

4.3.6 3D Viewer Window

The 3D Viewer is a handy tool to have a quick look at the Surface (Function or Data) fromdifferent sides and under different shading conditions.The surface is drawn by pushing the Draw in 3D Viewer button in the Prepare / Draw window

Click on the hotspots in the image for more information

Page 61: Springfield Holding B.V

61Functions

Springfield Holding B.V.

Grab the 3D picture with your left mouse button and hold it down to rotate the surface or to zoomin or out. You may change the position of the ligth sources in the same way. The viewing anglealways stays in the direction of the axis origin.

Once you have found a favourable orientation you may transfer the orientation parameters to thesurface in the Graph Window using the =>Graph button. The axis ratios and the lightingproperties are not transferred.

The contents of the 3D Viewer can be saved in different file formats (bitmap, jpg, encapsulatedpostscript, windows metafile, portable network graphics)

4.4 Import / Export: Functions

Mathematical functions defined in MathGrapher can be stored on disk and retrieved by going tothe pull down menu. Choose File => Save (or Open) => Function to open a file browser. TheFunction files have default extension .fct

Some predefined example files are placed in the MathGrapher directory during installation.

Example Functions:

2D / 3D Functions in Functions/Examples-2D.fct and Examples-3D.fct

Iterations in subdirectory Functions/Map

Page 62: Springfield Holding B.V

62 MathGrapher v2

Springfield Holding B.V.

Ordinary Differential Equations in subdirectory Functions/ODEs

Page 63: Springfield Holding B.V

MathGrapher

Part

V

Page 64: Springfield Holding B.V

64 MathGrapher v2

Springfield Holding B.V.

5 Data

5.1 Data: panel

In the data panel you may define or import data in one of the data grids.The maximum number of cells is presently 100.000

Click on thehotspots in theimage for moreinformation

5.2 Import: Data

Data can be imported into the grid in 4 ways:

Direct editing/writing in the grid cells

Copy and paste from a tab separated data grid such as Microsoft Excel, or from atab-separated text file.

Go to File => Get => Data in the menu to import a file that was saved by MathGrapher(default extension .dat).

Page 65: Springfield Holding B.V

65Data

Springfield Holding B.V.

Importing data points by clicking on a graph (see example) after pushing the Read Datafrom Graph button on lower right of the Data panel.

5.3 Data: Drawing a Graph

Push the Data button in the main button bar.

Select the Data you want to plot either by by dragging the mouse cursor over the grid withthe left button pressed, or by selecting the upper left and lower right corners and pushing theSelection buttons.

Push the Prepare Graph button in the main button bar to open the Prepare / Draw window(shown below) and the Graphics window.

Click on the hotspots in the image for more information

2D

Up to 9 lines (columns) can be drawn in a 2D graph. You may choose either the rownumber or the values in the first selected column to represent the abscissa of thegraph. The other columns contain the Y-values.

3D

Choose 3D to draw a surface graph. Here too you may choose either the row numbers(and column numbers) or the values in the first row (and column) as the X- (and Y-)coordinates.

Press Draw Graph to produce the graph. In 3D you may also view the surface graph in the3D Viewer.

Push the Graph properties button in the main window to change the axes and line properties

5.4 Data: Statistics

5.4.1 Statistics panel

In this version of MatGrapher some statistical calculations can be performed on selected cellsin the data grids.

To select Data: Push the Data button in the main button bar.

Page 66: Springfield Holding B.V

66 MathGrapher v2

Springfield Holding B.V.

Select the Data by dragging the mouse cursor over the grid with the left button pressed, orby selecting the upper left and lower right corners and pushing the Selection buttons.

Push the Prepare / Draw button to open the Graphical window and the window shownbelow. Here you may choose the type of calculation you want to do.

Click on the hotspots in the image for more information

5.4.2 Statistics

1) Statistical measures of a set of selected data

2) Sort selected data (selected Y-values) in increasing order

3) Histogram

Select a number of Y-values from a data grid. You may draw a histogram of these Y-values.It may be necessary to sort the data in increasing order before drawing the histogram. Notethat the Y-values from the data grid are given along the X-axis in the graph.Henceforth we will denote them by X

4) Histogram - normalised

The normalised distribution is obtained by deviding the numbers in each bin by the totalnumber of X-values. This distribution approaches a probability function for large totalnumber Ny and large number of bins Nbins.

5) Distribution function (cumulative, normalized)

The cumulative distribution gives the number of X-values below a certain X-value. Ifnormalised it approaches a Distribution function (for the Y-values in the grid):

Page 67: Springfield Holding B.V

67Data

Springfield Holding B.V.

where the probability function Pf(x)dx represents the probability that y lies between x andx+dx.

6) Chi-square test - 1 and 2

The Chi-square test is used to test differences between binned distributions. TheselectedY-values in grid 1 and grid 2 are compared. In the first test the Y-values in grid 1 are assumed to represent a theoretical distribution.Chi-squared is defined as

where Ni is the number in the i-th bin and ni is the number expectred according to someknown distribution. Both distributions should contain the same total number of events.The probablity (0<P<1) that the numbers Ni are drawn from the expected distribution iscalculated. It is an incomplete Gamma function of Chi-squared. In the second test two measured data sets (in grid 1 and grid 2) are compared. Chi-squaredis then defined as

where Ni and Mi are the numbers in the i-th bin of the distributions calculated in grid 1 andgrid 2. The total numbers should be the same. The probablity P that the two distributions aredrawn from the same underlying distribution is calculated. A small value of P indicates thatthe two distributions are probably different.

7) Kolmogorov-Smirnov test - 1 and 2

The KS-test is used to test differences between unbinned distributions of a singlecontinuous variable. The largest vertical difference D between the cumulative distributions isdetermined. This yields the probability that the two distributions are drawn from the sameunderlying distribution. The first test compares the data in grid 2 with a theoretical (normalized) distribution functiondefined in the Function panel. The second test compares (observed) data in grid 1 and grid 2.

Page 68: Springfield Holding B.V

68 MathGrapher v2

Springfield Holding B.V.

5.4.3 Statistical measures

A few commonly used statistical measures are calculated. Their definition is given below.

n is the number of data points x. Note that these x- values do not need to be the numbersalong some axis; they represent the values given in the selected cells in the data grid.SD - Standard Deviation - is a measure of the width of the distribution.Skewness indicates the degree of asymmetry.Kurtosis is a measure of the peakedness of the distribution. For a Gaussian distribution ithas the value 3. A more peaked distribution has a Kurtosis larger than 3.

The Minimum and Maximum value and the Median are given as well as. By definition thenumber of values that are smaller than the Median equals the number that are larger.

These measures are calculated

for data selected in one of the Data grids when the Calculate button in the Calculus panelof the Prepare / Draw window is pushed, and

for the residuals of a least squares fit when the Go button on the Curve Fitting panel ispushed.

5.5 Graph Window

The Graph window is opened by pushing the Prepare Graph button in the main button bar.

For 2D graphs it looks like the picture below. The range of the variable x is set in the Prepare /Draw window. The axis range is given in the Graph window and the other graph propertiessuch as graph position, axis annotation, line color etc. may be changed in the Graph propertiespanel (push the button in the main button bar).

Click on the hotspots in the image for more explanation

Page 69: Springfield Holding B.V

69Data

Springfield Holding B.V.

In the case of 3D graphs the Graph window looks slightly different (see the example below).Here too the range of the variables (x,y) is set in the Prepare / Draw Graph window and thegraph type (shaded surface, contour map and/or cross-section) and the other graph propertiessuch as colors, line ratios etc. are set in the Graph properties panel.

Page 70: Springfield Holding B.V

70 MathGrapher v2

Springfield Holding B.V.

5.6 3D Viewer Window

The 3D Viewer is a handy tool to have a quick look at the Surface (Function or Data) fromdifferent sides and under different shading conditions.The surface is drawn by pushing the Draw in 3D Viewer button in the Prepare / Draw window

Click on the hotspots in the image for more information

Page 71: Springfield Holding B.V

71Data

Springfield Holding B.V.

Grab the 3D picture with your left mouse button and hold it down to rotate the surface or to zoomin or out. You may change the position of the ligth sources in the same way. The viewing anglealways stays in the direction of the axis origin.

Once you have found a favourable orientation you may transfer the orientation parameters to thesurface in the Graph Window using the =>Graph button. The axis ratios and the lightingproperties are not transferred.

The contents of the 3D Viewer can be saved in different file formats (bitmap, jpg, encapsulatedpostscript, windows metafile, portable network graphics)

5.7 Edit: 2D Graph

If you are not satisfied with the default settings for the Axes and the Lines / Symbols push the Graph properties button in the main button bar. Note that the contents of this Graph propertieswindow depend on your choice of 2D or 3D in the Prepare/Draw window.

Page 72: Springfield Holding B.V

72 MathGrapher v2

Springfield Holding B.V.

Click on the hotspots in the image for more explanation

5.8 Edit: 3D Graph

After pushing the Graph properties button in the main button bar the panel below appears.Here you may choose the type of Graph and change its properties.

Four different Graph types may be drawn in one drawing action:

1. Shaded or contoured surface plot in perspective

2 a. Contour map in perspective view (drawn under the surface plot) b. Flat (2D) Contour map

3. Cross-section through the contour map

The 3 tabs in the upper row give acces to the properties panel of the these Graph types. Use thetoggle buttons to choose which Graph you want to draw.

Page 73: Springfield Holding B.V

73Data

Springfield Holding B.V.

Click on the hotspots in the image for more information

5.9 Examples: Data Graphs (2D)

Step 1

Push Data in the Input panel (upper left) to open the Data panel.

Step 2

Edit / Import data into the grid (see also Import/Export data). Type or Copy/Paste thefollowing numbers into the grid.

1 2 122 5 104 5 86 8 148 8 1212 6 8

Note that the Abcissa (X-values) should be in the first column of the grid

Step 3

Select the second and third rows by dragging the mouse over the cells with the leftbutton pressed down.

Step 4

Press Draw.

Step 5

Next select the first 3 rows and Draw the two lines in the same graph.

Step 6

Press the Graph preperties button to change the Position of the Graph, the Axisproperties and the Lines/Symbols properties on the Graph preperties panel. You maychoose Line and Symbol properties for up to 9 different lines and/or symbols.

Page 74: Springfield Holding B.V

74 MathGrapher v2

Springfield Holding B.V.

5.10 Read data from the Graph into a Grid

Read data from the Graph into one of the Data Grids

After drawing a (2D) graph you may read points from the Graph into the Grid.

Select the cell in the Data grid where the first X-coordinate should be placed. TheY-coordinate will be placed in the cell to the right.

Open the Extra tab on the Data panel and push the Read Data from Graph. The buttonwill start flashing until you are finished.

Place the mouse pointer on the point in the Graph which you want to import click the leftmouse button. The coordinates will be placed in the grid. Subsequent X-Y coordinatesare placed below the previous ones.

Continue reading points from the Graph into the Grid. When you are finished push theStop Reading Data button.

You may also import a graph into the graphical window and read Data from it

=> see an Example

5.11 Calculate Function values for column 1

Define and select the Function(s) in the Function panel

Go to the Data panel and type or paste the values of the x-values in the first column ofone of the data grids

Open the Extra tab and select the column where you want the function values to beplaced

Push the F(column 1) => column Y button.

Draw the graph by selecting the Y column and pushing the Draw graph button in the Prepare /

Page 75: Springfield Holding B.V

75Data

Springfield Holding B.V.

Draw window.

Note that you may do the same result wil be obtained In Function mode by selecting thevariables tab in the Prepare / Draw window, choosing x-values from the grid, typing the x-valuesin the grid on that tab panel and pushing the Draw button.

5.12 Examples: Read Data from Imported Graph Image

Step 1

Import an image graph by selecting File => Open => Image in the menu and select forinstance the consumption.bmp file. This image file has 256 colors. If necessary rotatethe image by +90 or -90 degrees.Note that it may take some time (seconds) to import a file with 16 million colors.

Step 2

Choose appropriate minimum and maximum values of X and Y. Press the Graphproperties button in the button bar and open the Axes => Axis Annotation panel.Activate the Fix min/max toggle buttons and type the minimum and maximum values ofX and Y in the value entries.

Step 3

Activate the Fix endpoints toggle buttons. You can also fix the number of intervals along the axes.

Step 4

Push Position and let the lower left corner coincide with [Xmin,Ymin] and the upper rightcorner with [Xmax,Ymax].

Step 5

Press the Prepare Graph button. Make sure the Function button on the button bar isactivated and push Draw button in the Prepare / Draw Graph window. The axes will bedrawn and the scaling is set. Check this by placing the cursor on the graphics screenand reading the coordinates in the status bar.

Step 6

Now you can read the data from the graph into the value grid, plot them again and/orfind a best fitting curve (see Read Data from Graph).

Page 76: Springfield Holding B.V

MathGrapher

Part

VI

Page 77: Springfield Holding B.V

77Curve fitting

Springfield Holding B.V.

6 Curve fitting

6.1 Curve Fitting introduction

A number of curve fitting methods may be selected. In all cases you must first select the data from the grid and plot them. Then select the a curvefitting method from the list box:

Levenberg-Marquardt (general, non-linear)You can use this method to fit your data to any (non-linear) continuous function youdefine. This function may contain several constants. Give these constants a reasonableinitial value, press the Go button and Mathgrapher will return the values for the leastsquares fit (see Example)

Predefined functions

Linear combination of Functions and Data sets

Click on the hotspots in the image for more information

Press the Go button to find a least squares fit to the selected dataThe results are shown in the Graphical window and in the Results window.

Graphical window. The type, width and color of the line drawn in the Graphical window canbe changed in the Add panel

Page 78: Springfield Holding B.V

78 MathGrapher v2

Springfield Holding B.V.

Results window. The values of the best fitting constants is written in the Results.out filewhich is shown in the window. Some statistical properties of the Residuals are also calculatedand shown.

6.2 Curve Fitting: Levenberg-Marquardt

The Levenberg-Marquardt method is a very general algorithm to find a least-squares fit of aset of data points to a (linear or nonlinear) function (see Example).

It is done in only 3 steps

Step 1. Go to Data. Select the data from the grid and plot them.

Step 2. Define and select your function in the Function panel. Select the constants for whichyou want to find a best fit and give them an appropriate initial value. You may select morethan one constant by using the Ctrl or Shift Button.

Step 3. Go to Curve Fitting, select Levenberg-Marquardt and press Go

The least-squares fit is shown in the graph and the values of the constants are written in theResults.out file which is shown in the Results window.

Example

The example given below illustrates a fit to data from a Fermi distribution:

A good description of the method is given in "Numerical Recipes, The Art of ScientificComputing", by W. H. Press, B. P. Flannery, S. A. Teukolsky and W.T. Vetterling, 1986,Cambrige University Press, Cambridge.The numerical code was adopted from the SLATEC Common Mathematical Library:

Page 79: Springfield Holding B.V

79Curve fitting

Springfield Holding B.V.

http://www.netlib.org/slatec/

=>back

6.3 Curve Fitting: Predefined functions

Simpler algorithms are used to find least squares fit for some special cases such as:

Straight Line (linear regression)

Example

Some special curves (linearization of data)

Polynomials

Trigonometric polynomial

Finally it is possible to produce a smooth curve through the data points using the cubic splinesmethod.

Press the Go button to find a least squares fit to the selected dataThe results are shown in the Graphical window and in the Results window.

Graphical windowThe type, width and color of the line drawn in the Graphical window can be changed inthe Add panel

Results windowThe values of the best fitting constants is written in the Results.out file which is shown inthe window. Some statistical properties of the Residuals are also calculated and shown.

6.4 Curve Fitting: Linear combination of Functions and Data sets

Choose the third option if you want to fit your Data (xi,yi) to a linear combination of Functions anData sets. In the example given in the Demonstrations we define functions F3, F4 and F5 in theFunctions panel and give data sets Y2 and Y4 in the Data panel. Select these functions andData sets in the list boxes on the Curve fitting panel. We the constants const1.. const5 thatminimize the norm ||Yi - yi||, where

Yi = const1 * F3(xi) + const2 * F4(xi) + const3 * F5(xi) + const4*Y2(xi) + const5*Y4(xi)

(see Example).In the demonstrations we find a fit for a spectrum that is composed of two model spectra Y1 andY2 and a background of the form const1 + const2*Log(x). For that purpose we defined F1=1and F2=Log(x). The model spectra Y1 and Y2 were given in Grid 2 and the observed data inGrid 1.

Press the Go button to find a least squares fit to the plotted dataThe results are shown in the Graphical window and in the Results window.

Graphical windowThe type, width and color of the line drawn in the Graphical window can be changed inthe Add panel.

Results windowThe values of the best fitting constants is written in the Results.out file which is shown inthe window. Some statistical properties of the Residuals are also calculated and shown.

Page 80: Springfield Holding B.V

80 MathGrapher v2

Springfield Holding B.V.

6.5 Curve fitting - Examples

6.5.1 Straight Line

Step 1

Generate and Draw some data:1) Define the Function aX+b and make a Graph. Go to the Data panel, push

the Read Data from Graph button and read some data along the line,or,

2) Copy and Paste the following data into the grid.

0.50000 2.500002.00000 5.000003.00000 7.000004.50000 6.500006.00000 7.000008.00000 8.000009.00000 12.000009.20000 13.00000

Select the data using the mouse and push the Draw button in the Prepare / DrawGraph window. Make sure the 2D toggle button is checked Note that the data points are connected by straight lines (default). You can change thisby pushing the Line/Symbols button in the Graph properties panel and selecting onlySymbols.

Step 2

Select the toggle button Predefined functions and choose ax+b from the combo box

Step 3

Push Go. The resulting least squares fit to the data will be plotted in the graph. Theresulting constants are written in the Results.out file which is shown in the Results Windowtogether with some statistical data on the residuals (toggle button: Residual statistics). TheRMS error is the Root of the Mean of the Squared differences between the data points andthe line. (Note that this differs slightly from the Standard Deviation which has n-1 in stead ofn in the denominator)

Page 81: Springfield Holding B.V

81Curve fitting

Springfield Holding B.V.

6.5.2 Levenberg-Marquardt

The example given below illustrates a fit to data from a Fermi distribution:

Page 82: Springfield Holding B.V

82 MathGrapher v2

Springfield Holding B.V.

Step 1

Define the Function:First we create some data by defining and plotting this function for a=4, b=0.5 and c=2.

Step 2

Generate some Data:Push the Data button on the main button bar. Push the Read data from Graph button andchoose some points along the curve. The data points appear in the value grid. Select thedata and Draw them. It is usefull to redraw the Data using Symbols (change theproperties in the Graph properties panel).

Step 3

Select variables and assign initial values: Go back to the Function panel to choose the constants for which you want to find a leastsquares solution to the selected data. Give them an appropriate initial value. Note that you may select more than one constant by using the Ctrl or Shift Button.

Step 4

Find a solution and check the results:Finally open the Curve Fitting panel, select Levenberg-Marquardt and press Go. Theresulting solution is drawn in the graph and the results together with some statistics of theresiduals are shown in the Results window.

Check to see if the original values of a and b are retrieved!!

Non-continuous functions or complicated periodic functions are difficult to fit . Such functionsrequire special fitting algorithms. As an experiment define and plot the singular function 1/(x+b) for b = - 5 in the interval [0,10].Read some points from the graph and try to find a fit with Levenberg-Marquardt. Then try to fit itwith the 4th or 5th entry in the Curve Fitting list box.

Page 83: Springfield Holding B.V

83Curve fitting

Springfield Holding B.V.

6.5.3 Linear combination of Functions and Data sets

The example given below illustrates a fit to 2 model spectra: Y1 and Y2, and 2 backgroundfunctions: F1 and F2.

This fit was obtained in the following steps

Define the Functions:F1 was defined as F1=1. and F2 = Log(x)

Import observed Data in Grid 1:Open grid 1 and select Open => Data and choose the data file: Hb-HbO-spectra.grd

Import the 2 spectra in Grid 2: Open grid 2 and select Open => Data and choose the data file: Hb-HbO-obs.grd

Find a solution and check the results:Finally open the Curve Fitting panel, select the third option, select F1, F2, Y1 and Y2 andpress Go. The resulting solution is drawn in the graph and the results together with somestatistics of the residuals are shown in the Results window.

Page 84: Springfield Holding B.V

MathGrapher

Part

VII

Page 85: Springfield Holding B.V

85Iterations

Springfield Holding B.V.

7 Iterations

7.1 Iterations: Definition

Iterations are defined in the same way as Functions. The difference is that the selectedFunctions are calculated n times, where n is given in the Prepare / Draw Graph window. In thiswindow the initial values of the Functions are given also. Function values of the nth iteration arecalculated using the results of the (n-1)th calculation. n may be used as a variable in theFunction definition.

It is important to realize that the Functions are calculated from the first selected function upwardto the last selected function. So you may use F2 in the definition of F3, but don't use F3 in thedefinition of F2.

EXAMPLES

Algebraic series:

Calculate e = 1 + 1/2! + 3!... by defining F1=F2, F2=F2+1/n! with initial value F2=0

Iterative maps:

1) The one-dimensional logistic map:

can be represented by

F1=F2 F2=4*a*F1*(1-F1).

N.B. N-dimensional maps should be represented by 2N equations, where the last N F'sdepend only on the first N F's.

2) The two-dimensional Henon map:

is best represented by the following 4 equations:

F1=F3

F2=F4

F3=1 - a*F1**2 + F2

F4= b*F1

where F1 and F2 are the nth x and y values and F3 and F4 the n+1 th.

Other Examples are shown in the Demonstrations.

Some special well known iterative maps are given in the Functions => Maps folder. These can

be imported by choosing File => Open => Functions from the menu bar.

ITERATION TYPES

You can do 3 types of Iterations in Mathgrapher:

Type I (Default): the iteration is done n times starting form the initial F - values. Severaltools are available to analyse the results.

Type II: Type I Iterations are done for a range of parameter values (for example theparameter a in the logistic map) or initial F-values

Type III: Mandelbrot and Julia sets. Type I iterations are done for a 2-dimensional rangeof parameters (a and b in the Mandelbrot map) or initial values (F1,F2 in the Julia sets)

Page 86: Springfield Holding B.V

86 MathGrapher v2

Springfield Holding B.V.

7.2 Iterations: Start / End Conditions

After defining your series or (multi-dimensional) iterative map push the Prepare Graph button inthe upper button bar to open the Graphics screen and the window shown below.

Her you may give the Initial values of the F's you want to iterate and the number of iterations.Select an F in the list, give the initial value in the value entry and push the Read F button.

The final values are shown when the iterations are completed.

7.3 Iterations - Type I: Standard Iteration

By standard iteration we mean that a single iteration run is done for one set of initial values andone value of the constants in the Function definition. You have 2 options:

Type Ia. Store the intermediate F-values. These F-values can be plotted and analysedin a second step (see the Analysis panel). The results are drawn in the Graph window

Page 87: Springfield Holding B.V

87Iterations

Springfield Holding B.V.

Type Ib. Draw the results (2D) in the Pixel Graph window during the iteration run. Thisoption is used to draw a high resolution graph of the results (see the Demonstrations).In this case intermediate F-values are drawn in the Pixel graph window during theiteration. You my choose which F's are plotted along the X and Y axis. The range of theX and Y coordinates is set in the Pixel Graph window.

7.4 Iterations - Type II: Vary one parameter

Iterations are done for a range of parameter values (for example the parameter a in the logisticmap) or initial F-values. So a type I iteration is done for a range of parameter values in stead ofa single one.

This type of iterations is used to calculate series (summation or product for example) or thebifurcation diagram of the logistic map (see the Demonstrations). The results are drawn in the

Page 88: Springfield Holding B.V

88 MathGrapher v2

Springfield Holding B.V.

Graph window.

In the lower left panel you choose the parameter you want to vary (x or one of the otherparameters occurring in the Function definition), its begin and end value, and the number ofintermediate values for which you want an iteration. The parameter values will become theabcissa in the final plot. For the ordinates you may choose the end value of one of the F's or theLyapunov exponent.

Example: Bifurcation diagram of the Logistic map

Below the result is shown of iterates of the logistic map for a ranging from a=0.72 to a=0.98(see also Demonstrations=>Iterations=>Logistic map). Note the period doublings at a=3/4 and0.862 and higher. As a increases the behaviour becomes increasingly chaotic especially abovethe gap at a=0.96 where a 3-cycle occurs (see the power spectrum).

Page 89: Springfield Holding B.V

89Iterations

Springfield Holding B.V.

7.5 Iterations - Type III: Mandelbrot and Julia

Iterations are done for a 2D range of parameter values (for example the parameters a and b inthe Mandelbrot sets) or initial F-values (as in the Julia sets).

This option is used to study the stability of orbits in a 2D graph of parameters (or constants) asin the well-known graphs of the Mandelbrot set, or a 2D graph of initial conditions as in the Juliasets.

The results are shown in the Pixel Graph window. In the lower part of the Prepare / Drawwindow (see below) you may set which parameters (or initial F-values) are given along the Xand Y-axis. In the Pixel Graph window you choose the pixel size of the graph (not larger than400x300) as well as the ranges for the parameters (or initial values).

For each pixel an iteration is done until the Escape condition is met. The pixel color isdetermined by the number of iterations it takes to meet this condition. You have to define aseparate function F in the Function panel to be used in the Escape condition. This function willcome after the other functions. So, in the case of a N=3-dimensional map, you have 2N=6functions and the escape function will be F7. In many cases the escape function will besomething like a distance to origin or some other reference point, f.e. F7=sqrt(F4^2+F5^2+F6^2)and the Escape condition will be some maximum distance to this reference point.

7.6 Type I Iterations: Analysis

7.6.1 Iterations: Analysis

The Analysis tab applies only to Iterations of Type I

First start the Iteration by pushing the Iterate button.Then, make your choice from the combo box and draw Draw.

Push the Show Evolution button to draw the successive iterations in slow-motion.

Page 90: Springfield Holding B.V

90 MathGrapher v2

Springfield Holding B.V.

Click on the hotspots in the image for more information

7.6.2 Iteration sequence

Below the result is shown of 30 iterations of the logistic map

(File=>open=>Function=> Open=>Maps=>logistic.fct) for a=0.94After defining and selecting F1 and F2 in the Iterations panel, the Prepare / Draw window isopened, the initial values of F1 and F2 are set in the Start / End conditions panel. Push theIterate button. Finally select Time Series in the combo box on the Analysis panel, select F1and F2 and push Draw to produce the Graph below.

The red line is the result of setting the initial values F1=0.0 and F2=0.2. The black line starts at F1=0.0 and F2=0.202. Note how a small variation in initial valuescauses a sudden change after 14 iterations.

Page 91: Springfield Holding B.V

91Iterations

Springfield Holding B.V.

7.6.3 Power spectrum

Below 2 power spectra are shown for the logistic map.

(File=>open=>Function=>Maps=>logistic.fct)The normalized power spectrum is calculated from the results of the Iteration. Note that only thefirst 2**k points are used in the calculation of the Power spectrum, where k is the largest integerfor which 2**k is smaller than, or equal to N.

The result below is for 256 iterations starting with initial values F1=0.0, F2=0.2 and a = 0.99. Atthis high value of the constant a the behaviour is quite chaotic. This can also be seen in the bifurcation diagram. Note that this diagram shows a gap at a=0.96 where we find a 3-cycle.Indeed the power spectrum graph gives a nice peak at J=171 which means that the 256iterations show about 85 ( =(171-1)/2 ) cycles.

7.6.4 Projections in 2D

Choose a pair of F's from the Functions that are iterated (use your Ctrl button) and push Drawto make a graph where the X-axis represents the first and the Y-axis the second Function.

Below some examples are given for the logistic map

Page 92: Springfield Holding B.V

92 MathGrapher v2

Springfield Holding B.V.

The example below is a graph of F1 and F2 for a series of 1024 iterations of the logistic map.The first 100 iterations are omitted. Note that a 4-cycle has developed for a=0.87

Same as above for a=0.89 showing an 8-cycle and a=0.96 (the gap in the bifurcation diagram)where we have a 3-cycle. The behaviour is chaotic above 0.96.

=>back

Page 93: Springfield Holding B.V

93Iterations

Springfield Holding B.V.

7.6.5 Projections in 3D

A combination of three functions that are integrated (iterated) and selected represents an orbit ina three dimensional space. For example if functions F2, F3 and F4 are selected, then the orbit isdefined by X(t) =F2(t), Y(t)=F3(t) and Z(t)=F4(t).

You may select different colors for the orbit and/or its projections on the X-Y, X-Z or Y-Z plane(see the Example for the Lorenz attractor). Projections in 3D are more useful for analyzing thesmooth orbits produced by integrating ODE's than for the irregular and discontinuous seriesfrom multi-dimensional iterative maps.

Multiple orbits may be drawn as in the case of 2D orbits. The number of functions you select fordrawing must be a multiple of three. Open the Graph properties window to change the colors ofthe orbits and their projections

Use the Show Evolution button to draw the orbit in slow motion

7.6.6 Fixed points

Consider a 2-dimensional map T given by

The map has a fixed point X when

There are several types of fixed points depending on the behaviour of the orbits in theirneighborhood: stable or elliptic, hyperbolic, parabolic The behaviour of the orbits near a fixedpoint can be found by studying the linearized equations for small perturbations around the fixedpoint.

The eigenvalues of the matrix T determine the type of equilibrium point and its stabilityproperties. They are the roots of the equation

where I is the identity matrix. In the 2-dimensional case discussed here this generally yields 2

Page 94: Springfield Holding B.V

94 MathGrapher v2

Springfield Holding B.V.

solutions. The eigenvalues are sometimes called characteristic multipliers. Just like theeigenvalues at an equilibrium point their position in the complex plane determines the stabilitynear the fixed point. The magnitude of the eigenvalues give the amount of contraction orexpansion near the fixed point and must therefore be equal to the Lyapunov exponents near thatpoint. Below are some orbits drawn for the Henon map

for a=0.2 and b=0.998The two fixed points are at (2.23,2.23) and (-2.23, -2.23). The eigenvalues in the first fixed pointare -1.54 and 0.647. The eigenvalues in the other point have opposite signs.

The results are written in a file in the working directory called 'Results.dat'. The contents of thisfile are shown in a separate window

7.6.7 Lyapunov exponents

Lyapunov exponents are very important and useful in the description of chaoticdynamical systems. They describe the exponential rate at which neighboring orbitsdiverge. They can be used to determine the behaviour of quasi-periodic and chaoticbehaviour as well as the stability of equilibrium points and periodic solutions. For orbitsnear equilibrium points they are equal to the real parts of the eigenvalues at these points.

The number of Lyapunov exponents is equal to the dimension of the system of ODE's, so asystem of n ODE's is characterized by n Lyapunov exponents. Mathgrapher calculates all ofthem.

The results are written in a file in the working directory called 'Results.dat'. The contents of thisfile are shown in a separate window

Page 95: Springfield Holding B.V

95Iterations

Springfield Holding B.V.

7.6.8 Lyapunov exponents - Definition and calculation

An n-dimensional map has n Lyapunov exponents. Mathgrapher calculates all of them. Themethod used is the one described in "Practical Numerical Algorithms for Chaotic Systems" byT.S. Parker and L.O. Chua (1989, Springer-Verlag New York Inc.). The calculation of the exponents is easier than in the case of ODE's. It involves linearization ofthe map at each point x(i) along the orbit, i.e. calculating the tangent map M(i), For ann-dimensional system this is a n x n matrix. The tangent map gives the amount of expansion orcontraction of neighbouring orbits near xi. After a few iterations the product M(k)M(k-1) ..M(1) islikely to grow rapidly and become ill-conditioned. So we have to apply orthonormalization atregular intervals as in the case of ODE's. This is done by QR decomposition. The Lyapunovexponents are calculated from the diagonal elements of R (see also ODE's)The simplest case is the one-dimensional map

For n-dimensional maps

Page 96: Springfield Holding B.V

96 MathGrapher v2

Springfield Holding B.V.

For area conserving maps contraction in one direction is balanced by expansion in anotherdirection, so we have

The set of Lyapunov exponents define a dimension: the Lyapunov or Kaplan-Yorke dimension

The results are written in a file in the working directory called 'Results.dat'. The contents of thisfile are shown in a separate window

7.7 Edit: Iterations / ODEs

Push the Graph properties button in the main button bar to change the graph properties in theGraph window

The 2D Graph properties panel is the same as for Functions or Data.

The 3D Graph properties panel shown below appears when you have chosen Projection in 3Din the combo box on the Analysis panel in the Prepare / Draw Graph window.

Page 97: Springfield Holding B.V

97Iterations

Springfield Holding B.V.

Click on the hotspots in the image for more information

7.8 Pixel Graph Window

It can be useful to draw pixels directly when a high resolution is required. This is done in aspecial windowApplications:

Iteration Type Ib. Drawing 2D orbits of an iterative map (Iteration Type Ib). An exampleis given below for the Henon map with a=1.4 and b=0.3 (see also the standard map).The red dots in the graph shown below give the orbital coordinates (run theDemonstrations => Iterations => Henon map from the main menu).

Iteration Type III. Calculate the stability of orbits for 2D initial conditions (as for examplein the Julia sets) or for a 2D range of parameters (as in the Mandelbrot sets). Each pixelrepresents an inital coordinate (F3,F4). The pixel is colored according to the number ofiterations it takes to escape, i.e. when the radius sqrt(F3^2 +F4^2) exceeds a givenvalue. A pixel remains black when the the orbits does not escape. In the graph shownbelow this is done for the Henon map. in a second calculation the orbit (red dots) wasadded (see Demonstrations => Iterations => Henon map).

Lindenmayer systems

Cellular automata (pixels are enlarged by factor 2x2)

Page 98: Springfield Holding B.V

98 MathGrapher v2

Springfield Holding B.V.

Click on the hotspots in the image for more information

7.9 Iterations: Examples

Algebraic series (Type I):

Series representation of e

Series representation of square wave

Fibonacci numbers and the golden mean

Logistic map (Type II)

Iteration for a=0.94

Projection in 2D

Bifurcation diagram

Power spectrum

Henon map (Type I and III)

Definition

Orbits

Page 99: Springfield Holding B.V

99Iterations

Springfield Holding B.V.

Stability

Vary initial coordinates

Lyapunov exponents (see the Demonstrations)

Standard map (Type Ib, see also the Demonstration)

Mandelbrot and Julia sets (Type III)

Definition

Vary parameters (Mandelbrot sets)

Vary initial conditions (Julia sets)

7.9.1 Algebraic series

Series representation of e

Define F1=F2 and F2=F1+1/n! with initial values 0 and 1 respectively and do an integration tosee if

=>back

Series representation of square wave

Define F1=F2 and F2=F1+sin((2n+1)*x)/(2*n-1) with initial values 0. Choose Vary one parameter in the Iteration type panel. Vary x and do 50 iterations (N=50) for200 values of x ranging from -5 to 15. This yields the following graph (this is also shown in oneof the demonstrations)

Page 100: Springfield Holding B.V

100 MathGrapher v2

Springfield Holding B.V.

The function was calculated for 200 x-values (N=50).

Fibonacci numbers and the Golden Mean

Fibonacci numbers are the integers given by the prescription

One of the interesting properties of these numbers is that

=>back

7.9.2 Logistic map

Time Series Below the result is shown of 30 iterations of the logistic map (File=>open=>Function=>=>Maps=>logistic.fct) for a=0.94After defining and selecting F1 and F2 in the Iterations panel, the Prepare / Draw window isopened, the initial values of F1 and F2 are set in the Start / End conditions panel. ChooseIteration type Ia. Push the Iterate button. Finally select Time Series in the combo box on theAnalysis panel, select F1 and F2 and push Draw to produce the Graph below.

The red line is the result of setting the initial values F1=0.0 and F2=0.2. The black line starts at F1=0.0 and F2=0.202. Note how a small variation in initial values causesa sudden change after 14 iterations.

Page 101: Springfield Holding B.V

101Iterations

Springfield Holding B.V.

=>back

Projection in 2D applied to the logistic map

Choose a pair of F's from the Functions that are iterated and push Draw to make a graph wherethe X-axis represents the first and the Y-axis the second Function.

The example below is a graph of F1 and F2 for a series of 1024 iterations of the logistic map.The first 100 iterations are omitted. Note that a 4-cycle has developed for a=0.87

Same as above for a=0.89 showing an 8-cycle and a=0.96 (the gap in the bifurcation diagram)where we have a 3-cycle. The behaviour is chaotic above 0.96.

Page 102: Springfield Holding B.V

102 MathGrapher v2

Springfield Holding B.V.

=>back

Bifurcation diagram of the Logistic map (Iteration Type II)

Below the result is shown of iterates of the logistic map for a ranging from a=0.72 to a=0.98 (seealso Demonstrations=>Iterations=>Logistic map). Note the period doublings at a=3/4 and 0.862and higher. As a increases the behaviour becomes increasingly chaotic especially above thegap at a=0.96 where a 3-cycle occurs (see the power spectrum).

Page 103: Springfield Holding B.V

103Iterations

Springfield Holding B.V.

=> back

Power Spectrum The normalized power spectrum is calculated from the results of the Iteration (Type Ia). Notethat only the first 2**k points are used in the calculation of the Power spectrum, where k is thelargest integer for which 2**k is smaller than, or equal to N.

The result below is for 256 iterations of the logistic map starting with initial values F1=0.0,F2=0.2 and a = 0.99. At this high value of the constant a the behaviour is quite chaotic. This canalso be seen in the bifurcation diagram. Note that this diagram shows a gap at a=0.96 where wefind a 3-cycle. Indeed the power spectrum graph gives a nice peak at J=171 which means thatthe 256 iterations show about 85 ( =(171-1)/2 ) cycles.

Page 104: Springfield Holding B.V

104 MathGrapher v2

Springfield Holding B.V.

=>back

7.9.3 Henon map

Henon map - Definition

The Henon map is the 2D extension of the logistic map. It is defined as

The map is defined by the following equations:

F1=F3F2=F4F3=1-a*F1^2+F2F4=b*F1

The Fifth function F5 is used in the stability condition (see Stability)

Henon map - Orbits

We will draw the orbit in the Pixel graph window (Type Ib)

First select functions F1 to F4 in the Function Panel. Next open the Prepare / Draw Iterationswindow => open the Iteration type tab. We choose to Draw results (2D) directly in the PixelGraph window. Next set the number of iterations to 3000 and the initial coordinates F3=0.7 andF4=0.3. Push the button that opens the Pixel Graph window, set the number of pixels at300x300 pixels, set the X coordinate (F3) from -2 to 2, the Y-coordinate (F3) from -2 to 2 andpush the Iterate and Draw button in the Prepare / Draw iterations window. This will yield thefollowing picture (apart from the square). The square results from selecting a new range. Thecoordinates of this new range are given below the graph.

Page 105: Springfield Holding B.V

105Iterations

Springfield Holding B.V.

The middle picture below was obtained for 30.000 iterations and the picture to the right for 3runs of 1000.000 iterations (3 different initial positions on the attractor)

The picture below shows orbits of the Henon map for a=0.2 , b=1.1 in the region F3= -4 to 4 andF4 = -6 to 6. You may use your mouse to select new initial values from the graph after pushingthe Select Coordinate button above the Graph. It is also interesting to compare this graph with agraph that shows the stable orbits

Henon map - Stability (Iteration type III)

The picture below shows the region of stability, i.e. the region from which orbits do not escape. Itwas produced as follows: Select the first 5 Functions in the Function panel. The fifth function(F5) gives the distance to the origin. It is used in the escape criterium. Go to Iteration type in thePrepare / Draw graph window and choose II: Vary two parameters or initial values. Choose Varyinitial values. Set the maximal number of iterations to 50 and the Escape value of F5 to 10.Open the Pixel grpah, set the minimum and maximum coordinates to -2 and 2 respectively, andpush the Iterate and Draw button. The red orbit was added in a next step by going to Ib: tandard type Iteration, choosing Drawresults directly ... and push Iterate and Draw.

Page 106: Springfield Holding B.V

106 MathGrapher v2

Springfield Holding B.V.

The picture shows the stable orbits of the Henon map for a=0.2 , b=1.1 in the region F3= -4 to 4and F4 = -6 to 6. The maximum number of iterations was set to 100 and the escape: F5>10(black region). The colors give the number of iterations it took to escape. The color range can beset in the lower part of the graph window. Here they go from red to blue (rainbow mode).

Page 107: Springfield Holding B.V

107Iterations

Springfield Holding B.V.

7.9.4 Standard map

Do the Demonstration (Demonstrations => Iterations => Standard map) to produce the followinggraph in the Pixel graph window.

7.9.5 Mandelbrot and Julia sets

Mandelbrot map - Definition

The Mandelbrot set is the set of points in the complex c-plane that do not go to infinity wheniterating z(n+1) = z(n)^2 + c starting with z = 0. Defining z=x+iy and c=a+ib this yields the 2Dmap:

In Mathgrapher this looks like:

F1=F3F2=F4F3=F1^2-F2^2 +aF4=2*F1*F2 +bF5=sqrt(F1^2+F2^2)

The Fifth function F5 (distance to the center) is used in the stability condition. You may importthis map by going to the main menu: File => Open=> Function. You find Mandelbrot .fct in theMaps subdirectory.

Mandelbrot sets - Stable orbits

The Mandelbrot sets are produced when stable orbits are searched in the parameter (a,b)plane. This is done for the initial values F3=F4=0 (F5 is used in the stability condition)

Choose the Iterations module and Push the Prepare / Draw button to open the PrepareIterations window. Push the Iteration type tab and choose III: Vary two parameters or initialvalues. Here you have to set the maximum number of iterations and the maximum value of theescape parameter (F5 in this case). Note that all 5 functions (F1, F2, ..F5) in the Functionspanel have to be selected. Choose Vary parameters (X=a, Y=b) and Open the Pixel Graphwindow. Set the range of a and b in this window and push the Iterate and Draw button. In the

Page 108: Springfield Holding B.V

108 MathGrapher v2

Springfield Holding B.V.

picture below the maximum number of iterations was 50 with F5< 4 (Black region).

The first picture below is an enlargement of the region indicated above. You may zoom in bypushing the Select new range button and click on the graph (left button) to give the new lowerleft and upper right corners. In the pictures below the max. number of iterations was 75, 100,200, 200 and 600 resp. (ordered clockwise). The color may be adjusted in the panel below thegraph. Not how the final structure resembles the original structure.

Paragraph

Hypertextbool

Julia sets - Definition

The Julia sets are produced when stable orbits are searched in the plane of initial conditions(F3-F4 plane) while keeping a and b fixed. You can type the a and b values in the Pixel window below the graph. Confirm the new choice ofa and b by pushing the Reset constant values button below the value entries. Alternatively youuse your mouse (left button) to select a and b in the Mandelbrot set (after pushing the SelectCoordinate button) .

Page 109: Springfield Holding B.V

109Iterations

Springfield Holding B.V.

The pictures below were produced as described above. Escape (black region) for F5>2;maximum number of iterations 100

Page 110: Springfield Holding B.V

MathGrapher

Part

VIII

Page 111: Springfield Holding B.V

111Ordinary Differential Equations

Springfield Holding B.V.

8 Ordinary Differential Equations

8.1 ODEs: Definition

Many dynamical systems in physics, astronomy, chemistry, physiology, meteorology, economics,population dynamics can be described by Ordinary Differential Equations (ODE's).

An ordinary differential equation is a differential equation that contains only one variable, forinstance Time. Such an equation may contain derivatives and derivatives of derivatives. Thehighest derivative determines the order of the ODE. For example, Newton's law for theacceleration of a particle in a gravitational field (in one dimension) is described by a secondorder ODE (x=position, t=time):

Any nth order ordinary differential equation can be reduced to a set of n first order differentialequations. Newton's law for the acceleration of a body in a central force field (in one dimension)given above, is equivalent to the following system of first order equations

So first you have to write your differential equation in an equivalent set of first order equations asin the example given above. Press the ODEs button in the main button bar. You may define aset of up to 20 coupled first-order equations. In the example given above you would defineF1=x(t) and F2=v(t)

and define the ODE's as

dF1/dt = F2

dF2/dt=c/F1^2

MathGrapher uses an accurate Adams-Bashforth variable order, variable steppredictor-corrector algorithm to integrate systems of up to 20 coupled ODE's.

After defining the ODE's we heave to set the initial values. Press the Prepare / Draw Graph

Page 112: Springfield Holding B.V

112 MathGrapher v2

Springfield Holding B.V.

button to open the Graphical Window and the Prepare / Draw window.

8.2 ODEs: Start / End Conditions

After defining the set of differential equations in the ODEs panel you must give the initial valuesfor the Functions. Push the Prepare / Draw Graph button to open the Graphics screen and thewindow shown below. Adjust the initial values if necessary. The End values are given when the integration is finished.

8.3 ODEs: T - Range

Set the initial and final T-values.A variable order, variable time step Adams-Bashforth algorithm is used for the integration, sothe size and the number of time steps are determined by the code. Output may be generated ateach time step taken by the code (lower check box), or at a given number of equidistantintermediate T-values.

When the integration is done you may Continue the integration to a new T using the final

Page 113: Springfield Holding B.V

113Ordinary Differential Equations

Springfield Holding B.V.

F-values as initial values for the new integration. Alternatively you may Restart the integrationusing the initial values set in the Start/End Conditions.

8.4 ODEs: Analysis

Finally -- after setting the initial values, the T Range and perhaps the Error tolerance -- start theIntegration by pushing the Integrate button.When the integration is done choose from the combo box the type of Graph you want to drawand push the Draw button.

8.4.1 Time Series

Below the result is shown of an integration of the Lorenz oscillator (see Examples). All 3Functions are selected in the combo box on the right. Different colors are chosen for theFunctions using the Graph properties button in the main button bar.

Page 114: Springfield Holding B.V

114 MathGrapher v2

Springfield Holding B.V.

8.4.2 Power spectrum

The normalized power spectrum is calculated from the results of the Integration. Note that onlythe first 2**k points are used in the calculation of the Power spectrum, where k is the largestinteger for which 2**k is smaller than, or equal to N.

The example below is again for an Integration of the Lorenz oscillator showing chaoticbehaviour in spite of the nice regular orbit (see 2D and 3D projection).

8.4.3 Projection in 2D

Choose a pair of F's from the Functions that are integrated and push Draw to make a graphwhere the X-axis represents the first and the Y-axis the second Function.Below the results of an integration of the Lorenz oscillator is given.

Page 115: Springfield Holding B.V

115Ordinary Differential Equations

Springfield Holding B.V.

Erase the Graph and Push the Show Evolution button in the Integration and Analysis panel ofthe Prepare / Draw window to see the orbit in slow motion

In case more than 4 equations are integrated multiple orbits may be drawn by selecting morethan one pair of Functions in the combo box of the Analysis panel.

8.4.4 Projection in 3D

Choose three F's from the Functions that are integrated and push Draw to make a graph wherethe X-axis represents the first, the Y-axis the second Function and the Z-axis the thirdFunction. Push the Graph propertiest button in the main button bar to edit the GraphYou may draw the orbit in 3D as well as the projections of the orbit on the three planes.

Below the results of an integration of the Lorenz oscillator are shown. The black curve is theorbit in 3D, the red curve is the projection on the XY-plane (2D).

Erase the Graph and Push the Show Evolution button in the Integration and Analysis panel ofthe Prepare / Draw window to see the orbit how the orbit evolves in time.

Page 116: Springfield Holding B.V

116 MathGrapher v2

Springfield Holding B.V.

8.4.5 Surface of Section

The Henon-Heiles equations with initial values F1=0.2, F2=0.0, F3=0.4, F4=0.0 (E=0.1) areintegrated from T=1 to 250 giving output at 2000 intermediate points.This yields the following surface of section at F1=0.0

The graph below gives the section points for another orbit with E=0.1 starting at F1=0.0,F2=0.0, F3=0.4, F5=0.2 yielding the two circular patterns. The other points are for a slightlyhigher energy (E=1/7) starting at F3=0.5 instead of 0.4. It illustrates how the orbit is no longerconfined to a torus, but spreads out over a larger volume in phase space as the energyincreases.

Page 117: Springfield Holding B.V

117Ordinary Differential Equations

Springfield Holding B.V.

=>back

8.4.6 Phase portrait

It is very easy to generate a phase portrait like the one shown below. Just define thedifferential equations. In this case these are the equations for a predator-prey model:

Push the Prepare / Draw graph button to open the graph window and the prepare window, slectthe Analysis tab, choose phase portrait and push the Draw button. You can fix the X and Yranges just below the graph.

The other analytical tools allow you to draw extra orbits (orbit in 2D), find equilibrium points and calculate their stability properties (eigenvalues).

Page 118: Springfield Holding B.V

118 MathGrapher v2

Springfield Holding B.V.

8.4.7 Linearization

Suppose we have a system of 2 coupled ODE's

The eigenvalues of this matrix determine the type of equilibrium point and its stability properties.They are the roots of the equation

8.4.8 Equilibrium points (Fixed points)

A set of ODE's has an equilibrium point when dF/dt=0 for all F's.There are severaltypes of equilibrium points depending on the behaviour of the orbits in theirneighbourhood: stable and unstable nodes, saddle points, stable and unstable spiralpoints. The behaviour of the orbits near an equilibrium point can be found by studyingthe linearized equations. Suppose we have a system of 2 coupled ODE's:

dx/dt=x(4-x-y)dy/dt=y(x-2)

The eigenvalues of the stability matrix J (see linearized equations) determine the type ofequilibrium point and its stability properties. They are the roots of the equation

where I is the identity matrix. In the 2-dimensional case discussed here this generally yields 2solutions. Stable point have negative eigenvalues, unstable points have positive eigenvalues,saddle points have one negative and one positive eigenvalue and spiral points have complexeigenvalues. They may be stable or unstable depending on their position in the complex plain.

Page 119: Springfield Holding B.V

119Ordinary Differential Equations

Springfield Holding B.V.

The fixed points are (0.0), (2,2) and (4,0). To find the eigenvalues we have to solve theequation:

For (0,0) these are -2 and 4 => hyperbolic point, for (2,2) we find -1+i*sqrt(3) and -1-i*sqrt(3) i.e.stable spiral point, and for (4,0) -4 and 2, i.e. hyperbolic point. Check these results withMathgrapher. To find an equilibrium point (and its eigenvalues) you have to give initial valuessomewhere in its neighborhood. The results are written in a file in the working directory called 'Results.dat'. The contents of this file are shown in a separate window

8.4.9 Lyapunov exponents

Lyapunov exponents are very important in the description of chaotical dynamicalsystems. They describe the exponential rate at which neighbouring orbits diverge. Theyare used to determine the behaviour of quasi-periodic and chaotic behavious as well asthe stability of equilibrium points and periodic solutions. For orbits near equilibriumpoints they are equal to the real parts of the eigenvalues at these points.

The number of Lyapunov exponents is equal to the dimension of the system of ODE's, so asystem of n ODE's is characterized by n Lyapunov exponents. Mathgrapher calculates all ofthem.

The results are written in a file in the working directory called 'Results.dat'. The contents of thisfile are shown in a separate window

Page 120: Springfield Holding B.V

120 MathGrapher v2

Springfield Holding B.V.

8.4.10 Lyapunov exponents - definition

Lyapunov exponents give the exponential separation of neighbouring orbits.Suppose we have a system of n coupled ODE's given by

So, calculation of the Lyapunov exponents involves linearization of the differential equationsand integration of all the n^2 components of the the tangent map (or perturbation vectors) alongwith the n ODE's. The displacement vectors grow rapidly and should be orthonormalized atregular intervals to prevent overflow.For Hamiltonian systems the n-dimensional volume spanned by the displacement will bedeformed, but not changed due to Liouville's theorem. Since the Lyapunov exponents give theexponential rates of change of the vectors spanning this volume we have in that case:

The set of Lyapunov exponents define a dimension: the Lyapunov or Kaplan-Yorke dimension

8.4.11 Lyapunov exponents - calculation

An n-dimensional system of ODE's has n Lyapunov exponents. Mathgrapher calculates all ofthem.

The method used is the one described in "Practical Numerical Algorithms for Chaotic Systems"by T.S. Parker and L.O. Chua (1989, Springer-Verlag New York Inc.). A set of n independentperturbation (or displacement) vectors is integrated simultaneously with the orbital coordinates.The evolution of these perturbation vectors is described by the Variational equation: i.e. the linearization of the vector field along the trajectory. This is a set of n^2 linear equationsdescribing the evolution of each of the n components of the n perturbation vectors. The totalnumber of equations that needs to be integrated in order to obtain all the Lyapunov exponentsis therefore n+n^2.

Page 121: Springfield Holding B.V

121Ordinary Differential Equations

Springfield Holding B.V.

In a chaotic system the perturbation vectors increase exponentially. To prevent overflow, thesevectors are orthonormalized at regular time intervals. This is done by QR decomposition of thetangent matrix. The Lyapunov exponents are found from the diagonal elements of the Rmatrices formed at each orthormalization step:

where Ri is the the R-matrix at the i-th orthonormalization step.

8.5 Edit: Iterations / ODEs

Push the Graph properties button in the main button bar to change the graph properties

The 2D Graph properties panel is the same as for Functions or Data.

The 3D Graph properties panel shown below appears when you have chosen Projection in 3D inthe combo box on the Analysis panel in the Prepare / Draw Graph window.

Click on the hotspots in the image for more information

8.6 ODEs: Examples

For the following examples

Power spectrum

Projection in 2D

Projection in 3D

Henon-Heiles Hamiltonian

Page 122: Springfield Holding B.V

122 MathGrapher v2

Springfield Holding B.V.

where the (non-linear) potential is given by

The potential supports bounded motion for E<1/6 (see a 3D graph and Contour plot ofthis potential produced by MathGrapher)

is given by

The potential supports bounded motion for E<1/6 which is the triangular central region.

The Hamiltonian yields the following equations of motion

import these equations by going to File=> Open=>Function=>ODEs and selectingHenon-Heiles.fct.It is interesting to study the braking up of smooth regular orbits into chaotic motion whenthe energy increases. This can be studied using the well known surfaces of section (orPoincaré section) See

Other examples

Several other examples can be imported from the ODEs folder:

Predator-Prey equation (Voltera)

Rossler Equation

van der Pohl oscillator

Duffing oscillator

Page 123: Springfield Holding B.V

123Ordinary Differential Equations

Springfield Holding B.V.

8.6.1 Lorenz attractor

Lorenz attractor:

The Lorenz equations for X=X(t), Y=Y(t) and Z=Z(t) are:

where c= Prandtl number, a = (normalised) Rayleigh number and b is a geometricalfactor. You may import the Lorenz attractor by going to File=> Open=>Function=>ODEand selecting Lorenz.fct.

Integrate the equations from 0 to 10 and go to the Analysis panel

Time series

Power spectrumThe normalized power spectrum is calculated from the results of the Integration. Note thatonly the first 2**k points are used in the calculation of the Power spectrum, where k is thelargest integer for which 2**k is smaller than, or equal to N.

The example below is again for an Integration of the Lorenz oscillator showing chaoticbehaviour in spite of the nice regular orbit (see 2D and 3D projection).

Page 124: Springfield Holding B.V

124 MathGrapher v2

Springfield Holding B.V.

Projection in 2D

Choose a pair of F's from the Functions that are integrated and push Draw to make a graphwhere the X-axis represents the first and the Y-axis the second Function.Below the results of an integration of the Lorenz oscillator is given.

Erase the Graph and Push the Show Evolution button in the Integration and Analysis panel ofthe Prepare / Draw window to see the orbit in slow motion

In case more than 4 equations are integrated multiple orbits may be drawn by selecting morethan one pair of Functions in the combo box of the Analysis panel.

Projection in 3D

Choose three F's from the Functions that are integrated and push Draw to make a graphwhere the X-axis represents the first, the Y-axis the second Function and the Z-axis the thirdFunction. Push the Graph propertiest button in the main button bar to edit the Graph

Page 125: Springfield Holding B.V

125Ordinary Differential Equations

Springfield Holding B.V.

You may draw the orbit in 3D as well as the projections of the orbit on the three planes.

Below the results of an integration of the Lorenz oscillator are shown. The black curve is theorbit in 3D, the red curve is the projection on the XY-plane (2D).

Erase the Graph and Push the Show Evolution button in the Integration and Analysis panel ofthe Prepare / Draw window to see the orbit how the orbit evolves in time.

8.6.2 Henon-Heiles potential

Henon-Heiles Hamiltonian

where the (non-linear) potential is given by

The potential supports bounded motion for E<1/6 (see a 3D graph and Contour plot of thispotential produced by MathGrapher)

is given by

The potential supports bounded motion for E<1/6 which is the triangular central region.

Page 126: Springfield Holding B.V

126 MathGrapher v2

Springfield Holding B.V.

The Hamiltonian yields the following equations of motion

import these equations by going to File=> Open=>Function=>ODEs and selectingHenon-Heiles.fct.It is interesting to study the braking up of smooth regular orbits into chaotic motion when theenergy increases. This can be studied using a

Surface of section (or Poincaré section)

The Henon-Heiles equations with initial values F1=0.2, F2=0.0, F3=0.4, F4=0.0 (E=0.1) areintegrated from T=1 to 250 giving output at 2000 intermediate points.This yields the following surface of section at F1=0.0

The graph below gives the section points for another orbit with E=0.1 starting at F1=0.0,F2=0.0, F3=0.4, F5=0.2 yielding the two circular patterns. The other points are for a slightlyhigher energy (E=1/7) starting at F3=0.5 instead of 0.4. It illustrates how the orbit is no longerconfined to a torus, but spreads out over a larger volume in phase space as the energyincreases.

Page 127: Springfield Holding B.V

127Ordinary Differential Equations

Springfield Holding B.V.

8.6.3 Rossler equation

is given by

We have adopted a=0.2, b=0.2 and c=4.2 with initial values F1=0.8, F2=0.5 and F3=0.25. Theintegration was done from T=0 to 1024 and output was geb=nerated at 1024 intermediatepoints. The graph shows F1 versus F2.

The same parameters were used to calculate the power spectrum of F3 below.

8.6.4 Duffing oscillator

is given by

which we can write as a system of coupled ODEs using

Page 128: Springfield Holding B.V

128 MathGrapher v2

Springfield Holding B.V.

to obtain

For small d simple limit cycle behaviour is observed. As d increases the cycles bifurcate intodouble period cycles and the motion becomes increasingly chaotic. The 2D (F1-F2) graphbelow is the result of an integration from T=0 to 50 using a=0.25, d=200, g=1.5. Initial valuesare F1=0.8, F2=0,5 and F3=0.25. Output is generated at 3000 intermediate time steps.

Below the power spectrum of F2. The same parameters were used, but in this case T runsfrom 0 to 250 and output is generated at 256 equal steps.

Page 129: Springfield Holding B.V

MathGrapher

Part

IX

Page 130: Springfield Holding B.V

130 MathGrapher v2

Springfield Holding B.V.

9 Matrices

9.1 Matrices: screenview

In this window you can do Matrix operations on matrices A and B. The result is given in matirx Xafter pressing the =>Go button. You may also calculate eigenvalues and eigenvectors of matrixA. These are given in the Results window.

The matrices may contain no more than 400 elements.

Click on the image for more information

9.2 Matrices : operations

Mathgrapher handles real matrices only. The results (eigenvalues, eigenvectors) may becomplex.

Matrix addition

Page 131: Springfield Holding B.V

131Matrices

Springfield Holding B.V.

X = A + B

Matrix multiplication

X = A B

Transpose of a matrix

X = Transp (A)

Solve AX=B (Least squares) solution of linear system of equations.

Find solution for A X = B

Eigenvalues and Eigenvectors of A.

The (complex) eigenvalues and eigenvectors of a real matrix are calculated and the resultsare written in the file Results.out and shown in the Results window.

A x = x

Inverse of A

X = Inv (A) implies X A = 1

Determinant of A

The determinant of the matrix is calculated using LU factorization. The results are written inthe file Results.out and shown in the Results window.

Det (A)

9.3 Matrices: Solve A.X=B

The solution is computed to the real linear least squares problem minimize ||AX-B|| where A is am x n matrix which may be rank-deficient.

Example:

Suppose you have a number of measurements B(ti), where you expect that B is the result ofa linear combination of functions (or data sets):

Page 132: Springfield Holding B.V

132 MathGrapher v2

Springfield Holding B.V.

A and B are known and we want to find C (=X) for which ||AC-B|| is minimized.Let's assume that c1=1, c2=2, c3=3, c4=4 and calculate B for t=0, 0.5, 1.0, 1.5, 2.0, 2.5, and3.0.

When the Go button is pushed the following solution for C (or X) is found. The results aregiven in the matrix X. The results are also written in the Results.out file and shown in theresults window.

Note that A may also contain columns that represent data sets instead of functions. The leastsquares algorithm used here is also used in the Curve fit module (linear least squares fit to acombination of functions and Data sets.

Page 133: Springfield Holding B.V

MathGrapher

Part

X

Page 134: Springfield Holding B.V

134 MathGrapher v2

Springfield Holding B.V.

10 Lindenmayer systems

10.1 L-systems

Lindenmayer systems (L-systems, turtle graphics) are used to generate

--Fractal curves (Koch, Sierpinski, Levy, Dragon)--Space filling curves (Hilbert, Peano-Gosper)--Growth patterns in plants--etc

It is an iterative string rewriting method. Starting from the Axioma a new string is formed byreplacing the string symbols according to a few given Rules.The final string containsínstructions telling the turtle where to go, or how to draw the path. We have the following instructions

F go one step forward and draw a linef go one step forward without drawing a line+/- turn right/left by the (fixed) angle[ store the present state on a stack] go to the last state on the stack: go one step up in the color list (9 colors); go one step down in the color list.

The list on the left contains a number of well known examples. Choose one of them and pushthe Draw button to draw it in the graphical window. You may construct your own examples andadd them to the list.

Below you find a number of useful references to internet sites on the subject.

Mathforum Some history Larry Ridldle Algorithmic botany

Wikipedia Mathworld Fractint (manyexamples)

Page 135: Springfield Holding B.V

135Lindenmayer systems

Springfield Holding B.V.

10.2 L-systems: Screenview

Click on the hotspots in the image for more information

10.3 L-systems: Examples

Lindenmayer systems (L-systems, turtle graphics) are used to generate

Fractal curves (Koch, Sierpinski, Levy, Dragon)

Koch curve for order 1 to 4. The line length is adjusted (27, 9, 3,1; see theDemonstration)

Sierpinsky gasket

Page 136: Springfield Holding B.V

136 MathGrapher v2

Springfield Holding B.V.

Space filling curves (Hilbert, Peano-Gosper)

This type of curves have the remarkable property that they can fill a 2 (or more)dimensional space.

Example: Hilbert's curvesX => -YF+XFX+FY- and Y=> +XF-YFY-FX+ for increasing order (1,2,3,4,5 and 6) anddecreasing the line length (32,16,8,4,2,1).

Peano-Gosper curve

Growth patterns in plantsTrees nr 2 and 4 from the list

Page 137: Springfield Holding B.V

137Lindenmayer systems

Springfield Holding B.V.

--etc

The list contains a number of well known examples. Choose one of them and push the Drawbutton to draw it in the graphical window. You may construct your own examples and add themto the list. Below you find a number of useful references to internet sites on the subject.

Page 138: Springfield Holding B.V

MathGrapher

Part

XI

Page 139: Springfield Holding B.V

139Cellular automata

Springfield Holding B.V.

11 Cellular automata

11.1 Cellular Automata: 1D rule

A Cellular automaton is a collection of colored cells on a grid. At each iteration (generation) thecells may change state (color) depending on the state of the other neighboring cells. We will look at automata in which the cells may have 2 states only (dead or alive).Such simple automata may produce many kinds of interesting behaviour from dull extinction tolife-like growth patterns and chaos.

1D Cellular automataThe first one is a simple one-dimensional Automaton from Stephen Wolfram's "A new kind ofScience". The initial state is either a single black cell on the middle of the first row or a randomlychoice of black and white cells on the first row. At each iteration the pixels status of the next row is determined by the status of the 3 nearestneighbors in the row above it according to the rule number:Rule number 30 written in binary is 0000011110. There are eight possible combinations for thecolors of the 3 nearest neihgbors:

111 110 101 100 011 010 001 000. For each combination the color of the cell is given by

0 0 0 0 1 1 1 0 = 30The total number of combinations is 256 (2^8)

Page 140: Springfield Holding B.V

140 MathGrapher v2

Springfield Holding B.V.

11.2 Cellular Automata: 2D rule

A Cellular automaton is a collection of colored cells on a grid. At each iteration (generation) thecells may change state (color) depending on the state of the other neighboring cells. We will look at automata in which the cells may have 2 states only (dead or alive).Such simple automata may produce many kinds of interesting behaviour from dull extinction tolife-like growth patterns and chaos.

2D Cellular AutomataThe second type of automata is a simple two-dimensional one also from Stephen Wolfram'sbook "A new kind of Science". The initial state is a single black cell on the middle of a grid of300x300 cells. Now the color is determined by the number of black neighbors in the vertical andhorizontal direction and by its present color as follow. For example for the number 942, which is1110101110 in binary notation, we have

nr of neighbors: 4 3 2 1 0color 11 10 10 11 10

meaning that if a cell has 3 neighbors its color will become 10, i.e. black (1) if it was black andwhite (0) if it was white. The total number of recipes will be 1024.

Example

Page 141: Springfield Holding B.V

141Cellular automata

Springfield Holding B.V.

11.3 Cellular Automata: Life

A Cellular automaton is a collection of colored cells on a grid. At each iteration (generation) thecells may change state (color) depending on the state of the other neighboring cells. We will look at automata in which the cells may have 2 states only (dead or alive).Such simple automata may produce many kinds of interesting behaviour from dull extinction tolife-like growth patterns and chaos.

In the Cellular automata module of Mathgrapher you may try 3 types of automata. The first 2(1D and 2D) are taken from the book by S Wolfram entitled "A new kind of Science".

The Game of LifeThe third one is a more general type of automata, sometimes called Life. Dead (uncolored)cells may come to life and living cells may survive or die depending on the status of theirneighboring cells.The initial state may be random, or some predefined configuration. Such a configuration maybe drawn and stored under some name (Glider, Gosper_gun, block, puffer, etc. see the list).You may start with one of these stored configurations by choosing it from the list. When youstart the Game of Life the system evolves according to the Rule given by 2 numbers. Rule 23 /3 (Conway's Game of Life) means that (alive) cells with 2 or 3 neighbors will survive and deadcells with 3 neighbors become alive.

Click on the hotspots in the image for more information

Page 142: Springfield Holding B.V

142 MathGrapher v2

Springfield Holding B.V.

Example: Gosper gun

More information:

Wikipedia

Variations on the game of life

Life lexicon

Page 143: Springfield Holding B.V

MathGrapher

Part

XII

Page 144: Springfield Holding B.V

144 MathGrapher v2

Springfield Holding B.V.

12 Add drawing objects

12.1 Add: Draw Lines, Symbols, Text

The Add button in the main button bar opens the Add panel. Here you may choose graphicalelements to draw in your Graph, such as lines, symbols and text.

Choose the Drawing element, go to the position in your Graph where you want to draw and clickyour left mouse button.

Page 145: Springfield Holding B.V

MathGrapher

Part

XIII

Page 146: Springfield Holding B.V

146 MathGrapher v2

Springfield Holding B.V.

13 Import / Export

13.1 Import / Export: Functions

Mathematical functions defined in MathGrapher can be stored on disk and retrieved by going tothe pull down menu. Choose File => Save (or Open) => Function to open a file browser. TheFunction files have default extension .fct

Some predefined example files are placed in the MathGrapher directory during installation.

Example Functions:

2D / 3D Functions in Functions/Examples-2D.fct and Examples-3D.fct

Iterations in subdirectory Functions/Map

Ordinary Differential Equations in subdirectory Functions/ODEs

13.2 Import / Export: Data

Data can be imported into the grid in 4 ways:

Direct editing/writing in the grid cells

Copy and paste from a tab separated data grid such as Microsoft Excel, or from atab-separated text file.

Using the Get => Data under the File menu to save a file that was saved byMathGrapher (default extension .dat).

Importing data points by clicking on a graph (see example) after pushing the Read Datafrom Graph button on lower right of the Data panel.

The last method can be used to import data from an imported graph

Data can be exported by

copying and pasting into another Windows application

Saving the Data in a . dat file by choosing File => Save => Data in the menu.

sending the grid data to the printer. Choose File =>Printer => Data

13.3 Import: Images

Choose File => Open => Image in the menu to import an image into the graphicswindow.

Press OK to open a browser windowChoose the appropriate type: Bitmap or JPEG.

Page 147: Springfield Holding B.V

147Import / Export

Springfield Holding B.V.

Note that Data can be read from an (imported) graph and placed in one of the the Data grids.

13.4 Export: Save Graphs

The contents of the 3 graphical windows: the Graph window, the 3D Viewer window or the PixelGraph window can be exported or stored in various ways. You may send the contents of the graphical window:

directly to your printer by going to File => Print => Graph in the menu. The size of theprinted Graph can be varied.

to a File. Go to File => Save => Graph in the menu

to a screen dump. Push the Print Screen button on your keyboard. The screen dumpcan be loaded into another application such as Paint Shop Pro and subsequently editedand converted to other file formats. You may also store the Graph on the WindowsClipboard for further processing in another application, by pushin the Copy button on theGraphical window

You can save the Graph in one of the following formats:

Windows Bitmap (.bmp)Joint Photographic Experts Group (.jpg)Encapsulated Postscript (.eps)Windows Metafile (.wmf)Portable Network Graphics (.png)

The EPS file can be viewed with postscript viewers such as GSview (and AladdinGhostscript), which is freely available at http://www.cs.wisc.edu/~ghost/. GSview can alsoconvert .eps files to other formats: .bmp, .jpg etc.

WMF (Windows MetaFiles) can be imported directly into Microsoft Applications such asWord and Excel. Resizing can be done there.

13.5 Export: Results

The result from mathematical operations such as:

calculation of zeroes, extrema curve fitting procedures calculation of eigenvalues/vectorscalculation of Lyapunov exponents

are written in a file 'Results.out' and presented in a separate Results window.Results from Iterations and from Integration of ODE's can be sent to Data Grid 3. From therethey can be exported (see export of Data).

Page 148: Springfield Holding B.V

MathGrapher v2148

Springfield Holding B.V.

Index

- A -About MathGrapher 9

- C -Calculus (2D): Zeroes 44

Calculus (2D):Differentiate 44

Calculus (2D):Extrema 44

Calculus (2D):Integrate 44

Cellular Automata: 1D rule 139

Cellular Automata: 2D rule 140

Cellular Automata: Life 141

Chi-square test 66

Constants 21

Contour map 50

Contour Plot 55

Conway 141

Copyright Notice 11

Cross-section 50, 56

Curve Fitting 77, 79

Curve Fitting: Cubic Splines 77, 79

Curve Fitting: Levenberg-Marquardt 77, 78, 79

Curve Fitting: Linear combination of Functions andData sets 79

Curve Fitting: Linearization of Data 77, 79

Curve Fitting: Polynomials 77, 79

Curve Fitting: Predefined functions 79

Curve Fitting: Straight Line 77, 79

Curve Fitting: Trigonometric Polynomials 77, 79

- D -Damped Sine wave 49

Data: Drawing a Graph 65

Data: panel 64

Data: Statistics 65, 66

Demonstrations 16

Distribution function 66

- E -Edit: 3D Graph 59, 72

Edit: Axes of 2D Graph 46, 71

Edit: Iterations / ODEs 96, 121

Equilibrium points 118

Examples 17

Examples: Curve Fitting - Linear combination ofFunctions and Data 83

Examples: Curve fitting - Straight Line 80

Examples: Curve Fitting Levenberg-Marquardt 81

Examples: Damped Sine wave 49

Examples: Data Graphs (2D) 73

Examples: Read Data from Imported Graph Image 75

Examples: Shaded surface 56

Export: Results 147

Export: Save Graphs 147

- F -Fixed points 93, 118

Fractal curves 135

Function: Calculus (2D) 44

Function: Calculus (3D) 50

Function: X-Y coordinates 43

Function: Definition 20

Function: Definition - Constants 21

Function: Definition - Operators / (sub)Functions 22

Function: Definition - Variables 22

Function: Drawing a 3D Graph 50

Function: Parameter Function 47

Function: Polar Coordinates 48

Function: Variables 42, 49

- G -Game of Life 141

Graph Window 45, 58, 68

Growth patterns 135

- H -Henon map 104

Henon-Heiles 116

Page 149: Springfield Holding B.V

Index 149

Springfield Holding B.V.

Hilbert curve 135

Histogram 66

- I -Import / Export: Data 146

Import / Export: Functions 61, 144, 146

Import: Data 64

Import: Images 146

Introduction 13

Iterations: Analysis 89

Iterations: Analysis - (Time) series 91, 100

Iterations: Analysis - Bifurcation Diagram 91, 100

Iterations: Analysis - Fixed points 93

Iterations: Analysis - Lyapunov exponents 94, 95

Iterations: Analysis - Power spectrum 91, 100

Iterations: Analysis - Projections in 2D 91, 100

Iterations: Analysis - Time series 90

Iterations: Definition 85

Iterations: Examples 98

Iterations: Examples - Algebraic series 99

Iterations: Examples - Fibonacci numbers 99

Iterations: Examples - Henon map - Definition 104

Iterations: Examples - Henon map - Orbits 104

Iterations: Examples - Henon map - Stability 104

Iterations: Examples - Mandelbrot map - Definition 107

Iterations: Examples - series representation of e 99

Iterations: Examples - series representation squarewave 99

Iterations: Examples - Standard map 107

Iterations: Mandelbrot and Julia type 89

Iterations: Standard Iteration 86

Iterations: Start / End Conditions 86

Iterations: Vary one parameter 87

- J -Julia set 107

- K -Koch curve 135

Kolmogorov-Smirnov test 66

Kurtosis 68

- L -Least squares 77

Linearization 118

Logistic map 100

Logistic map: Bifurcation diagram 87

Lorenz attractor 113, 114, 115, 123

L-systems 134

L-systems: Examples 135

L-systems: Screenview 135

Lyapunov exponents 94, 95, 119, 120

- M -Mandelbrot set 107

Matrices: operations 130

Matrices: screenview 130

Matrices: Solve A.X=B 131

Matrix addition 130

Matrix Determinant 130

Matrix inversion 130

Matrix multiplication 130

Matrix transposition 130

Matrix: Eigenvalues / vectors 130

Median 68

- O -ODEs: Analysis 113

ODEs: Analysis - Equilibrium points (Fixed points) 118

ODEs: Analysis - Lyapunov exponents 119

ODEs: Analysis - Lyapunov exponents - calculation 120

ODEs: Analysis - Lyapunov exponents - definition 120

ODEs: Analysis - Orbits in 3D 93

ODEs: Analysis - Phase portrait 117

ODEs: Analysis - Power spectrum 114

ODEs: Analysis - Projection in 2D 114

ODEs: Analysis - Projection in 3D 115

ODEs: Analysis - Surface of Section 116

ODEs: Analysis - Time Series 113

ODEs: Definition 111

ODEs: Examples 121

Page 150: Springfield Holding B.V

MathGrapher v2150

Springfield Holding B.V.

ODEs: Examples - Duffing oscillator 127

ODEs: Examples - Henon-Heiles potential 125

ODEs: Examples - Lorenz attractor 123

ODEs: Examples - Rossler equation 127

ODEs: Linearized equations 118

ODEs: Start / End Conditions 112

ODEs: T - Range 112

- P -Peano-Gosper curve 135

Phase portrait 117

Pixel Graph Window 97

Poincaré section 116, 125

Predator - prey model 117

- R -Read data from the Graph into a Grid 74

- S -Shaded surface graph 50

Shaded Surface: Inclination 56

Shaded Surface: Orientation 56

Sierpinski gasket 135

Skewness 68

Space filling curves 135

Special Functions 23

Special functions: Airy functions 33

Special functions: Bessel function of the first kind 32

Special functions: Bessel function of the second kind 33

Special functions: Bessel functions 32

Special functions: Beta distribution function 40

Special functions: Binomial distribution function 37

Special functions: Binomial probability distributionfunction 36

Special functions: Chi squared distribution function 41

Special functions: Complementary incompleteGamma function 31

Special functions: Cosine integral 28

Special functions: Distribution functions 37

Special functions: Elliptic integral of the first kind 34

Special functions: Elliptic integral of the second kind 35

Special functions: Elliptic integrals 34

Special functions: Error function 38

Special functions: Exponential integral 26

Special functions: Exponential integral En 26

Special functions: Exponential integrals 26

Special functions: Fresnel integrals 25

Special functions: Gamma function 29, 30

Special functions: Gaussian distribution function 39

Special functions: Hyperbolic cosine integral 29

Special functions: Hyperbolic sine integral 28

Special functions: Incomplete Gamma function 30

Special functions: Logarithmic integral 27

Special functions: Modulo function 25

Special functions: Poisson distribution function 37

Special functions: Poisson probability function 35

Special functions: Random numbers 24

Special functions: Riemann Zeta function 31

Special functions: Sine integral 27

Special functions: Student's t distribution function 41

Standard deviation 68

Standard map 107

Statistics: Statistical measures 68

Summary 13

Surface Graph 54

Surface of section 116, 125

- V -Viewer (3D) 60, 70

Page 151: Springfield Holding B.V

Back Cover