Wolfram for Teaching and Education

Troy Schaudt
Wolfram Research, Inc.
Educational Licensing
troys@wolfram.com

Table of Contents

About Wolfram

Workflow of Wolfram|Alpha Pro, Mathematica, Mathematica Online

Teaching Applications

Flexible document format to organize concept exploration

Add real-world relevance with integrated data

Scope of built-in functionality

Research Applications

Common platform for teaching and research

Specialized functionality and programming

Q&A

About Wolfram

A well-established user community

Deep roots in academia

Founded in 1987 by Stephen Wolfram

Continuous flagship product is Mathematica

Supports any teaching style (reformed calculus, Common Core, etc)

Many Nobel prize winners use Mathematica (at least 1 in 8 in Physics)

Wolfram|Alpha

Released as web site 2009

Pro version released in 2012, popular with students

Evolution of Wolfram technology

TabView[{Style["Mathematica", Blue]->Rasterize[ ,ImageResolution->130], Row[{Style["Wolfram|Alpha & ", Red], Style["Mathematica", Blue]}]->Rasterize[,ImageResolution->130],Row[{Style["Wolfram|Alpha, ", Red], Style["Mathematica, ", Blue], Style["and Mathematica Online", RGBColor[0, 0.501961, 0.25098]]}]->Rasterize[,ImageResolution->130]}]

Wolfram Language

Knowledge-based language with largest scope of any language

Language developed in Mathematica

Wolfram Cloud

Mathematica Online is browser-based version of Mathematica

Wolfram Programming Cloud to deploy Wolfram Language code as API

New uses of Wolfram Language: Draw Anything app, winning hack at MHacks V (at UMichigan)

Wolfram Workflow

Wolfram|Alpha queries

Same technology used by Siri for many types of queries

Web site for quick, single calculations and visualizations

Mathematica

Free-form input

Bridge from Wolfram|Alpha to Mathematica

Start working immediately: just type an equal sign to issue a command in plain English, then press ⇧ + ⌤ to evaluate.

Suggestions Bar

As commands are evaluated, the Suggestions Bar provides easy and immediate access to suggestions for what to do next.

(((x-1))^3)

Roll up your code when finished to create a miniature program.

Three simple rules for Wolfram Language

Functions in Mathematica are capitalized.

Use [ ] to surround function arguments.

Use { } to denote lists and ranges.

Plot[Cos[x],{x,-5,5}]

Input Assistant

The Input Assistant helps you automatically complete code, discover functions and options, and reduce errors when typing commands directly.

Point-and-click palettes

Use palettes like the Classroom Assistant to browse functionality and paste command templates into your document.

Documentation Center

Each built-in function has its own page with live calculations, Guide Pages and How-To’s to learn broader areas of functionality

Mathematica Online

Same document format

Author in Mathematica on desktop, File -> Save to Wolfram Cloud, access work on any other machine/device

WolframAlpha or any new user can author documents in Mathematica Online (not necessary to start in desktop)

Same Wolfram Language

Any machine, no installation of Mathematica required

Language exactly the same, as well as Free-form input and suggestions bar

Teaching Applications:
   Get hands-on with concept exploration

Flexible interactive models with Manipulate

Plot[Sin[x],{x,0,2π}]

Manipulate[expr,{u,(Subscript[u, min]),(Subscript[u, max])}]

Manipulate works with any built-in function

Model which varies the exponent and algebraic expansion

Expand[(((a+b))^5)]

Manipulate[Expand[(((a+b))^n)], {n, 1, 100, 1}]

Model which varies the sampling of a normal distribution

Histogram[RandomReal[NormalDistribution[0,2], 100]]

Manipulate[Histogram[RandomReal[NormalDistribution[0,2], n]], {n, 100, 10000, 100}]

Model which varies the quantity of rendered frames

Nest[Framed,x,6]

Manipulate[Nest[Framed,x,n], {n, 1, 25, 1}]

Make models as simple or as complex as you’d like.

Manipulate[Plot[a*function[f*(x-p)]+c,{x,-2π,2π},Ticks->{{-2π,-((3π)/2),-π,-(π/2),(π/2),π,((3π)/2),2π},True},PlotStyle->{Thickness[0.008],Hue[.6]},PlotRange->{-6,6},
PlotLabel->Style[
ToExpression[
ToString[a]<>"*"<>ToString[function]<>"["<>ToString[f]<>"* (x - "<>ToString[p]<>")] + "<>ToString[c]],14,Bold],
GridLines->Automatic,LabelStyle->Directive[FontFamily->"Helvetica",FontSize->12],
ImageSize->{300,200}],
{{f,1,"frequency"},1,5,Appearance->"Labeled",ControlPlacement->Left},
{{a,1,"amplitude"},-5,5,Appearance->"Labeled",ControlPlacement->Left},
{{p,0,"horizontal shift"},-3,3,Appearance->"Labeled",ControlPlacement->Left},
{{c,0,"vertical shift"},-2,2,Appearance->"Labeled",ControlPlacement->Left},
{function,{Sin,Cos,Tan,Csc,Sec,Cot},ControlPlacement->Left},
SaveDefinitions->True]

Manipulate authoring in Mathematica Online

Author interactive models on any web-enabled device in addition to primary machine

Extensive library of prebuilt materials

10,000+ prebuilt models available at the Wolfram Demonstrations Project

additional materials in the Wolfram Library Archive

Basic interactivity in Wolfram|Alpha

Enable interactivity -> Mathematica powers sliders for polar plot in web site

Teaching Applications:
   Create engaging, interactive documents

Mathematica Slide show templates

Many slide show templates are available for desktop Mathematica

TraditionalForm versus StandardForm

(∫_0^(2π))(1/((x^3)+1))\[DifferentialD]x

(∑_(n=0)^∞)((x^n)/(n!))

Mathematica sample quiz

Sample Mathematica Online documents

Notebooks are ideal for lectures or student projects, especially online/hybrid courses

iframe Mathematica Online into a Course Management System to organize files

Can also use folder structure in Mathematica Online itself

Mathematica Online, Insert -> Special Characters

Tests and quizzes

WolframAlpha Problem Generator

Wolfram Technical Services, creating custom assessment with Wolfram Language

Teaching Applications:
   Add real-world relevance with integrated data

Free-form queries

Look up data with plain English.

ChemicalData

You can easily look up all contents of a particular data set by typing the function name and evaluating...

ChemicalData[]

...along with the properties available for that data.

ChemicalData["Properties"]

Putting those together, you can look up a property for a specific piece of data.

ChemicalData["Caffeine","MoleculePlot"]

From data lookup to an interactive model in seconds

Start with a single piece of data, like the literacy fraction for Zimbabwe.

CountryData["Zimbabwe","LiteracyFraction"]

Then plot the same data for all of the countries in Africa.

BarChart[QuantityMagnitude[CountryData["Africa","LiteracyFraction"]]]

Now make it interactive...

Manipulate[
BarChart[QuantityMagnitude[CountryData[continent,"LiteracyFraction"]]]
,{continent,{"NorthAmerica","SouthAmerica","Africa","Europe","Asia","Oceania"}}]

Geographical data

Map based on current location

GeoGraphics[]

Entity is a more streamlined way to mix curated data and built-in functions.

flags=EntityValue[LinguisticAssistant,{"Entity","Flag"}];GeoGraphics[{EdgeForm[Black],{GeoStyling[{"Image",#2}],Tooltip[Polygon[#1],CommonName[#1]]}&@@@flags},GeoBackground->"StreetMapNoLabels"]

Work with your own data

Mathematica’s robust support for import and export of data allows you to perform all of your data visualization, analysis, and reporting within a single environment.

Supported file types

Import files on your computer

Let’s import a spreadsheet of data collected during a chemistry lab exercise:

data=Import["SampleLabData.csv"]

Wolfram Data Drop

Centralized storage for data sets on Wolfram Cloud, each with unique identifier

data=Databin["3GO7gvkz"]

Values[data]

Now we can visualize it or perform some analysis (more on that in the statistics section).

ListPlot[Values[data]]

Import files from a URL

Import["http://exampledata.wolfram.com/hailey.dem.gz",ColorFunction->"GreenBrownTerrain"]

Teaching Applications: 
   Compute and visualize anything

Symbolic computation

Step-by-step solutions in WolframAlpha Pro

Wolfram Language typesetting for common calculations

∫((Sin[x])^4)((Cos[x])^3)\[DifferentialD]x

(∂_(x,y))((Sin[x y])^3)

Solve[a (x^2)+b x+c==0,x]

Wolfram Language for multi-step problems with Manipulate

disp=DSolve[{y''[x]+damp y'[x]+40y[x]==0,y[0]==1,y'[0]==(1/3)},y,x]
Manipulate[Plot[ReplaceAll[y[x],disp]/.damp->a,{x,0,4},PlotRange->{-1,1}],{a,0,3}]

Numeric computation

Integrate oscillatory and other complicated functions (problem 1 of the SIAM challenge problems):

Plot[(1/x)Cos[((Log[x])/x)],{x,0,1},PlotRange->15,Filling->Axis,ImageSize->400]

Mathematica desktop for more intensive calculations

NIntegrate[(1/x)Cos[((Log[x])/x)],{x,0,1}]

Numerically solve delay and differential-algebraic equations, partial differential equations, and systems of nonlinear differential equations of any order.

sol=NDSolve[{D[u[t,x],t]==D[u[t,x],x,x],u[0,x]==0,u[t,0]==Sin[t],u[t,5]==0},u,{t,0,10},{x,0,5}];
Plot3D[Evaluate[u[t,x]/.sol],{t,0,10},{x,0,5},PlotRange->All,PlotLabel->Style["Heat equation in 1 dimension",FontFamily->"Arial",14,Bold]]

Support for finite elements included in NDSolve function

mr=BoundaryDiscretizeGraphics[ExampleData[{"Geometry3D","SpaceShuttle"}]];

uif=NDSolveValue[{Inactive[Laplacian][u[x,y,z],{x,y,z}]==0,DirichletCondition[u[x,y,z]==1,z≤-1.3]},u,{x,y,z}∈mr];

Needs["NDSolve`FEM`"]
ElementMeshSurfacePlot3D[uif,Boxed->False,ViewPoint->{0,-4,2}]

Linear algebra

Mathematica supports:

linear algebra on dense matrices, using industry-standard, high-performance libraries

sparse arrays of any dimension

numerical linear algebra on arbitrary-precision and mixed symbolic-numeric matrices

Matrix construction

use the Classroom Assistant palette

(Subscript[matrix, 1])=(({{\[Placeholder], \[Placeholder], \[Placeholder]}, {\[Placeholder], \[Placeholder], \[Placeholder]}, {\[Placeholder], \[Placeholder], \[Placeholder]}}))

(Subscript[matrix, 1])=(({{1, 2, (Sqrt[3])}, {1, 5, 7}, {(Sqrt[7]), 2, 3}}))

use a pattern for construction

(Subscript[matrix, 2])=Table[i*j,{i,1,5},{j,1,5}]

create a random matrix

(Subscript[matrix, 3])=RandomInteger[10,{5,5}]

Det[(Subscript[matrix, 3])]

(Subscript[matrix, 2]).(Subscript[matrix, 3])

Norm[(Subscript[matrix, 2]).(Subscript[matrix, 3])]

Inverse[(Subscript[matrix, 3])]

N[%]

Advanced example: linear solving with sparse systems

First, we construct a sparse tridiagonal matrix of dimensions 5 by 5.

s=SparseArray[{{i_,i_}->9,{i_,j_}/;Abs[i-j]==1->1},{5,5}]

We can get a visual representation of the matrix.

MatrixForm[Normal[s]]

We can also visualize the matrix as a plot.

MatrixPlot[s]

Now, let's create a random 5-element vector of real numbers.

b=RandomReal[1,{5}]

We can now solve the equation s.x=b using LinearSolve, and for a final touch, we wrap the entire command with Timing to see how long it takes.

Timing[LinearSolve[s,b]]

Mathematica returns a result immediately, but this is a small-scale problem. Let's ramp this up a bit. First, we create a random 50,000-element vector of real numbers.

bLarge=RandomReal[1,{50000}];

Next, we create the same tridiagonal matrix as before, only this time with dimensions 50,000 by 50,000.

sLarge=SparseArray[{{i_,i_}->9,{i_,j_}/;Abs[i-j]==1->1},{50000,50000}];

Let's take a quick peek to see what that looks like...

MatrixPlot[sLarge,ColorFunction->"Rainbow"]

Finally, we solve as before.

Timing[LinearSolve[sLarge,bLarge]]
Clear[b]

Notice how quickly Mathematica returns the result.

Unit computation

Support for thousands of units, integrated throughout the system with a new Quantity framework. Units are resolved automatically or can be converted explicitly.

Use free-form input to handle unit conversion

Use Ctrl + = to create Inline free-form input.

LinguisticAssistant+LinguisticAssistant+LinguisticAssistant

Use the Quantity framework

The Quantity framework can be used to compute with and compare units, or for conversion.

Add 3 feet to 2 inches.

Quantity[3,"Feet"]+Quantity[2,"Inches"]

Determine is 3 feet is less than 1 meter.

Quantity[3,"Feet"]<Quantity[1,"Meters"]

Convert 3 feet to meters.

UnitConvert[Quantity[3,"Feet"],"Meters"]

Simplify units.

UnitSimplify[Quantity[1,("Joules"/"Seconds")]]

Units are integrated with other parts of the system, such as axes labels.

dataset1=Table[Quantity[RandomReal[{0,1}],(("Grams")/(("Centimeters")^3))],{25}];
ListLinePlot[dataset1,AxesLabel->Automatic,Filling->Axis,PlotLabel->"Hardwood Density",BaseStyle->FontSize->16]

Teaching Applications: 
   Compute and visualize anything

"2D visualization""3D visualization""data visualization""specialized subjects & fields"

Consistent Wolfram Language syntax

To visualize a sine curve:

Plot[Sin[x],{x,-10,10}]

To compute a definite integration for the same sine curve:

Integrate[Sin[x],{x,-10,10}]

View the same function in different ways by simply choosing a different visualization command.

Plot3D[Sin[x]Cos[y],{x,-6,6},{y,-6,6}]

Manipulate[func[Sin[x]Cos[y],{x,-6,6},{y,-6,6}],{func, {Plot3D, ContourPlot, DensityPlot}}]

Built-in interactivity

WolframAlpha Pro chooses charts/graphs based on uploaded data

In Wolfram Language, some 2D graphics have automatic interactivity to provide more information when the pointer is moused over the graphic.

BoxWhiskerChart[Table[RandomVariate[NormalDistribution[μ,1],100],{μ,{0,3,2,5}}]]

3D graphics are interactive—click and drag to rotate, Ctrl-click (or ⌘-click) to zoom, and ⇧+click to pan.

Plot3D[Sin[x] Sin[y],{x,0,2π},{y,0,2π}]

User-defined interactivity

Commands like Tooltip and PopupWindow can be used to provide additional interactivity.

Plot[Tooltip[{Sin[x],Cos[x],Sin[x]+3,Cos[x]+3}],{x,0,2π}]

Automation

Automated computational aesthetics and symbolic preprocessing create visually pleasing and accurately rendered results.

TabView[{
Style["function coloring",FontFamily->"Arial",FontSize->14, Background->Transparent]->Show[,ImageSize->1->1],
Style["branch cuts",FontFamily->"Arial",FontSize->14, Background->Transparent]->Show[,ImageSize->1->1],
Style["adaptive sampling",FontFamily->"Arial",FontSize->14, Background->Transparent]->Show[,ImageSize->1->1],
Style["general presentation",FontFamily->"Arial",FontSize->14, Background->Transparent]->Show[,ImageSize->1->1]
}]

Customization

Use the Suggestions Bar to create custom styling, or add options with the Classroom Assistant palette.

TabView[{
Style["default plot",FontFamily->"Arial",FontSize->14, Background->Transparent]->,
Style["change the styling",FontFamily->"Arial",FontSize->14, Background->Transparent]->,
Style["add gridlines",FontFamily->"Arial",FontSize->14, Background->Transparent]->,
Style["add filling",FontFamily->"Arial",FontSize->14, Background->Transparent]->,
Style["add a title",FontFamily->"Arial",FontSize->14, Background->Transparent]->
}]

Lots of options

Change all manner of styling, lighting, background elements, and textures.

styleoptions=Sequence@@{PlotRangePadding->{{0.01,Scaled[0.01]},{None,Scaled[0.05]}},AxesStyle->Gray,ImageSize->200,Ticks->None,AxesOrigin->{0,0.01},PlotRange->{0.01,All}};
gridlines=Table[Function[{xmin,xmax},With[{x1=Round[xmin,0.1],x2=Round[xmax,0.1]},Join[{#,Directive[LightGray,Opacity[0.4]]}&/@DeleteCases[Range[x1,x2,0.02],Alternatives@@Range[x1,x2,0.1]],{#,Directive[Gray,Opacity[0.3]]}&/@Range[x1,x2,0.1]]]],{2}];
labelstyle={14,GrayLevel[0.3],FontFamily->"Helvetica"};
gridoptions=Sequence@@{Frame->All,FrameStyle->Directive[LightGray,AbsoluteThickness[2]],Alignment->{Center,{Bottom,Center}},Spacings->{2,2}};
xlist={1,10,100,1000,10000};
functions=Plot[Table[Sqrt[Sin[t]] Exp[-x Sin[t]^4],{x,xlist}]//Evaluate,{t,0,Pi/2},PlotStyle->(Directive[Thick,#]&/@ColorData[68,"ColorList"]),PlotLegends->LineLegend[{1,10,100,1000,10000},LegendLabel->x,LabelStyle->labelstyle],PlotLabel->Style[f[x],labelstyle],Evaluate@styleoptions];
approximations=Plot[Table[(8 E x)^(-1/8) Exp[-(2 Sqrt[2] Sqrt[x]-1) (t-ArcSin[(8 x)^(-1/4)])^2],{x,xlist}]//Evaluate,{t,0,Pi/2},PlotStyle->(Directive[Thick,Dashing[{0.02,0.03}],#]&/@ColorData[68,"ColorList"]),PlotLabel->Style["approximations",labelstyle],Evaluate@styleoptions];
Grid[{{functions,approximations},{Show[functions,approximations,ImageSize->400,GridLines->gridlines,LabelStyle->labelstyle,PlotLabel->None,Ticks->Automatic],SpanFromLeft}},Evaluate@gridoptions]

GraphicsRow[{
ParametricPlot3D[{(1.16^v) Cos[v] (1+Cos[u]),-(1.16^v) Sin[v] (1+Cos[u]),-2 (1.16^v) (1+Sin[u])},{u,0,2 π},{v,-15,6},PlotRange->All,Mesh->None,Boxed->False,Axes->False,
PlotStyle->Texture[],MaxRecursion->3,Background->Black,ImageSize->{240,300},RotationAction->"Clip",Lighting->"Neutral"],
ParametricPlot3D[{(1.16^v) Cos[v] (1+Cos[u]),-(1.16^v) Sin[v] (1+Cos[u]),-2 (1.16^v) (1+Sin[u])},{u,0,2 π},{v,-15,6},PlotRange->All,Mesh->None,Boxed->False,Axes->False,PlotStyle->{Black,Texture[]},MaxRecursion->3,Background->Black,ImageSize->{240,300},RotationAction->"Clip",Lighting->"Neutral"],
ParametricPlot3D[{(1.16^v) Cos[v] (1+Cos[u]),-(1.16^v) Sin[v] (1+Cos[u]),-2 (1.16^v) (1+Sin[u])},{u,0,2 π},{v,-15,6},PlotRange->All,Mesh->None,Boxed->False,Axes->False,
PlotStyle->Texture[],MaxRecursion->3,Background->Black,ImageSize->{240,300},RotationAction->"Clip"]},Spacings->0]

Annotation

Use Drawing Tools for interactive editing and annotation.

PolarPlot[θ,{θ,0,2π}]

Right-click to save your work as a standalone graphic.

Mobile Computing

2014 survey, popular hardware

2 out of 3 students use both a tablet and laptop for coursework

All of which were interested in using Mathematica on both tablet and laptop

Mathematica Online

Browser-based with coverage for wide variety of devices

Wolfram Cloud App

Optimize Mathematica Online experience for iOS (Android in development)

Free App for all Mathematica Online users

Wolfram|Alpha-based Apps

Subject-specific apps with intuitive interfaces guide students through the coursework to help them solve problems, not just give them answers.

Collaboration and Deployment

Sharing NB files in Mathematica Online

Group of users can work on the same file

Can create a duplicate copy to make personal changes to a file

Can set permissions for Collaborators allowing edits or static view

CDF

Share a snapshot of a project with Manipulate and static text/graphics

Users download free CDF Player (Mac/Windows/Linux only)

Any Mathematica 10 license can create CDF files

EnterpriseCDF

More flexible mouse-driven applications, adds input fields and data upload

Users download free CDF Player (Mac/Windows/Linux only)

Enterprise Mathematica can create EnterpriseCDF files

Panel[
DynamicModule[{eq1=x+5, eq2=x+5, a111=1, b111=1},
Column[{
Column[{
Style["Enter any equation using the symbols 'a' and 'b' as dynamic variables ", 14, RGBColor[0.0352941, 0.368627, 0.00784314]],
Row[{Style["Enter equation: ", RGBColor[0.027451, 0.00784314, 0.4]],InputField[Dynamic[eq1]]}],
Button["Update graph", eq2=eq1, ImageSize->150],
─
}],
Column[{
Row[{"a (1 to 5): ",Slider[Dynamic[a111], {1,5, 0.05}]}],
Row[{"b (1 to 5): ",Slider[Dynamic[b111], {1,5, 0.05}]}],
Dynamic[eq2/.{a-> a111, b->b111}],
Dynamic[Plot[eq2/.{a-> a111, b->b111}, {x, -10, 10}, PlotRange->{-10, 10},
PlotStyle->Directive[Thick,RGBColor[0.2,0.6,0.8]],
Filling->Axis,FillingStyle->Directive[Opacity[0.3],RGBColor[0.2,0.6,0.8]],
BaseStyle->{FontFamily->"Arial"},
ImageSize->400]]
}, Alignment-> Center]
}]
]
]

CloudCDF

Web-based CDF applications similar to Free CDF

Users view within browser, no download needed

CloudDeploy in Mathematica or Mathematica Online to deploy, Cloud Credits govern the licensing

Wolfram Cloud

Basic: 25 MB of cloud storage with 10 MB file size limit via File -> Save to Wolfram Cloud

Basic: 250 Cloud Credits per month to test CloudCDF applications, still have option of local CDF Player

Mathematica Online: 10,000 Cloud Credits per month (site license)

Teaching Applications Summary

Anyone can get started in 5 minutes, thanks to free-form input, the Suggestions Bar, and point-and-click palettes

Engage students with models that allow for hands-on exploration of concepts during lectures, lab activities, or homework assignments

Create dynamic documents, like handouts, quizzes, and lecture presentations, that mix text, graphics, typesetting, and interactive components

Integrated data can be used for real-world examples and is applicable to many subject areas

Mathematica (desktop and online) with Wolfram|Alpha Pro are ideal for learning and teaching, no matter the subject or grade level

Research Applications

Did you know that Mathematica is used for...

MouseOver

MouseOver

MouseOver

MouseOver

MouseOver

MouseOver

Research Applications: 
   Built-in parallel computing & GPU support

Automatic parallelization

Some Mathematica functions (such as MouseOver) have parallel analogues (MouseOver) that automatically parallelize computations for you.

There is also a general function, MouseOver, which will parallelize a computation, if possible.

Parallelize[(∑_(i=1)^1000000)N[(i^3)*π]]

Operations that cannot be parallelized are evaluated normally.

Parallelize[∫((1+(x^4))/((x^9)+3x))\[DifferentialD]x]

Support for managed and ad-hoc cluster computing

support for managed clusters (CCS, HPC, LSF, PBS, and SGE)

create an ad-hoc cluster using Wolfram Lightweight Grid System

CUDA & OpenCL support

Take advantage of your GPU with support for both CUDA and OpenCL, optimized for:

linear algebra

financial computation

image processing

Fourier transforms

Some Mathematica functions (such as MouseOver) have analogues (MouseOver) that automatically use GPUs for computation.

Examples

First, we load the built-in package for CUDA processing.

Needs["CUDALink`"]

Next, we generate some random numbers.

numberOfOptions=2^14;
spotPrices=RandomReal[{25.0,35.0},numberOfOptions];
strikePrices=RandomReal[{20.0,40.0},numberOfOptions];
expiration=RandomReal[{0.1,10.0},numberOfOptions];
interest=0.08;
volatility=RandomReal[{0.10,0.50},numberOfOptions];
dividend=RandomReal[{0.2,0.06},numberOfOptions];

Now, compute the European call option price using a traditional method.

Timing[FinancialDerivative[{"European", "Call"}, {"Expiration"->expiration[[#]],"StrikePrice"->strikePrices[[#]]},{"CurrentPrice"->spotPrices[[#]],  "InterestRate"->interest, "Volatility"->volatility[[#]], "Dividend"->dividend[[#]]}]&/@Range[numberOfOptions]]

Finally, let’s look at using the CUDA-optimized function instead.

Timing[CUDAFinancialDerivative[{"European", "Call"}, {"StrikePrice"->strikePrices, "Expiration"->expiration},{"CurrentPrice"->spotPrices, "InterestRate"->interest, "Volatility"->volatility, "Dividend"->dividend}]]

We see that the results are identical but that the CUDA-optimized function performs the computation more quickly.

Further reading: scalable parallelization

Mathematica's parallel computing scales across your available local cores, or can scale across a grid or cluster if you have the licensing for that. As an example, we can compute a table of StreamDensityPlots using multiple cores working in parallel to improve computation time. For example, here is the single-core case:

Quit[]

LaunchKernels[1]

Parallelize[
Map[StreamDensityPlot[#1,{x,-π,π},{y,-π,π}]&,Flatten[Table[{(x^i) Cos[(y^j)],Sin[j (y^i)]},{i,3},{j,3}],1]]]

We can look at a table of results (and you can try this yourself on your own multi-core machine; just replace the "1" in the MouseOver command to try this with a different number of kernels).

Grid[{
{Style["# of cores",FontFamily->"Arial",Bold],Style["Time elapsed (s)",FontFamily->"Arial",Bold]},
{Style["1",FontFamily->"Arial",FontSize->14, Background->White],Style["4.2904290",FontFamily->"Arial"]},
{Style["2",FontFamily->"Arial",FontSize->14, Background->White],Style["2.6122612",FontFamily->"Arial"]},
{Style["4",FontFamily->"Arial",FontSize->14, Background->White],Style["1.4971497",FontFamily->"Arial"]},
{Style["8",FontFamily->"Arial",FontSize->14, Background->White],Style["1.0011001",FontFamily->"Arial"]}
},
Dividers->{None,{2->Black}},Frame->{{11,2}->True},
Alignment->{{Left,Right}}]

We can see that for this particular problem, we didn't get a linear speed-up, but we did get a nice improvement as more kernels were leveraged.

Further reading: speculative parallelism

Mathematica contains the capability to perform speculative parallelism. This is particularly useful when you want to optimize each piece of a large program. In that case, you want to make sure that each function call is using the best possible method, so you may want to have Mathematica try all of them, find out which is the best method, and then hard-code that into your program.

Let's look at the most efficient method for a particular minimization problem.

AbsoluteTiming[ParallelTry[
{#,FindMinimum[(E^(Sin[50 x]))+Sin[60 (E^y)]+Sin[70 Sin[x]]+Sin[Sin[80 y]]-Sin[10 (x+y)]+(1/4) ((x^2)+(y^2)),{x,y},Method->#]}&,{"Gradient","ConjugateGradient","InteriorPoint","QuasiNewton","Newton"}]]

Mathematica launches additional kernels, tries all of the methods (in parallel), and we find out that the gradient method is the most efficient. Thus, we could use this piece of code in our program to make sure that method is used:

FindMinimum[(E^(Sin[50 x]))+Sin[60 (E^y)]+Sin[70 Sin[x]]+Sin[Sin[80 y]]-Sin[10 (x+y)]+(1/4) ((x^2)+(y^2)),{x,y},Method->"Gradient"]

Further reading: monitoring parallel computations

Mathematica provides a menu (under Evaluation > Parallel Kernel Status) to see what kernels are in use.

You can also get a visual representation of computations to be performed by using MouseOver and MouseOver:

First, we submit our jobs for processing...

Table[ParallelSubmit[{i},FactorInteger[2^i+1]],{i,213,222}]//StandardForm

Then we evaluate MouseOver and watch...

WaitAll[%]

Research Applications: 
   Programming in Mathematica

Program in whatever style you want

Mathematica’s multiparadigm language and broad range of constructs makes it a perfect choice for computer science curricula at all levels.

StandardForm@Grid[{
{" ",Style[HoldForm[f=Factorial],"Input",FontSize->14, Background->White,Background->White]},
{" ",Style[HoldForm[f[n_]:=n!],"Input",FontSize->14, Background->White]},
{Style["Rule-based",FontFamily->"Arial",Gray,FontSize->14, Background->White],Style[HoldForm[f[n_]:=n f[n-1];f[1]=1],"Input",FontSize->14, Background->White]},
{Style["Procedural",FontFamily->"Arial",Gray,FontSize->14, Background->White],Style[HoldForm[f[n_]:=Module[{t=1},Do[t=t*i,{i,n}];t]],"Input",FontSize->14, Background->White]},
{" ",Style[HoldForm[f[n_]:=Module[{t=1,i},For[i=1,i<=n,i++,t*=i];t]],"Input",FontSize->14, Background->White]},
{Style["List-based",FontFamily->"Arial",Gray,FontSize->14, Background->White],Style[HoldForm[f[n_]:=Apply[Times,Range[n]]],"Input",FontSize->14, Background->White]},
{" ",Style[HoldForm[f[n_]:=Fold[Times,1,Range[n]]],"Input",FontSize->14, Background->White]},
{Style["Recursive",FontFamily->"Arial",Gray,FontSize->14, Background->White],Style[HoldForm[f[n_]:=If[n==1,1,n*f[n-1]]],"Input",FontSize->14, Background->White]},
{Style["Functional",FontFamily->"Arial",Gray,FontSize->14, Background->White],Style[HoldForm[f=If[#1==1,1,#1*#0[#1-1]]&],"Input",FontSize->14, Background->White]},
{" ",Style[HoldForm[f[n_]:=Fold[#2[#1]&,1,Array[Function[t,#t]&,n]]],"Input",FontSize->14, Background->White]},
{Style["Constructive",FontFamily->"Arial",Gray,FontSize->14, Background->White],Style[HoldForm[f[n_]:=Length[Permutations[Range[n]]]],"Input",FontSize->14, Background->White]},
{Style["Pattern-based",FontFamily->"Arial",Gray,FontSize->14, Background->White],Style[HoldForm[f[n_]:=First[{1,n}//.{a_,b_/;b>0}:>{b*a,b-1}]],"Input",FontSize->14, Background->White]},
{Style["String-based",FontFamily->"Arial",Gray,FontSize->14, Background->White],Style[HoldForm[f[n_]:=StringLength[Fold[StringJoin[Table[#1,{#2}]]&,"\"A\"",Range[n]]]],"Input",FontSize->14, Background->White]},
{Style["Mathematical",FontFamily->"Arial",Gray,FontSize->14, Background->White],Style[HoldForm[f[n_]:=Gamma[n+1]],"Input",FontSize->14, Background->White]},
{" ",Style[HoldForm[f[n_]:=Product[i,{i,n}]],"Input",FontSize->14, Background->White]}
},Alignment->{{Right,Left}},
Frame->{None,None,{{1,2}->True,{2,2}->True,{3,2}->True,{4,2}->True,{5,2}->True,{6,2}->True,{7,2}->True,{8,2}->True,{9,2}->True,{10,2}->True,{11,2}->True,{12,2}->True,{13,2}->True,{14,2}->True,{15,2}->True}},
Spacings->{1,0.40}
]

Functions and pattern-matching

Functions in Mathematica are defined by rules that act on patterns.

f[x_]:=(x^2)

The x_ stands for any expression, so we can ask Mathematica to square whatever we give it.

f[10]

f[3.1415]

f[{1,2,3,4,5}]

f[\[MathematicaIcon]]

We can also define a function that behaves differently depending on the type of arguments passed to it.

g[x_Integer]:=Sin[(1/(x-1))]
g[x_Real]:=N[Pi,50]
g[x_String]:=

Let’s check its behavior.

g[10]

g[10.1]

g["test"]

Function definitions and command completion

If you can’t remember whether a function is defined, you can check its definition and context by using the ? operator.

?f

You can also use the asterisk (*) as a wildcard. For example, I want to find all functions and symbols that contain the letters Plot.

?*Plot*

Mathematica has command completion, which you can access by typing Ctrl+k (or ⌘+k).

Plo

Command completion also works on user-defined functions and symbols.
Let’s define a variable:

myVariableExample=10

Now we can type the first few letters and use Ctrl+k to complete the name.

myV

You can also go one step further by using template creation. Type the first few letters of your function name and then hit Ctrl+⇧+k (or ⌘+⇧+k) to have Mathematica create a function template for you.

Plo

Writing programs

Mathematica’s interactive nature makes it possible to perform useful calculations without actually programming – you aren’t forced to write an elaborate program beforehand, and then compile it and test it out.

Define your own program or function for involved projects

A simple data analysis program that shows polynomial fits and (r^2) values

dataFitApp[data_, polydegree_]:=
(fits=Table[LinearModelFit[data,Table[(x^j),{j,0,i}],x],
{i,1,polydegree}];
Table[
Show[ListPlot[data],Plot[fits[[i]]["BestFit"],{x,0,100},PlotStyle->Red],
PlotLabel->"degree "<>ToString[i]<>" polynomial"<>"\n"<>"(r^2): "<>ToString[fits[[i]]["RSquared"]]],
{i,polydegree}]
)

Import a local file or download a data set from Data Drop

data1=Databin["3GPXSZfi"];
Dimensions[Values[data1]]

ListPlot[Values[data1]]

The can then be accessed just like built-in functions, following gives us polynomial fits up to 8 degrees

dataFitApp[Values[data1], 8]

Transition to parallel program

By changing Table to ParallelTable, this program will take advantage of multiple cores or a dedicated cluster

parallelDataFitApp[data_, polydegree_]:=
(fits=ParallelTable[LinearModelFit[data,Table[(x^j),{j,0,i}],x],
{i,1,polydegree}];
ParallelTable[
Show[ListPlot[data],Plot[fits[[i]]["BestFit"],{x,0,100},PlotStyle->Red],
PlotLabel->"degree "<>ToString[i]<>" polynomial"<>"\n"<>"(r^2): "<>ToString[fits[[i]]["RSquared"]]],
{i,polydegree}]
)

We can compare timings of each program, in this case, comparing a single core to a dual core machine

dataFitApp[Values[data1], 8]//AbsoluteTiming

parallelDataFitApp[Values[data1], 8]//AbsoluteTiming

Clear[data1, dataFitApp, parallelDataFitApp]

Program with broad scope of functionality

Use data on campuses, data on maps, along with computational geometry and geodesy to find the nearest border to any particular campus (based on US map shape).

campus="univ of nevada";

pt=WolframAlpha[campus,{{"BasicInformation:UniversityData",1},"ComputableData"}][[1,2]]//StringSplit[#,", "]&//Flatten[#][[1;;2]]&//CityData[#,"Coordinates"]&//Reverse;usRegionPlot=DiscretizeGraphics[CountryData["UnitedStates","Polygon"]];
usRegion=RegionBoundary[usRegionPlot];
pn=RegionNearest[usRegion,pt];
GeoDistance[Reverse[pt],Reverse[pn]] 
p=Show[{usRegionPlot,Graphics[Arrow[{pt,pn}]]}]
Manipulate[Show[p,PlotRange->{{left,right},{bottom,top}}],{left,-125,-65},{right,-65,-125},{bottom,25,50},{top,50,25}]
Show[p,PlotRange->{{pt[[1]]-3,pn[[1]]+3},{pt[[2]]-3,pn[[2]]+3}}]

Example: random walks

Suppose we want to write a program to create a random walk in one dimension. We create a vector of random real numbers between -1 and 1.

RandomReal[{-1,1},{12}]

And we can use the MouseOver function to create running sums.

Accumulate[{a,b,c,d,e}]

Putting those together, we can have a single command that yields a one-dimensional random walk.

Accumulate[RandomReal[{-1,1},{12}]]

We can turn this into a function by which we can specify the number of steps.

myRandomWalk[steps_]:=Accumulate[RandomReal[{-1,1},{steps}]]

Let’s plot a large one-dimensional random walk.

ListPlot[myRandomWalk[1000],Joined->True]

On average, how far does the walk stray from the origin? We can look at the last position of a 1000-step walk.

Last[myRandomWalk[1000]]

Run 10 trials, and then average.

With[{trials=10},
Table[Last[myRandomWalk[1000]],{trials}]
]
Mean[%]

Let’s turn this into a function...

myRWMeanSerial[steps_,trials_]:=Mean[Table[Last[myRandomWalk[steps]],{trials}]]

Now we can look at 10,000 trials for a 1000-step walk...

myRWMeanSerial[1000,10000]

Example: automated report generation

CreateDocument[CellGroup[{TextCell[CountryData[#,"Name"],"Section"],ExpressionCell[GraphicsRow[{CountryData[#,"Shape"],Quiet[DateListPlot[CountryData[#,{{"Population"},{1970,2005}}]]]},Frame->All,ImageSize->600],"Output"]},Closed]&/@CountryData["Africa"],WindowTitle->"Africa",StyleDefinitions->"Creative/NaturalColor.nb"]

Research Applications: 
   Code Compilation & Connectivity

Mathematica introduces performance enhancements such as faster compiled execution, standalone C code generation, the ability to call dynamic linked libraries, and improved support for other connection technologies.

Faster compiled execution

Speed up code execution with the new option of automatic C code generation and linking. You can also run a compiled function in parallel to multiply performance on multi-core machines.

Why compile?

A major benefit of compilation is that it allows certain computations to be faster.

The following creates two expressions: the first is compiled for optimal execution while the second is a regular Mathematica function.

cFun=Compile[{{x,_Real},{n,_Integer}},
	Module[{sum, inc},sum=1.0;inc=1.0;Do[inc=inc*x/i;sum=sum+inc,{i,n}];sum]];
fFun=Function[{x,n},
	Module[{sum, inc},sum=1.0;inc=1.0;Do[inc=inc*x/i;sum=sum+inc,{i,n}];sum]];

It’s faster to use the compiled version.

cFun[10.5,1000000]//AbsoluteTiming

fFun[10.5,1000000]//AbsoluteTiming

Compile for parallel computation

Compiled function computations can be made faster still by running in parallel.

Let’s define a range of numbers to operate on.

arg=Range[ -50.,50, 0.05];
Short[arg]

Now, let’s look at an iterative function that processes these numbers, and let’s compile that function for improved execution.

cSequentialNoList=Compile[{{x,_Real,1}},Map[Module[{sum=1.0,inc=1.0},Do[inc=inc*#/i;sum=sum+inc,{i,10000}];sum]&,x],RuntimeAttributes->{Listable},Parallelization->True];

cSequentialNoList[arg]//Short

The Option for Parallelization and specifying a CompilationTarget can improve calculation time further in some cases.

Code generation

Mathematica allows you to convert compilable Mathematica programs into C code for standalone execution.

Create a compiled function.

cf=Compile[ {{x}},x^2+Sin[x^2]];

Now we can generate C code for the function that will execute completely externally to Mathematica.

Example

First, we load the built-in package for C code generation.

<<CCodeGenerator`

Now we can generate the code.

CCodeStringGenerate[cf, "fun"]

Connectivity

Databases

Use the DatabaseLink to connect to databases.

Dynamic linked libraries (DLLs)

Integrate external libraries into Mathematica for high-speed, memory-efficient execution.

MathLink, J/Link, and .NET/Link

Mathematica's two components (the front end and the kernel) communicate via a protocol known as MathLink. MathLink can also be used to connect Mathematica to other programs, such as C programs.

There are specialized links to Java (J/Link) and .NET (.NET/Link) available as well.

IDE available

The Wolfram Workbench provides a powerful integrated development environment that allows you to debug Mathematica code, as well as providing tools for profiling, testing, and version control. Additionally, you can worked with mixed-platform environments, such as Java, J/Link, and gridMathematica.

The Workbench is built on Eclipse and is available as a standalone application for Windows, Macintosh, or Linux (or as a plug-in for your existing Eclipse installation) and is available free of charge as part of your site license's Premier Service.

Research Applications: 
   Specialized application areas

Unlike systems that require the purchase of additional tools, Mathematica has built-in functionality for application areas that seamlessly integrates with its other capabilities.

Research Applications: 
   Statistics in Mathematica

The most recently Mathematica releases add...

a hundred new distributions, including specialized coverage for finance and engineering

new functions for computation of properties, parameter estimation, and simulation

new visualization capabilities

Descriptive statistics

Many descriptive statistics are available. Let’s generate 25 uniformly distributed random numbers between 0 and 10.

data=RandomReal[10,25]

We can now compute a variety of measures.

Mean[data]

Variance[data]

StandardDeviation[data]

InterquartileRange[data]

Let’s generate a new data set with the same parameters as before.

newdata=RandomReal[10,25]

Now we an compute covariance and correlation between the two data sets.

Covariance[data,newdata]

Correlation[data,newdata]

Curve fitting & regression analysis

Let’s import a spreadsheet of data and visualize it.

data=Databin["3GO7gvkz"];
ListPlot[Values[data]]

Fit a model to the data.

model=LinearModelFit[Values[data],{1,x,(x^2),(x^3)},x]

Visualize the data and the fitted model.

Show[ListPlot[Values[data]],Plot[model[x],{x,-5,15},PlotStyle->Red]]

We can also extract other properties from the model.

model["Properties"]

For example, here is the ANOVA table.

model["ANOVATable"]

Probability & expectation computation

Compute probabilities for simple or logical combinations of inequalities and equations.

Symbolic example

What is the probability that (k^2)>10 or k<2 given that k is sampled from a Poisson distribution with mean λ?

Probability[k^2>10||k<2,k\[Distributed]PoissonDistribution[λ]]

Coin tossing

Let’s define a function to simulate tossing a coin where the outcome is heads.

heads[n_]:=BinomialDistribution[n,1/2]

We can plot the probability density function (PDF).

DiscretePlot[PDF[heads[100],k],{k,0,100},PlotRange->All]

Now let’s find the probability that if we toss the coin 100 times, we receive between 60 and 80 heads.

Probability[60≤x≤80,x\[Distributed]heads[100]]

N[%]

Simulation & testing

Distributions generate data, but conversely, data generates distributions. We can take a data set in Mathematica and generate a distribution from it.

Example

The average number of accidents in a city is 100 per day. We can simulate the daily accidents with a Poisson distribution.

RandomVariate[PoissonDistribution[100],30]

ListPlot[%,Filling->Axis,PlotStyle->PointSize[Medium]]

And given outcomes, we can estimate the distribution.

data=RandomVariate[PoissonDistribution[100],(10^3)];
Short[data]

EstimatedDistribution[data,PoissonDistribution[μ]]

Statistical distributions

Mathematica contains more parametric distributions than any other system.

Statistics visualization

New charts for data distributions:

data=Table[RandomReal[NormalDistribution[RandomReal[{-2,2}],RandomReal[{0.5,2}]], 50], {i,10}];

ListAnimate@Join[

Table[DistributionChart[data,PlotLabel->Style[elt,FontFamily->"Arial"],ChartElementFunction->elt,ImageSize->Medium,ChartStyle->RandomInteger[{1,45}]],{elt,ChartElementData["DistributionChart"]}],

Table[BoxWhiskerChart[data,style,ImageSize->Medium,PlotLabel->Style[style<>" Box Whisker Chart",FontFamily->"Arial"],ChartElementFunction->RandomChoice[ChartElementData["BoxWhiskerChart"]],ChartStyle->RandomInteger[{1,45}]],{style,{"Basic","Median","Mean","Notched","Diamond","Outliers"}}]
]

Q-Q plots:

QuantilePlot[Range[0,10,0.1],PlotStyle->Directive[PointSize[Large],ColorData[13,10]],ReferenceLineStyle->Thick,AspectRatio->1,Filling->{2->{{1},Opacity[0.4,ColorData[13,10]]}},BaseStyle->{FontFamily->"Helvetica"},LabelStyle->Bold,ImageSize->500]

Probability-probability plots (compare data sets to the best-fitting normal distribution):

ProbabilityPlot[Range[0,10,0.1],PlotStyle->Directive[PointSize[Large],ColorData[17,7]],ReferenceLineStyle->Thick,AspectRatio->1,Filling->{2->{{1},Opacity[0.4,ColorData[17,7]]}},BaseStyle->{FontFamily->"Helvetica"},ImageSize->500,LabelStyle->Bold]

Paired bar charts:

countries=CountryData["G8"];
{dataLeft,dataRight}=Table[1*^-9 CountryData[#,s]&/@countries,{s,{"ExportValue","ImportValue"}}];

PairedBarChart[{dataLeft},{dataRight}, BarSpacing->{0, 0,1}, ChartLabels->{Placed[{"Import", "Export"}, Above],None,Placed[countries, "CenterAxis"]},Method->{"LabelStyle"->"Short"},ChartStyle->{{Opacity[1],Opacity[0.5]},None,53}]

Research Applications: 
   Other application areas

Finance

Mathematica includes support for derivative calculations (such as option pricing), computation of bond values and sensitivity measures, and calculation of time value of money with a variety of interest rate scenarios.

Financial derivatives

Price more than 60 exotic equity options using new built-in functions – the largest collection in one system.

Value of a European call option:

FinancialDerivative[{"European","Call"}, {"StrikePrice"-> 30.00, "Expiration"->1},  {"InterestRate"-> 0.01, "Volatility" -> 0.15, "CurrentPrice"-> 35, "Dividend"->0.0}]

Value and all Greeks of a European call option:

FinancialDerivative[{"European","Call"}, {"StrikePrice"-> 30.00, "Expiration"->1},  {"InterestRate"-> 0.01, "Volatility" -> 0.15, "CurrentPrice"-> 35, "Dividend"->0.0}, {"Value", "Greeks"}]

Compute the value given an expiration date of the contract:

FinancialDerivative[{"European","Call"}, {"StrikePrice"-> 50.00, "Expiration"->DatePlus[DateList[], 365]},  {"InterestRate"-> 0.1, "Volatility" -> 0.5, "CurrentPrice"-> 50, "Dividend"->0.05}]

List all the available contract types:

FinancialDerivative[]

An application example: plot the critical value surface of an American put contract:

ListPlot[{#,  FinancialDerivative[{"American", "Put"}, {"StrikePrice"-> 40.00, "Expiration"->1},  {"InterestRate"-> 0.09, "Volatility" -> 0.26, "CurrentPrice"-> 36, "Dividend"->0.07, "ReferenceTime"->#}, {"CriticalValue"}]}&/@Range[0,1, 0.05], Joined->True,InterpolationOrder->0, Filling->Axis, PlotRange->{25, 35}]

Financial visualization

Mathematica introduces new functions for finance visualization.

Let’s get some data using the MouseOver function.

cdata=FinancialData["IBM","RawClose", {{2008,7,1}, Date[],"Day"}];

We can now create a variety of charts for plotting price changes over time (used in trend analysis, for example).

KagiChart[cdata]

LineBreakChart[cdata]

RenkoChart[cdata]

PointFigureChart[cdata]

CandlestickChart[{"AAPL",{{2010,1},Date[]}},ImageSize->Large]

Interactive trading charts show price with automated financial indicators:

InteractiveTradingChart["AAPL"]

Image processing

Manipulate[Sharpen[,n],{n,1,10}]

New algorithms for real-time image acquisition and feature detection provide a complete and interactive workflow for image processing and analysis.

Real-time image acquisition

CurrentImage[]

Tyranno-vision (Tyrannosaurus Rex reportedly sees only moving images...)

Dynamic[ImageDifference@@CurrentImage[2]]

Face Detection

i=;
boxes=FindFaces[i,{50,∞}];
Show[i,Graphics[{EdgeForm[{Red,Thick}],Opacity[0],Rectangle@@@boxes}]]

Text Recognition

Convert an image of text to an expression and find the position of certain characters

TextRecognize[]
StringPosition[%,"or"]

Segmentation

WatershedComponents[]//Colorize

MorphologicalComponents[]//Colorize

Geometric transformations

Perspective transformations allow you to effectively view an image from another position and orientation.

A famous painting (“The Ambassadors” by Holbein). Can you find the hidden human skull?

Feature detection

Detect edges, lines, and key points.

EdgeDetect[,3]

img = ;
Show[img,Graphics[{Thick,Orange,Line/@ImageLines[Binarize[GradientFilter[img,1]],.2]}]]

Find and visualize matching points in two different images of the moon.

images={ ,};
matches=ImageCorrespondingPoints@@images;
MapThread[Show[#1,Graphics[{Yellow,MapIndexed[Inset[#2[[1]],#1]& ,#2]}]]&,{images,matches}]

Other

Many image effects and manipulations are possible.

lena=ExampleData[{"TestImage","Lena"}];
Grid[{
{ColorNegate[lena],ImageTake[lena,300],ImagePad[lena,15,Red]},
{Image[GraphicsGrid[ImagePartition[lena,25]],ImageSize->180],Image[ImageRotate[lena,45Degree]],ImageEffect[lena,"Charcoal"]},
{Dilation[lena,3],ImageApply[RotateRight,lena],ImageAdjust[lena,6]}
}]

Wavelets

With Mathematica, you can apply discrete or continuous high-performance wavelet analysis for thresholding and visualizing in any dimension.

Wavelet families

Many different wavelet families are supported:

wis=200;
fs=10;
Column[{
Row[{
Plot[WaveletPsi[HaarWavelet[],x],{x,-1,2},Exclusions->None,PlotLabel->Style["HaarWavelet",FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis],
Plot[WaveletPsi[DaubechiesWavelet[4],x],{x,-3,4},PlotRange->All,PlotLabel->Style["DaubechiesWavelet[n]",FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis],Plot[WaveletPsi[BattleLemarieWavelet[3,5],x],{x,-4,4},PlotRange->All,PlotLabel->Style[ToString@HoldForm@BattleLemarieWavelet[n],FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis]
}],
Row[{
Plot[WaveletPsi[BiorthogonalSplineWavelet[2,4],x],{x,-2,3},PlotRange->All,PlotLabel->Style[ToString@HoldForm@BiorthogonalSplineWavelet[n,m],FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis],Plot[WaveletPsi[CDFWavelet["9/7"],x],{x,-3,4},PlotRange->All,PlotLabel->Style[ToString@HoldForm@CDFWavelet,FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis],
Plot[WaveletPsi[CoifletWavelet[2],x],{x,-2,3},PlotRange->All,PlotLabel->Style[ToString@HoldForm@CoifletWavelet[n],FontFamily->"Arial",FontSize->fs], Filling->Axis,ImageSize->wis],
}],
Row[{
Plot[Evaluate[WaveletPsi[MeyerWavelet[2],x]],{x,-5,5},PlotRange->All,PlotLabel->Style[ToString@HoldForm@MeyerWavelet[n],FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis],
Plot[WaveletPsi[ReverseBiorthogonalSplineWavelet[2,4],x],{x,-2,3},PlotRange->All,PlotLabel->Style[ToString@HoldForm@ReverseBiorthogonalSplineWavelet[n,m],FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis],
Plot[WaveletPsi[ShannonWavelet[],x],{x,-5,5},PlotRange->All,PlotLabel->Style[ToString@HoldForm@ShannonWavelet,FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis],
}],
Row[{
Plot[WaveletPsi[SymletWavelet[4],x],{x,-3,4},PlotRange->All,PlotLabel->Style[ToString@HoldForm@SymletWavelet[n],FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis],
Plot[WaveletPsi[MexicanHatWavelet[1],x],{x,-5,5},PlotRange->All,PlotLabel->Style[ToString@MexicanHatWavelet[σ],FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis],Plot[{Re[WaveletPsi[GaborWavelet[1],x]],Im[WaveletPsi[GaborWavelet[1],x]]},{x,-5,5},PlotRange->All,PlotLabel->Style[ToString@GaborWavelet[w],FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis]}],
Row[{
Plot[WaveletPsi[DGaussianWavelet[10],x],{x,-5,5},PlotLabel->Style[ToString@DGaussianWavelet[n],FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis],Plot[WaveletPsi[MorletWavelet[],x],{x,-5,5},PlotRange->All,PlotLabel->Style[ToString@MorletWavelet,FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis],Plot[{Re[WaveletPsi[PaulWavelet[4],x]],Im[WaveletPsi[PaulWavelet[4],x]]},{x,-2,2},PlotRange->All,PlotLabel->Style[ToString@PaulWavelet[n],FontFamily->"Arial",FontSize->fs],Filling->Axis,ImageSize->wis]
}]
}]

What are wavelet transforms used for?

Wavelets localize noise and features in frequency and time simultaneously, allowing more selective filtering and analysis.

Column[{
Style["Example: removing one of two overlapping signals",FontFamily->"Arial",FontSize->14,Bold],
ListAnimate[{,,,,},AnimationRunning->False]
}]

Uniquely powerful wavelet computation

Mathematica’s wavelet functionality works on n-dimensional arrays and supports highly-optimized machine-precision arithmetic as well as infinite-precision computation – unlike other systems that are limited to 1D, 2D, or at most 3D arrays using machine precision.

Here is an example of something that is not possible in any other system: a 4-dimensional, 70-digit precision wavelet transform.

dwd=DiscreteWaveletTransform[RandomReal[1,{6,6,6,6},WorkingPrecision->70],WorkingPrecision->70]

Let’s view on of the wavelet coefficients:

dwd[{0,0,4}]

Transforms

Several different wavelet transform types are available: standard (DWT), lifting (LWT), and stationary (SWT), as well as packet versions (DWPT, SWPT).

Names["*Wavelet*Transform"]

Computing a DWT results in a WaveletRepresentation:

dwd=DiscreteWaveletTransform[{0,0,1,0,0},WorkingPrecision->∞]

dwd["TreeView"]

You can access many properties, including the transform coefficients at the different levels:

dwd[{0,0}]

You can also directly visualize the results:

data = Table[HeavisideLambda[x],{x,-2,2,4/1023}];
dwt = DiscreteWaveletTransform[data,DaubechiesWavelet[2],5,Padding->"Reflected"]

WaveletScalogram[dwt,{___,1},Method->{"Inverse"->True}, ColorFunction->"SolarColors",FrameTicksStyle->Directive[14],ImageSize->Medium]

Work directly with image and sound data.

dwt=DiscreteWaveletTransform[,Automatic,3]

WaveletImagePlot[dwt]

Application: compression

Suppose we have some data.

data=DiamondMatrix[32];

There are 4,225 elements in the matrix of which 2,113 are nonzero.

Count[data,_,{2}]

Count[data,_?(#≠0&),{2}]

However, we can express the matrix with a wavelet basis and only have 436 nonzero elements.

rdata=DiscreteWaveletTransform[data,Automatic,3];

Count[Last/@rdata[Automatic],_?(#≠0&),{3}]

And we can check to see that the data is well represented.

Norm[data-InverseWaveletTransform[rdata]]

Control theory

Symbolic and numeric control functions are streamlined and integrated into Mathematica, allowing you to:

analyze and design control systems using classical and state-space techniques

develop control systems for analog and digital systems

simulate models in open- and closed-loop configurations

Example: couple damped oscillators

Get a state space model from differential equations for coupled damped oscillators:

model=StateSpaceModel[{2 x2[t]-x3[t]+((3 x2'[t])/2)-((x3'[t])/2)+x2''[t]==F[t],-x2[t]+x3[t]-((x2'[t])/2)+((x3'[t])/2)+2 x3''[t]==0},{{x2[t],0},{x2'[t],0},{x3[t],0},{x3'[t],0}},{{F[t],0}},{x2[t],x3[t]},t]

Convert between state space representation and classical transfer function representation:

TransferFunctionModel[model]

We can ask questions about the system, such as, can the model be fully controlled with the specified input F[t]?

ControllableModelQ[model]

Simulate the model with varying driving frequency:

Plot[Evaluate[OutputResponse[model,Sin[2^(t/15)],{t,0,100}]],{t,0,100}]

Analyze the model by plotting frequency response gain for amplitude and phase:

BodePlot[model,GridLines -> Automatic,ImageSize->300,GridLinesStyle->GrayLevel[2/3]]

Combine with Mathematica’s 3D graphics, animation, and export capabilities:

Button[,SystemOpen[FileNameJoin[{NotebookDirectory[EvaluationNotebook[]],"SupplementalFiles","SpringMassDamperSystem.mov"}]]]

Visualization

Mathematica adds new visualization functions for control systems.

Bode plot:

Clear[s]

BodePlot[(20/(s+20)),GridLines -> Automatic,ImageSize->300,GridLinesStyle->GrayLevel[2/3]]

Root locus plot:

RootLocusPlot[k (((s^2)+2 s+4)/(s(s+4)(s+6)((s^2)+1.4s+1))),{k,0,150},ImageSize->300]

Nichols plot:

NicholsPlot[((10 s)/((s^3)+2 (s^2)+s+3)),NicholsGridLines->{{1,2,5,10},{20,10,5}},Mesh->8,MeshStyle->{AbsolutePointSize[5],Red},StabilityMargins->True,StabilityMarginsStyle->Directive[AbsoluteThickness[3],Orange],Frame->True,ImageSize->300]

Nyquist plot:

NyquistPlot[(z/((z-1)((z^2)+z+1))),SamplingPeriod-> 1,ImageSize->300]

Singular value plot:

SingularValuePlot[{{((2 s)/((s^2)+0.7)),(1/(s+4)),(1/s)},{(2/(s+1)),((s-1 )/(s+2)),(s/((s^2)+5))},{(1/(s+3)),(2/(s+4)),s}},ImageSize->300]

Graph theory

Mathematica includes support for interactive graph modeling and more than 150 new functions for graph computation.

Graph construction & computation

Build new graphs from existing ones.

GraphData["PetersenGraph"]

GraphComplement[]

Other operations include Cartesian product, lexicographic product, rooted product, tensor product, graph sum, graph difference, graph power, graph join, graph intersection, and graph union.

Find subgraphs

Highlight largest cliques (complete subgraphs) in random graphs:

Grid@Table[With[{g=RandomGraph[{10,30}]},HighlightGraph[g,Subgraph[g,First[FindClique[g]]]]],{3},{3}]

Find paths

Find the shortest paths between vertices in a graph:

g=PolyhedronData["GreatRhombicosidodecahedron","SkeletonGraph"]

path=PathGraph[FindShortestPath[g,19,30]];
HighlightGraph[g,path]

Find your way through a maze...

maze = ;

highlightMazePath[path_]:=Show[{Graphics[{GrayLevel[0.2],Rectangle[{-1.,-1.},{30.,20.}]}],maze,Graph[path,EdgeList[PathGraph[path]],VertexCoordinates->AbsoluteOptions[maze,VertexCoordinates][[2,VertexIndex[maze,#]&/@path]],VertexSize->0,EdgeStyle->Directive[Thickness[0.01],Red,Opacity[1],CapForm["Round"]]]},ImageSize->500]

highlightMazePath[FindShortestPath[maze,"in","out"]]

Neat example

Using built-in data lookup, image processing, and graph computation, we can build and analyze a road network, such as looking at a neighborhood on a city map.

image=WolframAlpha["Champaign IL",{{"Map:CityData",1},"Image"}];
graph=MorphologicalGraph[Binarize[ColorNegate[image]],EdgeStyle->Gray];
Row[{image,Spacer[20],HighlightGraph[graph,NeighborhoodGraph[graph,1800,10],ImageSize->{256,278},VertexSize->{1800->10}]}]

Wolfram SystemModeler

Large-scale system modeling is now possible with the coalescence of Mathematica and what was formerly MathModelica (more details in this blog post).

Modeling & simulation

create hierarchical, component-based models with individually testable and reusable sub-components

multi-domain modeling support to correctly simulate real-world systems that include parts from multiple physical domains instead of being restricted to a single domain

instant visualization to plot any system variable with a single click, and automatically animate 3D mechanical systems

built-in model libraries for mechanical systems, biochemical pathways, electronics, and more

Analysis & design with Mathematica

design in SystemModeler, and control simulations from Mathematica

calibrate and optimally fit model parameters by using native Mathematica functionality

describe a model with differential-algebraic equations and then analyze its properties

predict the effect of uncertainty in parameter values and discover the parameters that have the largest effect on system behavior

Case studies

Ford F350

style={FontFamily->"Arial",14,Bold};
TabView[{
Style["truck",style]->Show[,ImageSize->1->1],
Style["model",style]->Show[,ImageSize->1->1],
Style["simulation result",style]->Show[,ImageSize->1->1]
}]

Replacing rats: using simulations instead of live subjects for experimentation

style={FontFamily->"Arial",14,Bold};
TabView[{
Style["meal intake model",style]->Show[,ImageSize->1->1],
Style["model",style]->Show[ImageResize[,600],ImageSize->1->1],
Style["simulation result",style]->Show[ImageResize[,600],ImageSize->1->1]
}]

Gas turbine: test of operation

A single model can be created that combines:

a control system

an electrical grid

a fuels system

a turbine

a cooling system

style={FontFamily->"Arial",14,Bold};
TabView[{
Style["turbine",style]->Show[ImageResize[,500],ImageSize->1->1],
Style["model",style]->Show[ImageResize[,800],ImageSize->1->1],
Style["simulation result",style]->Show[ImageResize[,700],ImageSize->1->1]
}]

Demonstration of building models and simulating

DC Motor, Electric Kettle, Excavator

Demonstration of using Mathematica to control simulations

Electric Kettle

Excavator

Academic Initiatives

Mathematica

Long-term initiatives to help campuses go from specific machines to coverage for all campus machines plus unique flexibility for student machines

Wolfram|Alpha Pro

Many students license individually, new initiative to cover all students with consolidated agreement

Mathematica Online

Popular start with students just starting with Mathematica and individual licenses, just starting campus initiatives

Wolfram Technology System Starter

Initiative to skip “proof of concept” stage and give all students experience with newer products

Mathematica (with Wolfram-hosted download site)

Wolfram|Alpha Pro

Mathematica Online (with iOS and Android App when released)

Wolfram Programming Lab (when released)

Enterprise Edition of Mathematica

Applications using FreeCDF

Using the free CDF Player, anyone can interact with a computable document application built using Mathematica.  The application is saved as a FreeCDF file, which is then run by the user with the free CDF Player. The following example, which is on the Wolfram Demonstrations Project, varies the coefficients in an equation and then plots the result.

Manipulate[
Column[{
Row[{Style["Move the sliders to vary the coefficients in the equation, ", 14, RGBColor[0.027451, 0.00784314, 0.4], FontFamily->"Arial"],
Style["y =(a/b) x + c", 18, RGBColor[0.027451, 0.00784314, 0.4],FontFamily->"Arial"]}],
" ",
Style[Row[{"y = ",((ToString[a])/(ToString[b]))," x + ",c,}], 18,FontFamily->"Arial"],
Plot[(a/b) x+c,{x, -10, 10}, PlotRange-> {-10,10}, ImageSize-> 350]
}, Alignment->Center],
{a, 1,10,1},
{b, 1,10,1},
{c, 1,10,1}
]

Enterprise CDF Applications

Applications built with Enterprise CDF provide additional flexibility by allowing more types of input. For example, the following Enterprise CDF application can accept any equation as input. It varies dynamic variables linked to coefficients in the equation instead of using one hard-coded equation.  Rather than changing just coefficients, the entire equation can be changed to something like ‘Sin[a x]+b’ and the dynamic variables still work.

Panel[
DynamicModule[{eq1=x+5, eq2=x+5, a111=1, b111=1},
Column[{
Column[{
Style["Enter any equation using the symbols 'a' and 'b' as dynamic variables ", 14, RGBColor[0.0352941, 0.368627, 0.00784314]],
Row[{Style["Enter equation: ", RGBColor[0.027451, 0.00784314, 0.4]],InputField[Dynamic[eq1]]}],
Button["Update graph", eq2=eq1, ImageSize->150],
─
}],
Column[{
Row[{"a (1 to 5): ",Slider[Dynamic[a111], {1,5, 0.05}]}],
Row[{"b (1 to 5): ",Slider[Dynamic[b111], {1,5, 0.05}]}],
Dynamic[eq2/.{a-> a111, b->b111}],
Dynamic[Plot[eq2/.{a-> a111, b->b111}, {x, -10, 10}, PlotRange->{-10, 10},
PlotStyle->Directive[Thick,RGBColor[0.2,0.6,0.8]],
Filling->Axis,FillingStyle->Directive[Opacity[0.3],RGBColor[0.2,0.6,0.8]],
BaseStyle->{FontFamily->"Arial"},
ImageSize->400]]
}, Alignment-> Center]
}]
]
]

More Flexibility with Enterprise CDF Applications

Instead of numeric sliders, this application uses two points as input and then runs a check in the background to determine whether the plotted line matches the equation with random coefficients.

Panel[
DynamicModule[
{x,eq,pt1={2,0},pt2={3,0}, grade=""},
Column[{
Style["Instructions:", Blue],
"Graph the following equation by moving the points in the graph.\nClick \"Check Answer\" button to verify your answer.",
" ",
Column[{
Dynamic[With[{a=Coefficient[eq,x],b=Coefficient[eq,x,0]},Style[Row[{"y =",If[a==1||a==0,"",If[a==-1,"-",a]],If[a==0,"","x"],If[b>0&&a=!=0,"+",""],If[b==0,"",b]}],FontFamily->"Times",26]]],
"",
LocatorPane[Dynamic[{pt1, pt2}],
Dynamic[Plot[
If[Round[First[pt2]]===Round[First[pt1]],
20,
(Round[Last[pt2]]-Round[Last[pt1]])/(Round[First[pt2]]-Round[First[pt1]]) (x-Round[First[pt1]])+Round[Last[pt1]]], 
{x, -10, 10}, 
PlotRange->{-10, 10},PlotStyle->Thick,
GridLines->{Range[-10, 10],Range[-10, 10]},GridLinesStyle->LightGray,ImageSize->450, Background->White,
Epilog->{
PointSize[Large],
Point[
{Dynamic[{Round[First[pt1]],Round[Last[pt1]]}],{Round[First[pt2]],Round[Last[pt2]]}}
],
Text[Style[Dynamic[grade],FontFamily->"Arial",Red,Bold,60]]
}]], Appearance->None
],
" ",
Button["Check Answer", 
checker[eq, Simplify[((Round[Last[pt2]]-Round[Last[pt1]])/(Round[First[pt2]]-Round[First[pt1]])) (x-Round[First[pt1]])+Round[Last[pt1]]]], 
ImageSize->200],
Button["New Question", 
eq=(RandomInteger[{-10,10}]/RandomInteger[{1,10}]) x+RandomInteger[{-10,10}]; 
 grade="", ImageSize->200]
},Alignment->Center]
}],
 Initialization:>(
eq=(RandomInteger[{-10,10}]/RandomInteger[{1,10}]) x+RandomInteger[{-10,10}];
checker[eq_,answer_]:=
If[Expand[eq]===answer, grade="Correct", grade="Incorrect"]
)
]
]

Input Data Sets in Enterprise CDF

FreeCDF Version of Application

FreeCDF applications are limited to a hard-coded or randomly generated data set. For example, this application determines a fit for the data where you can alter the degree, but not the actual data.

Manipulate[
fits=Table[LinearModelFit[{{0.,0.},{1.,0.},{2.,0.3},{3.,0.7},{4.,1.1},{5.,1.7},{6.,2.8},{7.,4.1},{8.,5.9},{9.,8.1},{10.,11.3},{11.,13.6},{12.,15.1},{13.,16.},{14.,16.6},{15.,17.},{16.,17.3},{17.,17.5},{18.,17.6}},Table[(x^j),{j,0,i}],x],
{i,1,polydegree}];
plots=Table[
Show[ListPlot[{{0.,0.},{1.,0.},{2.,0.3},{3.,0.7},{4.,1.1},{5.,1.7},{6.,2.8},{7.,4.1},{8.,5.9},{9.,8.1},{10.,11.3},{11.,13.6},{12.,15.1},{13.,16.},{14.,16.6},{15.,17.},{16.,17.3},{17.,17.5},{18.,17.6}}],Plot[fits[[i]]["BestFit"],{x,0,100},PlotStyle->Red],
ImageSize->300,PlotLabel->"degree "<>ToString[i]<>" polynomial"<>"\n"<>"(r^2): "<>ToString[fits[[i]]["RSquared"]]],
{i,polydegree}]//Last,
{polydegree, 1, 5, 1}
]

Enterprise CDF Version of Application

Rather than being restricted to a hard-coded data set, the Enterprise CDF version of the application accepts any data set for calculating a fit.

Panel[
DynamicModule[{filename=Style["     none selected", 17], plots=Style["    no data set loaded", 17], deg=6},
Column[{
Style["Incremental Fit Application", 20],
Style["Provides degree 1 through max polynomial fits for data set with (r^2) values", Blue],
FileNameSetter[Dynamic[filename], Appearance-> "Choose File for Data Set"],
Style["Data set for analysis:", RGBColor[0.407843, 0, 0]],
Dynamic[filename],
─,
Row[{Style["Maximum degree for fit:   ", RGBColor[0.407843, 0, 0]],InputField[Dynamic[deg], FieldSize->4]}],
Button["Graphical Analysis of Best Fits",
If[StringTake[filename,-3]=="xls", dataFitApp[Import[filename][[1]], deg],dataFitApp[Import[filename, "Data"], deg]], ImageSize-> {200, 30}],
Dynamic[plots]
},Alignment->Center],
Initialization:>(dataFitApp[data_, polydegree_]:=
(fits=Table[LinearModelFit[data,Table[(x^j),{j,0,i}],x],
{i,1,polydegree}];
plots=Row[Table[
Show[ListPlot[data],Plot[fits[[i]]["BestFit"],{x,0,100},PlotStyle->Red],
ImageSize->300,Frame-> True,PlotLabel->"degree "<>ToString[i]<>" polynomial"<>"\n"<>"(r^2): "<>ToString[fits[[i]]["RSquared"]]],
{i,polydegree}],Frame->True,ImageMargins->10];
))]
]

Export Results with Enterprise CDF Applications

After uploading a data set and performing some analysis, a user running an Enterprise CDF application can export to any Mathematica supported format. The following example uses a simple image processing program to assign monetary value to uploaded coin images. A running tally of the values will be kept as additional images are uploaded. The buttons at the bottom of the application export the results.

Panel[
DynamicModule[{workingImage=, coinList={}, result=0, imageValues={0.75,0.45}, imageTally={}, incr=0.05,filename2=Style["     none selected"], exPlot=0, filePath="C:\\Users\\kelvinm\\Desktop\\"},
Column[{
Style["Enter Data Set for Next Measurement", RGBColor[0, 0, 0.435294], 18,FontFamily->"Times"],
FileNameSetter[Dynamic[filename2], Appearance-> "Choose Image"],
Dynamic[filename2],
─,
Button["Process Image", 
(workingImage=Import[filename2];count[workingImage];AppendTo[imageValues, result]), ImageSize-> 110],
Row[{Dynamic[workingImage],
"  ",
Dynamic[ArrayPlot[MorphologicalComponents[Binarize[workingImage]]]],
"      $",
Dynamic[result]
}],
" ",
─,
" ",
Style["Combination with Previous Measurements",RGBColor[0, 0, 0.435294], 18,FontFamily->"Times"],
Row[{
Dynamic[Histogram[imageValues, {0.3, 1.35, incr},Ticks-> {Automatic, Automatic}, ImageSize->300, Background-> White]],
Column[{
Row[{"Bin width for histogram:  ",Dynamic[incr]}],
Slider[Dynamic[incr], {0.01, 1, 0.01}],
"  ",
Row[{"  Number of measurements: ", Dynamic[Length[imageValues]]}],
Row[{"  Mean of measurements: ", Dynamic[Mean[imageValues]]}],
Row[{"  Median of measurements: ", Dynamic[Median[imageValues]]}]
}]
}],
─,
Row[{"File path for export: ", InputField[Dynamic[filePath], String]}],
Row[{
Button["Export Data TXT", Export[filePath<>"ImageProcessingAppTestData.txt", imageValues],ImageSize-> 200],
"  ",
Button["Export Data XLS", Export[filePath<>"ImageProcessingAppTestData.xls", imageValues],ImageSize-> 200],
"  ",
Button["Export Plot Image", Export[filePath<>"ImageProcessingAppPlotData.jpg", exPlot=Histogram[imageValues, {0.3, 1.35, incr},Ticks-> {Automatic, Automatic}, ImageSize->300, Background-> White];exPlot],ImageSize-> 200]
}]
}],
Initialization:>(count[image_]:=(imageTally=Select[Tally[Flatten[MorphologicalComponents[Binarize[image]]]][[All,2]], #>500&&#<10000&];
result=Total[Map[Length,Sort[FindClusters[imageTally,3]]]*{10,5,25}];
result=N[result/100, IntegerLength[result]]);)
],Background->GrayLevel[0.886275]
]

Development Workflow of an Enterprise CDF Application

Create the entire application in Mathematica.

Mathematica’s high-level language minimizes the time required to develop an application.

Use Enterprise Mathematica to create an Enterprise CDF file.

This is more of an encoding step rather than a compiling step. It’s as simple as selecting “Save As” from the file menu.

Post or send an Enterprise CDF file to end users.

Users only need to download the free CDF Player, which is the Mathematica kernel that powers the application.

What’s New in Mathematica 10

Code Assist

Built-in templates to create nicely formatted graphics and minimize plot options

Plot[Sin[x],{x,0,22},PlotTheme->"Detailed"]

Multiple Undo

Undo shows when the front end and the kernel state do not match by graying out output

Can change PlotTheme to Monochrome, plot grayed after clicking undo

Plot[Sin[x],{x,0,22},PlotTheme->"Detailed"]

Video showing this in action:  http://www.youtube.com/watch?v=r3DiJoUfC7s

Time Series

Specific time series object built in to represent a time series

temperatures=TimeSeries[];

DateListPlot[temperatures]

Model fit function built in for time series similar to working with other statistical models

tsm=TimeSeriesModelFit[temperatures]

Can create a time series forecast

DateListPlot[{tsm["TemporalData"],TimeSeriesForecast[tsm,{36}]}]

Graphs & Networks

New functionality for 3D graphs and networks

edges=EdgeList@GraphData["OctahedralGraph"];
{Graph[edges]Graph3D[edges,ImageSize->400]}

Graph[{1->2,2->1,1->4,1->4,2\[UndirectedEdge]3,3\[UndirectedEdge]2,3\[UndirectedEdge]4,2\[UndirectedEdge]4}]

All functions are integrated with each other, can use graph theory, image processing and optimization functionality together to find shortest tour between pixels in an image

monalisa = ;
monalisa=ColorQuantize[ColorConvert[monalisa,"Grayscale"],2];
pos=PixelValuePositions[ImageAdjust[monalisa],0];
res=FindShortestTour[pos];
Graphics[Line[pos[[res[[2]]]]]]

Image processing

Support for more types of color spaces

Grid[Partition[{
Labeled[Graphics3D[{EdgeForm[None],{LABColor[#],Cuboid[#,#+{.1,.2,.2}]}&/@Tuples[{Range[0,1,.2],Range[-1,1,.4],Range[-1,1,.4]}]},Axes->False,Lighting->"Neutral",BoxRatios->1,Ticks->None,Boxed->False],"LAB"],
Labeled[Graphics3D[{EdgeForm[None],{XYZColor[#],Cuboid[#,#+{.1,.2,.2}]}&/@Tuples[{Range[0,1,.2],Range[-1,1,.4],Range[-1,1,.4]}]},Axes->False,Lighting->"Neutral",BoxRatios->1,Ticks->None,Boxed->False],"XYZ"],
Labeled[Graphics3D[{EdgeForm[None],{LCHColor[#],Cuboid[#,#+{.1,.1,.1}]}&/@Tuples[{Range[0,1,.2],Range[0,1,.2],Range[0,1,.2]}]},Axes->False,Lighting->"Neutral",BoxRatios->1,Ticks->None,Boxed->False],"LCH"],
Labeled[Graphics3D[{EdgeForm[None],{LUVColor[#],Cuboid[#,#+{.1,.2,.2}]}&/@Tuples[{Range[0,1,.2],Range[-1,1,.4],Range[-1,1,.4]}]},Axes->False,Lighting->"Neutral",BoxRatios->1,Ticks->None,Boxed->False],"LUV"]
},2]]

{
i=ExampleData[{"TestImage","Mandrill"}],
ImageApply[{#[[1]],-#[[2]],-#[[3]]}&,ColorConvert[i,"LAB"]]
}

Enhancements to 3D image processing

Image3D[Table[Sin[x y z],{x,-3,3,.05},{y,-3,3,.05},{z,-3,3,.05}]]

MorphologicalComponents[%]//Colorize

Value Associative Arrays

Function Association to associate a color key with a string value

colors = Association[{"red"->,"green"->,"blue"->}]

colors[["green"]]

Structured Data

Enhanced formatting for data sets and better integration with units

planets=ExampleData[{"Dataset","Planets"}]

planets[All,"Moons",Length]

Semantic Data

Leverage Wolfram’s curated data when uploading a data set

FilePrint["ExampleData/buildings.dat"]

buildings=SemanticImport["ExampleData/buildings.dat","HeaderLines"->1]

buildings[1,"City"]

EntityValue[%,{"Population","Latitude"}]

Report Generation

Report templates built in to programmatically generate new notebooks for reports

Button["Show template",NotebookOpen[FindFile["ExampleData/BasicTemplate.nb"],Visible->True]]

template=NotebookTemplate["ExampleData/BasicTemplate.nb"];
report=TemplateApply[template,<|"author" -> "Bob Smith"|>];
SetOptions[report,Visible->True]

Machine Learning

New machine learning algorithms built in with super-function Classify

recognizeDigit=Classify[{->2,->0,->3,->5,->1,->3,->4,->1,->4,->1,->4,->1,->1,->2,->3,->0,->6,->6,->2,->7,->8,->1,->5,->2,->8,->5,->9,->4,->2,->6,->3,->1,->0,->4,->1,->9,->8,->8,->3,->3,->9,->5,->7,->5,->6,->4,->3,->2,->4,->0,->0,->7,->5,->0,->8,->6,->7,->3,->0,->3,->4,->7,->2,->4,->6,->4,->1,->6,->6,->8,->0,->6,->6,->8,->2,->8,->5,->4,->7,->9,->8,->8,->6,->8,->5,->2,->9,->0,->2,->5,->7,->5,->7,->8,->2,->5,->0,->3,->3,->3,->9,->4,->2,->0,->7,->9,->9,->2,->3,->8,->6,->3,->6,->1,->9,->3,->6,->6,->0,->7,->1,->2,->5,->1,->7,->7,->0,->9,->9,->4,->7,->0,->9,->1,->9,->8,->5,->1,->4,->1,->4,->2,->9,->5,->0,->7,->9,->8,->5,->7}]

Can use drawing tools to hand-write a number and run machine learning program to convert to an expression

recognizeDigit[ImageCrop@Binarize @ ]

Classify can also analyze a string of text and return the most likely language

Clear[text]

Classify["Language","Hello World","TopProbabilities"]

All functions in Mathematica work together, including dynamically writing a string of text and seeing the language probabilities change in real time

DynamicModule[{text=""},Column[{InputField[Dynamic[text],String,ContinuousAction->True,FieldHint->"Enter a string"],Dynamic[Classify["Language",text,"TopProbabilities"]]}]]

Geographic Computation

Find the nearest ocean and the distance to the coast

GeoNearest[Entity["Ocean"],Here]

GeoDistance[Here, First[%]]

Improved functionality for graphics related to geography

GeoGraphics[{
GeoStyling[Opacity[.5]],EdgeForm[Black],
Orange,Polygon/@{(Entity["United States", Entity["Country","UnitedStates"], "Entity[\"Country\", \"UnitedStates\"]", "country"]),(Entity["South Africa", Entity["Country","SouthAfrica"], "Entity[\"Country\", \"SouthAfrica\"]", "country"])},
thickarrow[{(Entity["Chicago", Entity["City",{"Chicago","Illinois","UnitedStates"}], "Entity[\"City\", {\"Chicago\", \"Illinois\", \"UnitedStates\"}]", "city"]),(Entity["London", Entity["City",{"London","GreaterLondon","UnitedKingdom"}], "Entity[\"City\", {\"London\", \"GreaterLondon\", \"UnitedKingdom\"}]", "city"]),(Entity["Moscow", Entity["City",{"Moscow","Moscow","Russia"}], "Entity[\"City\", {\"Moscow\", \"Moscow\", \"Russia\"}]", "city"]),(Entity["Johannesburg", Entity["City",{"Johannesburg","Gauteng","SouthAfrica"}], "Entity[\"City\", {\"Johannesburg\", \"Gauteng\", \"SouthAfrica\"}]", "city"])},3,2,{4,0.03}],
Blue,Polygon/@{(Entity["Chile", Entity["Country","Chile"], "Entity[\"Country\", \"Chile\"]", "country"]),(Entity["India", Entity["Country","India"], "Entity[\"Country\", \"India\"]", "country"])},
thickarrow[{(Entity["Santiago", Entity["City",{"Santiago","Metropolitana","Chile"}], "Entity[\"City\", {\"Santiago\", \"Metropolitana\", \"Chile\"}]", "city"]),(Entity["Mexico City", Entity["City",{"MexicoCity","DistritoFederal","Mexico"}], "Entity[\"City\", {\"MexicoCity\", \"DistritoFederal\", \"Mexico\"}]", "city"]),(Entity["Oslo", Entity["City",{"Oslo","Oslo","Norway"}], "Entity[\"City\", {\"Oslo\", \"Oslo\", \"Norway\"}]", "city"]),(Entity["Dubai", Entity["City",{"Dubai","Dubai","UnitedArabEmirates"}], "Entity[\"City\", {\"Dubai\", \"Dubai\", \"UnitedArabEmirates\"}]", "city"]),(Entity["New Delhi", Entity["City",{"NewDelhi","Delhi","India"}], "Entity[\"City\", {\"NewDelhi\", \"Delhi\", \"India\"}]", "city"])},6,2,{4,0.05}],
Darker[Green],Polygon/@{(Entity["Australia", Entity["Country","Australia"], "Entity[\"Country\", \"Australia\"]", "country"]),(Entity["Spain", Entity["Country","Spain"], "Entity[\"Country\", \"Spain\"]", "country"])},thickarrow[{(Entity["Sydney", Entity["City",{"Sydney","NewSouthWales","Australia"}], "Entity[\"City\", {\"Sydney\", \"NewSouthWales\", \"Australia\"}]", "city"]),(Entity["Tokyo", Entity["City",{"Tokyo","Tokyo","Japan"}], "Entity[\"City\", {\"Tokyo\", \"Tokyo\", \"Japan\"}]", "city"]),(Entity["Moscow", Entity["City",{"Moscow","Moscow","Russia"}], "Entity[\"City\", {\"Moscow\", \"Moscow\", \"Russia\"}]", "city"]),(Entity["Madrid", Entity["City",{"Madrid","Madrid","Spain"}], "Entity[\"City\", {\"Madrid\", \"Madrid\", \"Spain\"}]", "city"])},4,2,{3,0.05}]
},GeoRange->All,ImageSize->800]

Including mixing geographic data with measured and imported data

GeoGraphics[{GeoMarker[GeoPosition[{50.1174328,8.6272909}],EntityValue[(Entity["rhombic hexecontahedron", Entity["Polyhedron","WolframAlphaPolyhedron"], "Entity[\"Polyhedron\", \"WolframAlphaPolyhedron\"]", "polyhedron"]),"Image"]],PointSize[0.01],Blue,Point/@morningRunData,Red,Line[morningRunData]},GeoRange->(QuantityUnit[700]),ImageSize->800]

Geometric Computation

Support for computational geometry

reg=RegionDifference[RegionUnion[Disk[{0,0},1],Rectangle[{0,0},{2,2}]],Disk[{0,0},7/10]];
RegionPlot[reg,AspectRatio->Automatic]

RegionMeasure[reg]

Real-time computation of the minimum distance between a point and the nearest coast of Italy

italyRegion=DiscretizeGraphics[CountryData["Italy","Polygon"]]

Manipulate[Show[{italyRegion,Graphics[Arrow[{pt,RegionNearest[italyRegion,pt]}]]}],
{{pt,{11.7,39.9}},Locator}]

Another example of all functions being nicely integrated, including curated data, computational geometry, and integration

Integrate[1,{x,y}∈]

Version 10 extends numerical differential equation-solving abilities to include the finite element method

sol=NDSolveValue[{(InactiveLaplacian[u[x,y,z], {x,y,z}, Inactive])==0,
DirichletCondition[u[x,y,z]==1,z≤-1.3]},u,
{x,y,z}∈];
NDSolve`FEM`ElementMeshSurfacePlot3D[sol,Boxed->False,ViewPoint->{0,-4,2}]

Initialization

Drawing Tools

SetOptions[$FrontEndSession,
NewPrimitiveStyle->{Arrowheads->0.03`,Dashing->None,CapForm->"Square",JoinForm->{"Miter",3.25`},LineColor->Black,LineOpacity->1,EdgeColor->Black,EdgeOpacity->1.`,EdgeThickness->Absolute[28],EdgeDashing:>None,EdgeCapForm:>"Square",EdgeJoinForm:>{"Miter",3.25`},FrontFaceColor->,BackFaceColor->,FrontFaceOpacity->1,BackFaceOpacity->1,GraphicsColor->,PointSize->Absolute[3],Thickness->Absolute[27.542287033381662`],Opacity->1,DrawEdges->True,DrawFrontFaces->False,DrawBackFaces->True,Background->,RectangleBoxOptions->{RoundingRadius->0.`}}
]

ThickArrow

thickarrow[l_,t_,m_,{w_,δ_}]:=Module[{f,M=200,l1=l/.e_Entity:>EntityValue[e,"Coordinates"]/.GeoPosition[s_]:>s},f=BSplineFunction[Append[Flatten[Table[#1+k/m (#2-#1),{k,0,m-1}]&@@@Partition[l1,2,1],1],Last[l1]]];
{GeoStyling[Opacity[.8]],Polygon[GeoPosition[Join@@(#1[Table[f[s]+#2 If[s<1-δ,1,w (1-s)/δ] t Normalize[Reverse[f'[s]] {-1,1}],{s,0,1,1/M}]]&@@@{{#&,1},{Reverse,-1}})]]}];

What’s New in Mathematica 9

Wolfram Predictive Interface

Intelligent auto-completion and highlighting for functions, options, and other elements of Mathematica to help with input entry.

Suggestions Bar

When you finish an evaluation, the Suggestions Bar appears and gives smart suggestions for your next steps. Intelligently build on top of previous actions, explore new areas of Mathematica’s functionality, and roll-up your code when finished to create a single input.

Social network analysis

Access social network information from Facebook, Twitter, LinkedIn, and Google+ to use with the rest of Mathematica’s computation and visualization capabilities.

CommunityGraphPlot[SocialMediaData["Facebook","FriendNetwork"]]

SocialMediaData["Facebook", "ActivityRecentHistory","FormattedData"]

SocialMediaData["Facebook", "ActivityWeeklyDistribution", "FormattedData"]

Systemwide support for units

Support for thousands of units, integrated throughout the system with a new Quantity framework. Units are resolved automatically or can be converted explicitly.

Use free-form input to handle unit conversion

LinguisticAssistant+LinguisticAssistant+LinguisticAssistant

Use the Quantity framework

The Quantity framework can be used to compute with and compare units, or for conversion.

Quantity[3,"Feet"]+Quantity[2,"Inches"]

Quantity[3,"Feet"]<Quantity[1,"Meters"]

UnitConvert[Quantity[3,"Feet"],"Meters"]

dataset1=Table[Quantity[RandomReal[{0,1}],(("Grams")/(("Centimeters")^3))],{25}];
ListLinePlot[dataset1,AxesLabel->Automatic,Filling->Axis,PlotLabel->"Hardwood Density",BaseStyle->FontSize->16]

Built-in integration with R

Integrate R code into your Mathematica workflow. Execute R code directly from Mathematica using the new RLink.

Example

Load the built-in RLink library (requires installation of R to work).

Needs["RLink`"]
InstallR[]

You can create expressions using Mathematica, as you normally would.

x=Range[10];
y=2*x+RandomReal[{0,1},10];

Use your Mathematica expressions when running R routines.

lmfit=RFunction["function(x,y){
	lmfit <- lm(y~x)
	lmfit$coeff
}"][x,y]

The R routine has been mapped to a Mathematica command, which can now be used with the other parts of the Mathematica system, like visualization.

Show[{ListPlot[Transpose@{x,y}],
Plot[lmfit[[1,1]]+z*lmfit[[1,2]],{z,x[[1]],x[[-1]]},PlotStyle->Red]}]

3D volumetric image processing

Image processing is extended to 3D datasets, including pixel operations, local filtering, morphology, and more. In addition to 3D surface rendering, fast and interactive volume rendering is available.

Example

Construct a 3D image from a list of image slices.

Import["ExampleData/CTengine.tiff","Image3D"]

Construct a 3D image slicer.

With[{i=,size=100},
Manipulate[Grid[{#&/@{Show[Image3DSlices[i,{s},1][[1]],Graphics[{Red,Line[{{c,0},{c,size}}],Line[{{0,size-r+1},{size,size-r+1}}]}]],
Show[Image3DSlices[i,{r},2][[1]],Graphics[{Red,Line[{{c,0},{c,size}}],Line[{{0,size-s+1},{size,size-s+1}}]}]],
Show[Image3DSlices[i,{c},3][[1]],Graphics[{Red,Line[{{r,0},{r,size}}],Line[{{0,size-s+1},{size,size-s+1}}]}]]}}],
{s,1,size,1},{r,1,size,1},{c,1,size,1}]]

Other functionality

Plot legends

Built-in plot legends, with complete control over styling, placement, and labeling.

Plot[{Sin[x],Cos[x]},{x,-2π,2π},PlotLegends->"Expressions"]

ContourPlot[Sin[x y],{x,-π,π},{y,-π,π},PlotLegends->Automatic]

Legends match the styling of the graph.

d = {{14, 10, 19, 19, 15, 16, 21, 24}, {12, 17, 26, 31, 29, 38, 44, 
    48}, {15, 22, 36, 51, 51, 66, 68, 82}, {13, 22, 45, 67, 66, 79, 
    84, 98}};
markers = {{, 0.04}, {, 0.04}, {, 0.05}, {, 0.04}};
ListLinePlot[d,PlotMarkers->markers,PlotStyle->(Directive[AbsoluteThickness[4],#]&/@ColorData[64,"ColorList"]),ImageSize->400,Filling->{1->{2},2->{3},3->{4}},AxesOrigin->{0,0},PlotLegends->PointLegend[Row[{"l",#1}]&/@Range[4],LegendMarkerSize->20,LabelStyle->{GrayLevel[0.3],Bold,16}]]

Interactive gauges

New plot gauges that automatically pick up values and units.

Dynamic[Refresh[ClockGauge[],UpdateInterval->1]]

Many styling options are available.

Grid@Partition[Table[Column[{Style[t,FontFamily->"Arial"],AngularGauge[5.5,{0,10},PlotTheme->t,ImageSize->170]},Center],{t,{"Metal","DarkOrange","Dark","AntiqueCopper","NeonBlueKnob","Minimal1","Minimal2","Minimal3","Minimal4","Minimal5","Minimal6","MinimalHalf1","MinimalHalf2","MinimalHalf3","MinimalHalf4","MinimalHalf5","MinimalHalf6","VintageMilitary","VintageMilitaryDark","Speedometer","SpeedometerDark"}}],3,3,1,{}]

Use gauges with other components.

Manipulate[Plot[{Sin[a x],Cos[b x]},{x,0,4 π},ImageSize->300],{{a,1},0,4,AngularGauge[##1,ImageSize->100]&},{{b,1},0,4,AngularGauge[##1,ImageSize->100]&},ControlPlacement->Left]

Web access support

Symbolic tensors

Random processes

Reliability analysis

Markov chains and queues

Survival analysis

New import and export formats

New slide shows templates

Next Steps

Sign-in sheet

I’ll send these examples within about a day (based on sign-in sheet)

Can share other examples more specific to courses

Can give advice on how to install products, or how to consolidate licensing

Resources

Wolfram Community for networking with other users and sharing ideas

MouseOver for materials such as courseware

Demonstrations Project to download existing models and examples

MouseOver for mathematics information

Initialization

Color

Clear[m8red];
m8red[a_]:=RGBColor[0.811765,0.117647,0.145098,a];

C Compiler

Needs["CCodeGenerator`"]

Special Cells

Picture Cell

PicturePrint[expr_,opts:OptionsPattern[Cell]]:=CellPrint[TextCell[expr,"Picture",opts,ShowStringCharacters->False]]

Overview Mouseover

OverviewMouseover[header_,subs_]:=CellPrint@Cell[BoxData[ToBoxes@Mouseover[Framed[Style[header,"OverviewSection"],FrameMargins->{{15,15},{5,5}},BoxFrame->2,FrameStyle->None,RoundingRadius->5],

Evaluate@If[subs=="",Framed[Style[header,"OverviewSection",White],FrameMargins->{{15,15},{5,5}},BoxFrame->2,FrameStyle->None,RoundingRadius->5,Background->m8red[1]],Row[{Framed[Style[header,"OverviewSection",White],FrameMargins->{{15,15},{5,5}},FrameStyle->None,RoundingRadius->5,Background->m8red[1]]," » ",Framed[Style[subs,"OverviewSection"],FrameMargins->{{15,15},{5,5}},FrameStyle->m8red[1],BoxFrame->2,RoundingRadius->5,Background->White]}]]]],"OverviewSection"]

(*MapThread[OverviewMouseover,Transpose[{{"Chapter One","Chapter One topics, …"},{"Chapter Two","Chapter Two topics, …"},{"Chapter Three","Chapter Three topics, …"},{"Chapter Four","Chapter Four topics, …"}}]]*)

Large Overview Mouseover

LargeOverviewMouseover[header_,subs_]:=CellPrint@Cell[BoxData[ToBoxes@Mouseover[Framed[Style[header,"LargeOverviewSection"],FrameMargins->{{15,15},{5,5}},BoxFrame->2,FrameStyle->None,RoundingRadius->5],

Evaluate@If[subs=="",Framed[Style[header,"LargeOverviewSection",White],FrameMargins->{{15,15},{5,5}},BoxFrame->2,FrameStyle->None,RoundingRadius->5,Background->m8red[1]],Row[{Framed[Style[header,"LargeOverviewSection",White],FrameMargins->{{15,15},{5,5}},FrameStyle->None,RoundingRadius->5,Background->m8red[1]]," » ",Framed[Style[subs,"LargeOverviewSection"],FrameMargins->{{15,15},{5,5}},FrameStyle->m8red[1],BoxFrame->2,RoundingRadius->5,Background->White]}]]]],"LargeOverviewSection"]

SetDirectory

SetDirectory@NotebookDirectory[];

$Line

$Line=0;