UcenlyOpen in the app

Mathematical Applications · BE5B15MAA · Topic 13 of 13

Examples of advanced use of Mathematica

Week 13. Real tasks combine fitting, optimization, data import and a handful of solvers.

Open the interactive lesson

Key ideas

Fitting and optimization

Fit[data,{1,x,x^2},x] finds the least-squares combination of the given basis functions. Minimize[f,x] works symbolically and NMinimize numerically; for a model fit, build the squared-error sum and minimise it over the parameters. Define such an objective with Module-local symbols so that earlier definitions cannot disturb it.

Importing and selecting data

SetDirectory[NotebookDirectory[]] points to the notebook folder, then Import["data.csv"] reads a file and Export writes one. data[[;;,3]] takes a column, Cases and Select with a pure-function test pick rows, and Mean, Total and StandardDeviation summarise them.

Typical test tasks

The past tests ask for the same toolbox again and again: a styled ListPlot, a Fit, an Interpolation of order 2, Manipulate with a PolarPlot, FindRoot for two equations, Solve for unknown circuit parameters, NDSolve with ParametricPlot, and a function that returns a message when no solution exists.

In one line: A typical task is three steps: get the data, fit or solve, and show it with a plot and a Print line.

Formulas

Sources

Written by Ucenly. Based on the BE5B15MAA course materials: