![]() |
![]() |
| Products | F# for Visualization |
2D function plots
F# for Visualization can be loaded with only two lines of code: > #I @"C:\Program Files\Reference Assemblies\Microsoft\Framework\v3.0";; > #r @"C:\Program Files\FlyingFrog\FlyingFrog.Graphics.dll";; The definitions required for 2D function plotting are in the following modules: > open FlyingFrog;; > open FlyingFrog.Graphics;; > open FlyingFrog.Typeset;; A simple 2D function plot may be spawned from the F# interactive session using the > Graph.Plot((fun x -> x), (-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 > let labels = Row[Char 'x'], Row[Super(Char 'x', Char '3'); math_of_string "-x-3"];; val labels : math * math > Graph.Plot((fun x -> x**3.0 - x - 1.0), (-3., 3.), (-3., 4.), 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 > let Psi = Glyph {capital=true; name="Psi"; accent=None};;
val Psi : math
> 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
> Graph.Plot(wavelet, (-8., 8.), (-0.9, 0.5), (Row[Char 't'], Row[Sub(Psi, Char '2'); math_of_string "(t)"]));;
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)
|
| © Flying Frog Consultancy Ltd., 2007 | Contact the webmaster |