Math Minion Examples
A few interesting uses of Math Minion..

Pressure Drop Tutorial
Tutorial

This tutorial works through some basic Math Minion techniques while calculating the pressure drop of water flowing through a pipe.  If you haven't reviewed the information in the top few items in the Getting Started session, you might want to start there first.

The instructions  are in the notes of the models named Step_1, Step_2 etc. that are stacked along the left side of the diagram.

In addition to the instructions for that step, each model also contains the example completed to that point for you to compare with or copy from.  Tap the icon with the three connected blobs to view the model diagram for that step.

If you would like to follow the step by step notes outside of Math Minion, they are reproduced here.

Using Indexof to Look Up Table Values
Data Handling

Illustrates using the indexof function to do table look ups. In this case looking up names and share holdings in one table by using the company symbols in a second table.

ODE Example - Predator/Prey
Dynamic Modeling

This example illustrates the use of the ODE solver simulate the classic predator/prey relationship as characterized by the Lotka-Volterra model.

See wikipedia.org/wiki/Lotka-Volterra_equation.

The calculation is contained in the Population model, with the results illustrated in the two Plot objects.

Mathworks has a published demonstration of this problem (look for "Numerical Integration of Differential Equations" in the demos section of the mathworks.com website). The Math Minion solution to this problem is reproduced in the MatlabExample model.

Orbits
Dynamic Modeling

This models the orbital motion of 2 or more planets around a sun. It is a simplification of one of Marco M's wonderful models and as such, any mistakes are almost certainly once again mine.

For simplicity all of the planet masses are assumed to be equal, although this could be relaxed at the expense of slightly more complicated equations.

As set up, there are only two massive planets in close orbits. The large mass 1000 ME (earth mass) was chosen in order to have visible effects very quickly and their initial positions and velocities result in them orbiting around each other while orbiting the central sun.  Small changes to their orbital velocities will result in significant changes.

Note that two custom units ME (earth mass) and AU (astronomical unit) are used in this session.

To run the simulation, Tap on the ode icon and tap the reset and then run buttons. After the calculations complete, have a look at the Plot_xy and Plot_local_xy graphs. Try zooming in on interesting features and viewing the graph full screen if you are on an iPad.

Then try changing the leading 1.0 in the  InitialVx expression to 1.1 and rerun the simulation.

Friction Factor vs Reynolds
Engineering

Friction factors are determined by solving the Colebrook equation for a range of Reynolds numbers and roughness over diameter factors.

To calculate and view the plot, go to the Friction_Factor plot and tap the plot button.

If you want an operating point displayed, enter the appropriate values in OperatingF and OperatingRe.

The friction factors are determined by solving the Colebrook equation for a range of Reynolds numbers and roughness over diameter factors.

McCabe Thiele
Engineering

This is a partial port of a McCabe Thiele Excel spreadsheet written by my good friend, Marco Satyro, for teaching purposes.

The spreadsheet made extensive use of the VBA programming language and my purpose was to see if Math Minion could implement the key aspects of the calculations just using its formulas.

The math and science behind this are all Marco's and the errors and omissions I undoubtedly introduced are all mine.

Steam Turbine
Engineering

Given:

  • inlet temperature
  • inlet pressure
  • outlet pressure
  • mass flow
  • isentropic efficiency

this model calculates the power, outlet temperature and polytropic efficiency of a steam turbine.

It uses copies of models from the Steam97 Tools example, which in turn use steam correlations taken from the "IAPWS Industrial Formulation 1997 for the Thermodynamic Properties of Water and Steam" document.

Of course and as always, there are zero guarantees of correct implementation.

Steam97 Form
Engineering

Water and steam properties are calculated using correlations taken from the International Association for the Properties of Water and Steam as defined in this document.

These are presented in HTML forms using temperature/pressure, pressure/enthalpy, pressure/entropy as inputs as well as one that calculated saturated vapour and liquid properties for a specified temperature or pressure.

Tap the question mark beside the title in each form for usage notes.

Steam97 Tools
Engineering

Uses the same International Association for the Properties of Water and Steam correlations as the Steam97 Form example, but just as four models that can easily be copied and pasted into other problems. The models are:

  • SatLine - Calculates the saturation temperature and saturation pressure for the corresponding T and P inputs.
  • TPCalc - Calculates water properties at the given input temperature and pressure.
  • PHCalc - Calculates water properties at the given input pressure and enthalpy.
  • PSCalc - Calculates water properties at the given input pressure and entropy.

Steam97 Validation
Engineering

Uses the same models as in the Steam97 Forms and Steam97 Tools examples, but attempts to validate the calculations against examples from the "IAPWS Industrial Formulation 1997 for the Thermodynamic Properties of Water and Steam" document.

Financial Functions
Financial

This session contains a number of financial functions implemented as MM models. These are the types of things (present value, internal rate of return, depreciation etc.) that are often found in spreadsheet function libraries, but I thought it might be more useful and instructive to just construct them from Minion objects. Your thoughts and suggestions on this are of course welcome.

Some also have HTML form objects to illustrate how to create user interface objects for common calculations.

Portfolio Tracker
Financial

A simple portfolio value tracker that gets values from Yahoo. A form allows a one tap update and comparison with recent values. Although it is mainly intended to demonstrate some string handling and form techniques, it could be customized for personal use and in fact I use something similar myself.

The stock holdings are in a table in the Portfolio model as is the mechanism for getting values. Replace the demo values with your own if you want to use this app.

The MktValues table contains faked results for demonstration and you should replace it with the empty EmptyValues table if starting with your own portfolio.

Taylor Series Expansion
Math

Series expansion is a common mathematical tool for approximating functions that cannot be directly calculated. This example will show how Math Minion's matrix object can be used to easily implement a series expansion, specifically a Taylor series to calculate e^x and sin(x).

See the notes for each of the objects.

A generated text report is available here.

Steps
Miscellaneous

This uses the steps function to access the M7 coprocessor introduced in the iPhone 5s and presents a form that allows you to keep a record ofyour daily steps.

It also makes use of a number of other features introduced in version 2.5.6, including JQuery Mobile, the graph's abiliity to generate Scalable Vector Graphics for inclusion in HTML forms and new javascript functions for communicating with the Math Minion calculation engine.

Triangulate with Optimizer
Optimizing

This example uses the optimizer to calculate the best estimate of the location of a receiver, given approximate distances to a number of transmitters of known location.

For simplicity, everything is assumed to be on a single 2D surface.

Foot Inch Calculator
String Handling

Implements a four function calculator for foot, inch fraction format.

This uses the javascript bridge feature introduce in 2.5.3 to allow a smooth connection between the form and the underlying Math Minion calculations.

Both the Math Minion models and the form code are heavily commented.

Note that is intended for use on iOS. If you want to use it on a Mac, you should change all the onTouchStart calls in the Form html code to onClick instead.

Format Time
String Handling

This example contains a model that accepts a time value, in seconds since the beginning of 1970, and calculates integer values for the different date and time parts as well as formatted date and time strings.

You can create sessions from models like these and keep them in a session folder to copy and paste into models as needed.

Numbers with Commas
String Handling

Illustrates a formula that formats numbers with comma separators for thousands. Only for numbers less than one billion, but could be extended.

Web Get Funds
String Handling

Unfortunately Yahoo! does not provide CSV formatted results for Canadian mutual funds. This is rather unfortunate for me, being Canadian, but provides an excuse to show how the wget command can be used to retrieve an array of web pages, which can then be manipulated with Math Minion's string tools to extract the desired information.

Note that page scraping depends on the format of the pages and this method is likely to break when the pages are redesigned. Also, at the time of this writing, Yahoo Canadian fund updates are not always up to date, but the example should still be illustrative.

Web Get Stocks
String Handling

The wget function can be used to retrieve web pages as strings. Here it is used to get stock quotes from Yahoo in comma separated value format and process them into a quote table.