The CALC 1 Function Calculators provide a consistent and efficient solution to a wide range of financial, business, probability and statistical problems. You can also easily create a graph of the function by entering the range and selecting the independent variable. Solving for a parameter allows you to perform breakeven analysis for any parameter of any function.
The CALC 1 Function Calculators are built on a standard JavaScript function.
From MDN:
Functions are one of the fundamental building blocks in JavaScript. A
function is a JavaScript procedure—a set of statements that performs a
task or calculates a value.
CALC 1 Function Calculators require that the parameters and the return value be a Number. (An integer or floating point number. For example: 42 or 3.14159.)
A simple example of a JavaScript for a Function Calculator would be:
function oneMinusX( x ){
return 1 - x);
}
To call it:
let y = oneMinus(.89);
and it will return 0.11 to variable y.
A more typical example would be the function for the Economic Order Quantity Function Calculator:
function economicOrderQuantity(demand, fixedCostPerOrder, costPerUnit, carryingCostPct){
return Math.sqrt(2 * demand * fixedCostPerOrder / (costPerUnit * carryingCostPct / 100));
}
The function saves you from having to enter an expression with 4 variables, 5 operators, parenthesis and the square root function.
Functions can contain multiple statements (these example one have the one statement in the body) including if statements, while loops, switch statements, do while loops, and call other functions.
Simple functions can be created by using the algebraic (ALG) calculation mode to enter an expression using 'rgx'. The oneMinusX example, evaluate the expression, '1-rgx'. Then navigate to the History Detail for that expression and tap the 'Create fn' key. Enter 'oneMinusX' as the function name and tap OK. The Function Calculator is automatically created.
For functions that consist of more parameters or more expressions, the preferred method to create a Function Calculator is to write the function, copy it to the clipboard and then import it from the Function Calculator List.
See Debugging JavaScripts For CALC 1 for more information on the tools available for developing scripts.
The JavaScript function provides the minimum for a Function Calculator. After creating the Function Calculator use the Function Calculator Editor to customize the key labels, provide a description for the parameters and the function and more.
Use the Share actions to save your custom calculators to your iCloud drive or Message, Mail and more. Saving your calculator to your iCloud drive provides a backup of your custom calculator.
Many times it is more efficient to duplicate an existing Function Calculator to customize it to your requirements.
Left swipe on the Function Calculator you want to duplicate and select "Duplicate".
Use the Function Calculator Editor to edit the title, description, function name, parameters and body of the function.