# 2D function plots

 F# for Visualization provides advanced interactive 2D function plotting capability with typeset mathematics.

F# for Visualization can be loaded with only one lines of code:

```> #r "FSharpForVisualization.dll";;
```

The definitions required for 2D function plotting are in the following modules:

```> open FlyingFrog.Graphics;;
> open FlyingFrog.Graphics.Typeset;;
```

A simple 2D function plot may be spawned from the F# interactive session using the `Plot` constructor:

`> Plot([Function id], (-1e30, 1e30), (-1e30, 1e30));;`

To give:

Note how the large numbers on the ticks are automatically typeset in conventional scientific notation.

The vertical range and labels are optional arguments to the `Plot` constructor. The following example demonstrates the use of typeset labels:

```> let labels = Row[math "x"], Row[Super(math "x", math 3); math "-x-1"];;
val labels : math * math
> Plot([Function(fun x -> pown x 3 - x - 1.0)], (-3., 3.), (-3., 4.), Labels=labels);;```

Note the typeset label. Typeset mathematics can include a wide variety of constructs including square roots and even integrals with limits.

For a more advanced example, consider the 1D Mexican hat wavelet written in terms of the second Hermite polynomial `h2`:

```> let wavelet t =
let pi = System.Math.PI
let c = 1.0 / sqrt(2.0 ** -3.5 * sqrt pi * 3.0)
let h2 x = 4.0 * x * x - 2.0
0.25 * c * h2(t / 2.0) * exp(-t*t / 4.0);;
val wavelet : float -> float

> let labels = Row[math "t"], Row[Sub(Greek.Psi, math 2); math "(t)"];;
val labels : math * math

> Plot([Function wavelet], (-8., 8.), (-0.9, 0.5), Labels=labels);;
```

This functionality of F# for Visualization can be used to plot any function of one variable.

(Note: We are not VAT registered and, therefore, cannot provide VAT receipts)

 Mastercard VISA VISA Delta VISA Electron VISA Purchasing JCB Solo Switch