Introduction to Polymath

Welcome to POLYMATH 6.2

POLYMATH 6.X

Numerical Solutions for Scientific and Engineering Mathematical Problems

Polymath has four major programs:

for simultaneous Linear Equations:

for simultaneous Nonlinear Equations:

for simultaneous Ordinary Differential Equations:

for Curve Fitting and various Regressions:

with Student and Professional versions:

Module | Limitation | Educational Versions | Professional Version
POLYMATH | Min # of represented digits | 9 | 8
POLYMATH | Max # of represented digits | 20 | 22
LEQ | Max # of simultaneous linear equations | 100 | 264
NLE | Max # of simultaneous nonlinear equations | 30 | 300
NLE | Max # of simultaneous explicit equations | 40 | 300
DEQ | Max # of simultaneous differential equations | 30 | 300
DEQ | Max # of simultaneous explicit equations | 40 | 300
DEQ | Max # of intermediate data points | 151 | 1200
REG | Max polynomial regression degree | 5 | 12
REG | Max nonlinear regression model variables | 60 | 60
REG | Max nonlinear regression independent variables | 60 | 60
Data Table | Max # of rows (data points) | 301 | 1001
Data Table | Max # of columns | 50 | 200

Polymath now includes:

  • New full screen editor with with color coding and many new and improved features...

  • More Graphical Output Controls...

  • Automatic Export of Polymath Programs to Excel that will execute completely within Excel...

  • New Unique Excel Add-In for Differential Equations...

that gives User Control over the Numerical Solution Algorithm...

and Output Results...

  • New Capability to Produce MATLAB m Files from Polymath Nonlinear and Differential Equation Solvers

Matlab formatted m file for Nonlinear Equation Solver - Example 3

xguess = [0.04 0.004]; % initial guess vector
function fx = MNLEfun(x);
D = x(1);
fF = x(2);
%Temperature (K)
T = 25 + 273.15;
%Liquid density (kg/cu-m)
rho = 46.048 + T * (9.418 + T * (-0.0329 + T * (4.882e-5 - T * 2.895e-8)));
pi = 3.1416;
%Flow rate (cu-m/s)
q = 0.0025;
%Pressure drop (Pa)
dp = 103000;
%Pipe length (m)
L = 100;
%Liquid viscosity (Pa-s)
vis = exp(-10.547 + 541.69 / (T - 144.53));
%Flow velocity (m/s)
v = q / (pi * D ^ 2 / 4);
%Reynold's number
Re = D * v * rho / vis;
%Calculation of pipe diameter for specified flowrate (D in m)
fx(1,1) = dp - 2 * fF * rho * v * v * L / D;
%Fanning's friction factor
if (Re < 2100)
fx(2,1) = (fF - 16 / Re) ;
else
fx(2,1) = (fF - 1 / (4 * log10(Re * sqrt(fF)) - 0.4) ^ 2);
end

  • Advanced Calculator

  • Enhanced Unit Converter...

  • Expanded Scientific and Engineering Constants...


Getting Started

See Also: Variables and Expressions

The main display for Polymath provides the user with a variety of choices for problem solving. The main options are under the Program drop-down menu:

These major programs are alternately activated by clicking the mouse on the appropriate icon:

An input screen becomes available whenever a program is started. For example, both the Nonlinear Equation Solver and the Differential Equations Solver open to full-screen editors when equations can be entered directly or with the use of buttons on the screen:

Each program has an Examples pull-down menu that can be used to bring an example problem into the Polymath editor:

Click on the following links for more information on Linear Equations Solver, Nonlinear Equations Solver, Differential Equations Solver, or Regression Package.

To the right of the program icons are the icons for the Polymath utilities. The utilities create pop-up windows for specialized use such as the Units Converter shown below:

Other utilities include a Scientific Calculator and a Scientific Constants Database. At the far right of the top menu are icons that provide user input to Polymath and detailed Polymath Help.


Variables and Expressions

See Also: Calculator Nonlinear Equations Solver Differential Equations Solver

Expression Structure

The following objects compose a valid Polymath math expression:

Expression Objects | Description | Examples
Number A number can be represented in decimal notation or engineering notation. Engineering notation can be used to indicate powers of 10 using 'e' or 'E' for example, 0.123e-5 is the same as 0.123*10^(-5).
Note that only the period "." is used as the decimal delimiter symbol and comma nor spaces must not be used to indicate digits grouping. 		1.0, 2300, 5E-7, 1.23E+9, 34.0046

Invalid Polymath numbers:
5,000.00
12,9
12 000 000
Variable name | Variable names must begin with an alphabetical character and can contain alphabetic and numeric characters or underscore “_”. Variable names are case-sensitive, i.e. 't' and 'T' are two different variables. Special characters such as $, &, #, @ etc. are not allowed. | x1, x2, A12, T, tm4eee, VH2O, PmmHg, KL_1
Arithmetic operator Returns the arithmetic operations of the binary components.
For example '2+3' returns 5
The '^' symbol is used for exponentiation. The +, -, *, / symbols are used for addition, subtraction, multiplication, and division respectively. The precedence of operators is ^, (* or /), (+ or -) which is invoked working from left to right in an expression. 		+, -, *, /, ^

(1 + 2 * 3 ^ 2 ^ 3 / 2 - 4) is equivalent to

(1 + (2 * (((3 ^ 2) ^ 3) / 2)) - 4)

Function name Various mathematical function names are available.
Examples: sin, cos, exp, ...
The full list of available Polymath functions is presented below. 		12+sin(4)
exp( 5*9+log(8))
Condition operator

These operators return "1" if the condition met, and "0" if the condition does not meet.
Examples: The expression '3>6' returns 0. The expression '4>=4'
returns 1.

>, <, >=, <=, ==

Boolean operator

The Boolean operators return "1" if the condition is met, and "0" if the condition is not met.
Example: The expression '(2>3) or (1>0)' returns 1. The expression '1 and 0' returns 0.

And, Or

If-Then-Else There are three case-insensitive keywords which compose the if-then-else expression structure.
The three keywords are: If, Then, Else. 		If (2>5) Then (sin(12)+4) Else (sin(12)+8)

if(2>5)then(sin(12)+4)else(sin(12)+8)

Parenthesis Open Parenthesis: (
Close Parenthesis: ) 		x+(3-2)

A special 'if' statement is available, with the following syntax:

if (condition) then (expression1) else (expression2)

The parentheses are optional.
The condition may include the following operators: and, or (Boolean operators), > (greater than), < (less than), >= (greater than or equal), <= (less than or equal), == (equals).
The expressions may be any formula, including another 'if' statement.

For example:

A = if (x>0) then (log(x)) else(0)

b = if (T<minT) then (minT) else (if (T>maxT) then (maxT) else (T))

Vol_h1 = if (a>5 and c<2) then 1.12 else 7.89

Available Functions

A number of standard functions are available for use in the various programs. The arguments of the functions must be enclosed in parentheses. The arguments may be themselves expressions or other functions. The nesting of functions is allowed.

Function Name | Description
abs ( ) | absolute value
arccos ( ) | trigonometric inverse cosine with result in radians
arccosec ( ) | trigonometric inverse cosecant with result in radians
arccosech ( ) | inverse hyperbolic cosecant
arcsech () | inverse hyperbolic secant
arccosh ( ) | inverse hyperbolic cosine
arccotan ( ) | trigonometric inverse cotangent with result in radians
arccotanh ( ) | inverse hyperbolic cotangent
arcsec ( ) | trigonometric inverse secant with result in radians
arcsin ( ) | trigonometric inverse sine with result in radians
arcsinh ( ) | inverse hyperbolic sine
arctan ( ) | trigonometric inverse tangent with result in radians
arctanh ( ) | inverse hyperbolic tangent
cbrt ( ) | cubic root
cos ( ) | trigonometric cosine with argument in radians
cosec ( ) | trigonometric cosecant with argument in radians
cosech ( ) | hyperbolic cosecant
cosh ( ) | hyperbolic cosine
cotan ( ) | trigonometric cotangent with argument in radians
coth ( ) | hyperbolic cotangent
exp ( ) | exponential (e^x )
erf ( ) | error function
exp10 ( ) | exponential of 10 (10^x )
exp2 ( ) | exponential of 2 (2^x )
fact ( N ) | factorial of integer part of number N (this only operates on a number)
frac ( ) | fractional part
int ( ) | integer part
ln ( ) | natural logarithm to the base e
log ( ) | logarithm to the base 10
psi ( ) | psi function
rand ( ) | Returns a random number between 0-1. A parameter such as 1 or 2 should be provided to this function.
round ( ) | rounded value
sec ( ) | trigonometric secant with argument in radians
sech ( ) | hyperbolic secant
sign ( ) | returns + 1 or 0 or -1
sin ( ) | trigonometric sine with argument in radians
sinh ( ) | hyperbolic sine
sqrt ( ) | square root
tan ( ) | trigonometric tangent with argument in radians
tanh ( ) | hyperbolic tangent

All function names must be given in lower-case letters. The trigonometric functions require that their arguments be given in radians. Conversely, the inverse trigonometric functions give their results in radians.

You should note that the functions require that their arguments be enclosed in parentheses, but that the arguments do not have to be simple numbers. You may have a complicated expression as the argument for a function, and you may even nest the functions, using one function (or an expression including one or more functions) as the argument for another.


Polymath Programs

POLYMATH Help Documentation
Numerical Solutions for Scientific and Engineering Mathematical Problems

POLYMATH 6.2 is a proven computational system, which has been specifically created for educational or professional use. The various POLYMATH programs allow the user to apply effective numerical analysis techniques during interactive problem solving on personal computers. Results are presented graphically for easy understanding and for incorporation into papers and reports. Students, engineers, mathematicians, scientists, or anyone with a need to solve problems will appreciate the efficiency and speed of problem solution.

The principal options available in the POLYMATH main task selection window are the following:

Polymath Programs

LEQ | Linear Equations Solver
NLE | Nonlinear Equations Solver
DEQ | Differential Equations Solver
REG | Data Table
 | Linear & Polynomial Regression
 | Multiple Linear Regression
 | Multiple Nonlinear Regression

Utilities

Calc | Advanced Scientific Calculator
Units | Units Conversion
Const | Useful Scientific Constants
Setup | General and Numerical Algorithms Parameter Settings
Help | Help on Polymath

Special Capabilities

 | Export | Automatically Export Polymath Programs to Excel
 |  | Nonlinear Equations
 |  | Differential Equations
 |  | Linear & Polynomial Regressions
 |  | Multiple Linear Regressions
 |  | Nonlinear Regressions
MATLAB |  | Prepares MATLAB m file for Polymath Program
 |  | Nonlinear Equations
 |  | Differential Equations
 |  | Templates

Special Installation of ODE_Solver

Special Installation of the ODE_Solver which allows Differential Equations to be solved with Excel is available in ODE_Solver .


Linear Equations Solver

See Also: Nonlinear Equations Solver Differential Equations Solver

Overview

The purpose of this program is to allow you to solve systems of linear algebraic equations where the set of linear equations is inputted in a matrix-vector form. The elements of the matrix of coefficients and the vector of constants must be entered.

The data entry screen is shown below. The matrix of coefficients and the vector of coefficients are displayed. Each equation (row) is indicated by a number, and each column by a variable name (x1, x2, ..., x5, beta).

You can use the cursor to highlight one of the cells. This is the current cell. You can move the highlight by using the arrow keys or the left mouse click. To enter or modify a value in a data cell, move the highlight to the appropriate cell and either start typing in a number or erase and re-type the value already in the cell. Column (variable) names can be changed by selecting a column or a cell and then choosing the "Variable name..." option from the "Edit" dropdown menu or from the menu activated with the right mouse click.

After you have finished entering the data, the system of equations can be solved by selecting “Solve” from the dropdown “Program” menu or by bringing the cursor to the pink arrow on the screen and pressing the left mouse button.

Example

Consider the following system of linear equations:

0.07 D1 + 0.18 B1 + 0.15 D2 + 0.24 B2 = 10.5
0.04 D1 + 0.24 B1 + 0.10 D2 + 0.65 B2 = 17.5
0.54 D1 + 0.42 B1 + 0.54 D2 + 0.10 B2 = 28
0.35 D1 + 0.16 B1 + 0.21 D2 + 0.01 B2 = 14

This system of equations is defined by first entering "5" in the Number of equations box and pressing Enter.

The coefficients from the left hand side of the equation should be entered into the matrix of coefficients, the constants in the right hand side of the equations into the beta vector and the column names must be changed to D1, B1, D2 and B2 respectively, as shown below:

Pressing the pink arrow solves the problem, and the following solution is obtained in the “Report” window.

Solution Report

POLYMATH Report | No Title
Linear Equations |

Linear Equations Solution

 | Variable | Value
1 | D1 | 26.25
2 | B1 | 17.5
3 | D2 | 8.75
4 | B2 | 17.5

The equations

[1] 0.07·D1 + 0.18·B1 + 0.15·D2 + 0.24·B2 = 10.5
[2] 0.04·D1 + 0.24·B1 + 0.1·D2 + 0.65·B2 = 17.5
[3] 0.54·D1 + 0.42·B1 + 0.54·D2 + 0.1·B2 = 28
[4] 0.35·D1 + 0.16·B1 + 0.21·D2 + 0.01·B2 = 14

Coefficients matrix and beta vector

 | D1 | B1 | D2 | B2 | beta
1 | 0.07 | 0.18 | 0.15 | 0.24 | 10.5
2 | 0.04 | 0.24 | 0.1 | 0.65 | 17.5
3 | 0.54 | 0.42 | 0.54 | 0.1 | 28.
4 | 0.35 | 0.16 | 0.21 | 0.01 | 14.

General
Number of equations: 4


Nonlinear Equations Solver

See Also: Linear Equations Solver Differential Equations Solver

Expand All | Collapse All

Overview

The purpose of this program is to allow you to solve systems of nonlinear algebraic equations. The system may both nonlinear simultaneous (implicit) and auxiliary (explicit) equations. Only real roots (non-complex) can be found. All equations are checked for correct syntax and other errors upon entry. Multiple roots are given for a single equation.

The equation input/modification window is shown below.

The options and information available on this screen are the following:

Icon | Description
 | Add NLE: Input a new nonlinear (implicit) algebraic equation.
 | Add EE: Input a new explicit algebraic equation.
ini-finl | Enter minimum and maximum boundaries for single nonlinear equation.
 | Opens a window showing a list of defined and undefined variables.
 | Problem setup state. Blue color - complete, ready to be solved.
 | Problem setup state. Red color - incomplete (missing definition, initial state etc.).
 | Solve the system of equations. Note that this option is displayed only when a valid set of equations, including initial guesses for the variables, have been entered.

Comments: Use the "#" character to put a comment in the program text.

Algorithm Drop-down box: Select the preferred solution algorithm. The default algorithm is recommended for most problems and is usually quite adequate.

At the top of the window the number of nonlinear and auxiliary equations is listed and problem setup related warning messages (undefined variables, missing initial values etc.) are given. This is invaluable information as equations are entered.

Detailed additional information is provided with regard to the following subjects:

  • Entering the Equations and Initial Estimates
  • Variables and Expressions
  • Selection of Initial Estimates
  • Solution Algorithms
  • Solution Report
  • Troubleshooting

Entering the Equations and Initial Estimates

There can be two types of equations in a system of nonlinear algebraic equations: equations that require simultaneous iterative solution (implicit nonlinear equations) and equations where one of the variables can be expressed as explicit function of other variables and constants. An implicit nonlinear equation must be entered in the form:

    f(x) = an expression

where 'x' is the variable name , and f(x) is an expression that will have the value of zero at the solution.

An explicit equation should be rewritten in the form:

    x = an expression

where the expression may contain constants, implicit variables, and explicit variables.

Entering Implicit Nonlinear Equations

An implicit nonlinear equation may be entered by selecting “Nonlinear Equations (NLE)” from the file menu or clicking the NLE icon. This results in the following dialog box:

In this dialog box enter the name of one of the nonlinear variables between the brackets of the f( ) field. Enter the right hand side expression in the window between “=” and “=0”, and enter an initial estimate for the nonlinear variable. You can enter a comment (describing the variable and the units for example) if you wish. Press “Done” to finish entering the equation. Note that this entry defines the nonlinear variable to Polymath, but the variable does not need to appear in the particular nonlinear equation.

Entering Explicit Equations

An explicit equation can be entered by pressing the “Add EE” button. The following dialog box opens:

In this dialog box enter the name of the variable in the box to the left of the “=”. Enter the right hand side expression into the window on the right of the “=” sign. You can also enter a comment if you wish. Press “Done” to finish entering the equation.

All the variables must be defined and the initial conditions specified before a set of equations can be solved. Thus variable must appear in the left side of either an implicit nonlinear equation or an explicit equation.

Variable Tracking

A convenient feature of Polymath is that the undefined variables and missing initial guesses are indicated directly above the entry window as shown below to the right of the red X:

This feature helps you to insure that missing or misnamed variables are identified and easily entered or corrected. Also note that pressing [image] or choosing "Show Variables..." from the "Problem" drop-down menu opens a window with a summary of the problem variables as shown below:

Ordering of Equations

You need not be concerned with the order in which you enter the equations or the initial guesses. Polymath will automatically order the equations during problem solution. You may have your equations ordered at any time by selecting "Order Equations" from the drop-down "Problem" menu.

Editing Equations

Standard editing is available for entered equations from the "Edit" drop-down menu. Also note that you can copy an expression or part of it while in the equation entry dialog box or in the entered equation by marking it and pressing “Ctrl+C”. Pasting involves the key press combination “Ctrl+V”.

Experienced users can use the full-screen Polymath editor to directly enter all equations and initial guesses. This feature also allows you to copy all or parts of other Polymath programs to your current problem. The "#" character can be used to put a comment in the program text.

Selection of Initial Estimates

The solution algorithms require specification of initial estimates for all the variables in the implicit nonlinear equations. Generally speaking, closer initial estimates have a better chance of converging to the desired solution.

Single Nonlinear Equation

When solving a single nonlinear equation, you must enter an estimated range within which the solution lies. This can be accomplished with the button [image] . The syntax for enter the minimum and maximum range of the problem variable involves arguments of "min" and "max" respectively. These can alternately be entered as individual lines during problem input. For example, see the range for the variable x in the problem below:
For example:

f(x) = sin(2 * x)
x(min) = 0
x(max) = 5

Polymath will identify multiple solutions if they exist within this range. You may also alternatively request a plot of the function values in the specified range of the independent variable, so that the location of the roots (if any) can be seen. The program will then show the roots. If no roots exist in the estimated range, the plot can indicate in what direction you should seek the solution.

Two or More Nonlinear Equations

If there are two or more implicit nonlinear equations, the selection of initial guesses is more challenging. First, try to set initial guesses for the variables using physical considerations. (For example: The mole or mass fraction of a component can be neither negative nor greater than 1; the temperature of cooling water can be neither below freezing nor above boiling; etc.).

Be especially careful not to select initial guesses where some of the functions may be undefined. For example:
       f(xa) = 1/(xa-xb)+ ... is undefined whenever xa=xb
       f(xb) = log(1-xb) is undefined whenever xb>=1;
Selecting such a set of initial guesses will probably stop the solution process, and an error message will be displayed.

When solving nonlinear equations simultaneously, initial guesses must be set for each nonlinear variable. The initial guess for each equation is entered in the nonlinear equation entry dialog box. Alternatively the syntax for supplying the initial guess in the problem is the particular variable with an argument of "0". For examples, see the input for initial guesses for variables x1, x2, and x3 given in the problem below:

f(x1) = midtm ^ 0.8 - x2 * 2 - 12

f(x2) = 2 * x1 - 9 / (1 + x1) + (x2 + x3) * nlh

f(x3) = 7 * x3 - 9 * v

v = x1 + x2

midtm = x1

nlh = x1 + midtm + v

x1(0) = 2

x2(0) = 0.2

x3(0) = 9

Problem Solutions

Remember that Polymath will have a better chance of finding a solution to a complex set of simultaneous nonlinear equations and explicit algebraic equations where the initial guesses are close to the solution values. Polymath solutions typically are found that are in the region of the initial guesses. Note that not all sets of nonlinear equations have solutions. Your problem must be posed properly. Also, there may be multiple solutions to a particular set of equations which can be identified by starting at different sets of initial guesses.

Examples
Example 1 - Explicit Equations Only

The pressure (P) is to be calculated at a given temperature (T) and volume (V) according to the equation:

P = R·T/(V-b) – a/V2

where
a  = (27/64)(R2·Tc2/Pc)

b  = R·Tc/(8Pc)
R  = 0.08206

Tc = 304.2

Pc = 72.9

In this example, all of the equations are explicit algebraic equations. The equations can be inputted in any order as Polymath will order equations as necessary during the problem solution. The expression for the variable “a” can be entered by pressing the “Add EE” button. In the dialog box that opens put “a” in the box preceding the “=” sign and put the expression “(27/64)*(R^2*Tc^2/Pc)” in the window after the equal sign. A comment indicating that "a" is a Van-der-Waals equation constant can also be added. The entry of "a" with the dialog box is shown below.

After pressing “Done” the equations for R, Tc, Pc and b can be entered similarly. Suppose that the calculation of pressure is desired at three different combinations of temperature and volume. The three corresponding pressures can be designated by P!, P2, and P3 at corresponding temperatures and volumes. The pressure P1 can be calculated for T = 400 K and V = 0.8 liters by entering the equation as shown below:

After pressing “Done” to enter the equation for P!, the entire equation can be copied and edited in order to duplicate the same equation with different T, V values along with names for the pressure. The final for of the equation system with three expressions for P1, P2 and P3 for three different T and V sets is shown below.

Experienced users can enter all the lines of this problem directly into the full-screen editor window.

A mouse click on the pink arrow button solves this problem and results in the Polymath Report shown below:

Example 2 - One Implicit Nonlinear Algebraic Equation and Two Explicit Algebraic Equations

Consider the following set of three equations:

 f(T) = x1P1 + x2P2 – 760  (will be zero at solution) 	(1)
 log(P1) = 6.85221 - 1064.63/(T + 232.0)	(2)
 log(P2) = 6.87776 - 1171.53/(T + 224.366)	(3)

with x1 = 0.1 and x2 = 0.9. The equation set must be solved for the unknown T in the range of Tmin = 36 and Tmax = 70. The log represents the logarithm to the base 10.

In order to solve this set with Polymath, equations (2) and (3) should preferably be rewritten as explicit equations for P1 and P2. Thus:

P1 = 10^(6.85221-1064.63/(T+232.0))
P2 = 10^(6.87776-1171.53/(T+224.366))

The equations can be inputted in any order. The nonlinear implicit equation for T can be entered by pressing the “Add NLE” button. In the dialog box that opens, put “T” (without the quotation marks) in the box between the parentheses and place the expression: “x1*P1+x2*P2-760” (without the quotation marks) in the window between “=” and “=0”. (Note that POLYMATH does not allow use of subscripts or superscripts). Finally enter an initial guess in the middle of the initial range yielding T(0)=53. The dialog box after entering the equation is shown below.

Press “Done” when finished. To enter the equation for P1 press the “Add EE” button. In the dialog box that opens put “P1” in the box preceding the “=” sign and put the expression “10^(6.85221-1064.63/(T+232.0))” in the window after the equal sign. Before pressing “Done” you can copy the expression by marking it and pressing “Cntr C”. The explicit equation input window, with the equation for P1 is shown below:

Press “Done” to finish entering this equation and “Add EE” to enter the equation for P2. To enter the expression bring the cursor to the window after the “=” sign, press “Cntr V” to paste the expression of P1 and change the numerical constants to the values as they appear in the expression of P2. The constants: x1 = 0.1 and x2 = 0.9 should be added as two additional explicit equations. For a system with one nonlinear equation the program requires entering upper and lower limits for the implicit variable. Enter 30 as lower limit and 70 as upper limit for T. The final set of equations, ready to be solved is shown below.

Experienced users can enter all the lines of this problem directly into the full-screen editor window.

The solution is obtained by pressing the pink arrow key with the Graph box checked. The Report is given below:

The graphical solution (unedited) is presented below:

The graphical result confirms the calculated result given in the Polymath report.

Example 3 - Two Implicit Nonlinear Algebraic Equations and Several Explicit Algebraic Equations

Consider the following set of equations:

k·CA12 = v·(CA0-CA1)/V
k·CA22 = v·(CA1-CA2)/V

where k = 0.075, v = 30, CA0 = 1.6, and CA2 = 0.2 CA0. The resulting equation set must be solved for the variables CA1 and V using the initial estimates: CA1=1 and V=300.

To solve this system of equations, each nonlinear algebraic equation must be rewritten in the form f(x)=(an expression that is to have the value of zero at the solution). The appropriate forms for these equations are:

f(CA1) = k·CA12 – v(CA0 - CA1)/V
f(V) =  k·CA22 – v(CA1-CA2)/V

To input the first nonlinear equation press the “Add IE” button. In the dialog box that opens put “CA1” (without the quotation marks) in the box between the parentheses of: f(…)=. Put the expression: “k·CA12 - v(CA0 - CA1)/V” (without the quotation marks) in the window between “=” and “=0” (Note that POLYMATH does not allow use of subscripts or superscripts). The expression can be copied for future use by marking it and pressing “Cntr C”. To finish entering the implicit equation type in the initial guess for Ca1 (=1.0) in the appropriate box. Press “Done” when finished.

To input the second implicit equation press the “Add IE” button. In the dialog box that opens put “V” in the box between the parentheses of: f(…)=. To enter the expression, bring the cursor to the window after the “=” sign, press “Cntr V” to paste the expression of Ca1 and change the variable indexes: CA0 to CA1 and CA1 to CA2 as shown in Eq. 5. Enter the initial estimate 300 in the appropriate box. Press “Done” to finish entering this equation. Enter the constants k,v, CA0 and CA2 as four additional explicit equations. The set of equations, ready for solution is shown below.

Experienced users can enter all the lines of this problem directly into the full-screen editor window.

The resulting Polymath Report is given below:

Example 4 - Constrained Variables

Consider the following set of equations:

f(x1) = x1/x2 - 5 ln(0.4 x2/x3) + 4.45977 = 0

where

x2 = 1 - x1

x3 = 0.4 - 0.5 x1

In this problem, the variables x1, x2 and x3 are constrained. At the solution x1>0 because of physical considerations; x2 and x3 must be greater than zero throughout the solution process otherwise a negative value inside the ln function will yield an execution error. POLYMATH allows constraints on the variables of the type x>0 or x<0.

For the solution, the equations for x2 and x3 must be rewritten in the implicit form as:

f(x2) = x2 + x1 –1 = 0

f(x3) = x3 + 0.5 x1 – 0.4 = 0.

A Polymath solution can be achieved by first selecting “constrained” as the solution method. With this solution method selected additional input fields are added to the NLE equation input dialog box for defining constrains. Refer to the dialog box below to where the equation f(x1) has been already entered:

The options for constrains of x1 are “Any value” that indicates no constraints, “positive” that means it must be positive at the solution only and “always positive” that forces the variable to be positive all the way to the solution. For x1 the “positive” definition is sufficient. Since the variables x2 and x3 must be positive for all calculation leading to the solution, the option “Always positive” must be marked. The initial guesses for x2 and x3 are 0.5 and 0.15 respectively, which are consistent with initial guess of x1=0.5.

POLYMATH designates the constrained variables in the initial guess line as follows: Positive value will have ">= 0" added to the initial guess value, Always positive values will have "> 0" added to the initial guess value. The Polymath editor screen for the above problem is given below:

Experienced users can enter all the lines of this problem directly into the full-screen editor window.

The resulting Polymath Report screen presents the results of this problem:

Note that the constrained method may only be used for sets of equations with more than 1 simultaneous nonlinear equation.

The Conditions for Solution and General Settings are presented at the end of each of the Polymath Reports as shown above. This provides a summary of the calculations carried out during the problem solution.

Solution Algorithms

There are four algorithms available in Polymath for solution of nonlinear equations, and all of them are based on the Newton-Raphson (NR) method. This method uses a truncated Taylor series estimate of the function values to obtain better estimates of the unknowns. In each iteration the function values and the matrix of partial derivatives are calculated. Numerical perturbation is used for calculating the matrix of partial derivatives. The iterative solution stops if either the sum of the magnitudes of the functions is less than TolF (default value 1.0E-7) or the sum of the absolute values of the corrections to the unknowns is less than TolX (default value 1.0E-7). NTrial (default value 150) is the maximal number of iterations that are allowed.

The default solution method uses the NR method with line search to ensure reduction of the norm of the function values in every iteration. This is a “safe” method that usually finds the solution (unless it converges to a local minimum) but it requires a large number of function evaluations per iteration and may be too slow for large scale problems. Calculations can be speeded up by using the Newton-Raphson method without the line search where the function evaluations associated with the line search are saved. This method is faster if it converges but it may diverge frequently. Another way to reduce the number of function evaluations is to use Broyden’s method where the matrix of partial derivatives is calculated only once by numerical perturbation after that this matrix is updated rather than being recalculated. For detailed explanation of the above three algorithms see the book by Press et al.

For system of equations containing constrained variables (some or all of the variables must be positive throughout the solution process or only at the solution), an algorithm which combines the step length restricted NR method with a continuation type method is used. In the step length restricted NR method the progress in the NR direction is restricted so that none of the constrained variables become zero or negative. In the continuation method, the original problem is converted into a sequence of easier to solve problems where the solution is closer to the initial estimate than in the original problem. For detailed explanation of the above three algorithms see the publication by Shacham.

If there is only one implicit nonlinear equation, the program will attempt to find all the solutions. For such a system you must specify an interval in which the root(s) can be found. The function is plotted and smaller intervals in which root(s) are located are identified according to sign change of the function. Either the “fast” or the “safe” NR method is used to converge to the exact solution values for each root that has been identified.

Solution Report

The solution report obtained after solving Example 3, that is discussed in the “Entering the equations and initial estimates into the program” section is used to show the various information presented in the report page. The first part of this report is shown below.

POLYMATH Report Sample problem 1
Nonlinear Equations

Calculated values of NLE variables

Variable

Value

f(x)

Initial Guess

1

CA1

0.6019966

-8.246E-09

1.

2

V

1101.549

-2.772E-09

300.

Variable

Value

1

k

0.075

2

v

30.

3

CA0

1.6

4

CA2

0.32

In this section the title of the problem as entered by the user, the date when the solution was obtained, and the values of all the variables at the solution are shown. For the nonlinear algebraic equations, the function values (which should theoretically be zero) are also shown. For an acceptable solution the function values should be close to zero. If the program is unable to find a solution, then an appropriate error message is shown. In such case or in case that the function values are too high, you can refer to "Troubleshooting" to determine the cause for the failure of the program to reach an acceptable solution.

In the Polymath Report the entered equations are shown:

Nonlinear equations

1

f(CA1) = k * CA1 ^ 2 - v * (CA0 - CA1) / V = 0

2

f(V) = k * CA2 ^ 2 - v * (CA1 - CA2) / V = 0

Explicit equations

1

k = 0.075

2

v = 30

3

CA0 = 1.6

4

CA2 = 0.2 * CA0

The nonlinear (implicit) equations and the explicit equations are grouped separately. In case that constraints on the variables were defined, they are also shown here. Additional information presented includes the comments associated with each equation (if any), information related to settings, and the location where the problem file is stored.

Settings
Tolerance X | 0.0000001
Tolerance F | 0.0000001
Max trials | 150

General
Number of implicit equations | 2
Number of explicit equations | 4
Solution method | FASTNEWT
Elapsed time | 0.0000 sec

Troubleshooting

Most error messages issued by the program are self-explanatory and suggest the type of action that should be taken to correct the problem. In some cases, however, no error message is given or the message is less obvious. Discussion of some of those cases and the corrective actions that can be taken follows:

The arrow [image] does not show after finishing problem input.

The appearance of the pink arrow on the equation input window indicates that the problem has been completely defined and the program is ready to solve it. The input errors/omissions are usually indicated just above the input window. Two of the most common reasons for the arrow to be gray are:

  • There are still undefined variables. Open the window that shows the list of defined and undefined variables. Use of letters and numbers with similar symbols (such as the letter l (L) and the number 1 (one)) often causes the same variable to show up with different names.

  • The solution interval not specified for a single equation. Input lower limit and upper limit for the region where the root should be found using the input button or direct entry of the limits.

Circular definition of explicit variables not allowed.

This message appears while trying to solve a set of equations when one (or more) variable is defined as a function of another variable, which itself is a function of the first variable. For example, attempting to define y=z/x, when z was already defined as a function of y, will cause this error message. This can be prevented by writing the equation using an implicit form: f(y)=y-z/x.

No solution appears beneath the NLE Solution heading in the report page.

No solution can be found in the specified region for a single nonlinear equation. Plot the function value by marking the “Graph” option in the equation input window and resolve the equation. Use the graph obtained to extend the solution interval in the direction where the absolute function value is diminishing.

Solution did not converge.

This message usually appears when solving several simultaneous nonlinear equations,

The most common causes for the program to indicate that the solution has not been found are the following:

  • The default (or selected) algorithm is unable to solve the problem. Select a different solution algorithm in the equation input window. “Constrained” and “safebroyd” methods are found to be the most robust of the algorithms included in the program.

  • The system contains equations which are very non-linear. Equations can be made less nonlinear by eliminating division by unknowns (multiplying both sides of the equation by the expression that contains the unknown). Often, by substitution and reordering of the equations, a system of equations can be brought in a form which contains only one implicit equation, and all the rest are explicit. In this form, the solution will always be found, if one (or more) exists inside the search interval that is specified.

  • The initial estimates are too far from the solution. Specifying realistic initial guesses, as close to the solution as possible, can often help. See the section on “Selection of Initial Estimates for the Unknowns” for detailed discussion.

  • The error tolerances (TolX, TolF, etc) were set too small. The attainable tolerance for a nonlinear equation depends on the magnitude of the various terms comprising the function value. If these magnitudes are too large the default tolerances may be too small. Try to increase the tolerances in “setup”.

  • The problem has no solution. If a system of equations fails to converge from several starting points using different solution algorithms and tolerance settings indicates that the system has no solution. This can be due to errors in the problem setup. Check the basic equation set, the entered equations,, and the numerical values of variables, and units of the constants.


Differential Equations Solver

See Also: Linear Equations Solver Nonlinear Equations Solver

Expand All | Collapse All

Overview

The purpose of this program is to provide a solution for a system of simultaneous first-order ordinary differential equations and explicit algebraic equations.

The equation input/modification window is shown below for a typical problem:

The options and information available on this screen are the following:

Icon | Description
 | Add DE: Input a new differential equation
 | Add EE: Input a new explicit algebraic equation
ini- finl | Define initial and final values of the independent variable
 | Opens a window showing a list of defined and undefined variables
 | Problem setup state. Blue color - complete, ready to be solved.
 | Problem setup state. Red color - incomplete (missing definition, initial state etc.).
 | Integrate the system of equations. Note that this option is displayed only when a valid set of equations, including initial and final values of the variables, has been entered.

Table: When this option is marked, a table containing the values of all the variables as function of independent variable is created during integration.

Graph: When this option is marked, a plot of the integrated values of the differential variables versus the independent variable is created during integration.

Report: When this option is marked, a report containing initial, final, maximal and minimal values of all the variables, a complete listing of the equations in the system, and some additional information is shown after the integration is finished.

Algorithm Drop-down box: Select the preferred solution algorithm identified in the pull down menu.

At the bottom of the window the numbers of differential and the auxiliary equations are shown and problem setup related warning messages (undefined variables, missing initial values etc.) are displayed.

Additional detailed information is provided with regard to the following:

  • Entering the Equations into the Program

  • Variables and Expressions

  • Integration Algorithms

  • Solution Report, Tabular and Graphic Presentation of the Results

  • Troubleshooting

Entering the Equations

The system of equations may contain two types of equations: first order ordinary differential equations and explicit algebraic equations where one of the variables can be expressed as explicit function of other variables and constants. The differential equations must be entered in the following form:

d(x)/d(t)= an expression

Here t is the independent variable and x is a dependent variable.

Auxiliary algebraic equations must be entered in the form:

x = an expression

where the same naming rules apply.

An expression may contain any combination of constants and variables. However, the auxiliary equations must be sequential (not simultaneous). POLYMATH will sort and order the equations and will indicate if a simultaneous situation exists (by warning of 'circular dependency').

Initial conditions must be specified for all the variables defined by differential equations, as well as the independent variable. A final value must also be specified for the independent variable.

Entering Ordinary Differential Equations

To input a new set of equations for solution, select differential equations (DEQ) from the file menu. To input a differential equation, press the “Add DE” button. The following dialog box opens:

In this dialog box enter the name of a differential dependent variable between the brackets of the d( )/d( ) in the top left field that is left of the = sign. Enter the independent variable in the bottom of the d( )/d( ) field. Note that this defines the independent variable for subsequent differential equation entry. Enter the right hand side expression in the window after the = sign and finally enter an initial value for the dependent variable. You can enter comments (describing the variable and its units for example) if you wish. Press “Done” to finish entering the equation.

Entering Explicit Equations

To input an explicit equation, press the “Add EE” button. The following dialog box opens:

In this dialog box enter the name of a variable in the box to the left of the = sign. Enter the right hand side expression into the window on the right of the = sign. Press “Done” to finish entering the equation. Equations can be edited or removed by highlighting the row in which the particular equation is found and pressing the Edit or Remove buttons. Before a set of equations can be solved all the variables must be defined, thus every one of them must appear in the left side of either an implicit or an explicit equation.

Entering Boundary Conditions

The initial and final boundary conditions must be entered for the independent variable. This is accomplished by pressing the [image] button that opens the following windows for the initial value and the final values respectively:

Variable Tracking

A convenient feature of Polymath is that the undefined variables and missing initial/final conditions are indicated directly above the entry window. This is shown below for missing explicit variable k2 (to the right of the red X):

This feature helps you to insure that missing or misnamed variables are identified and easily entered or corrected. Also note that pressing [image] or choosing "Show Variables..." from the "Problem" drop-down menu opens a window with a summary of the problem variables as shown below:

Ordering of Equations

You need not be concerned with the order in which you enter the equations or the initial/final conditions. Polymath will automatically order the equations during problem solution. You may have your equations ordered at any time by selecting "Order Equations" from the drop-down "Problem" menu.

Editing Equations

Standard editing is available for entered equations from the "Edit" drop-down menu. Also note that you can copy an expression or part of it while in the equation entry dialog box or in the entered equation by marking it and pressing “Ctrl+C”. Pasting involves the key press combination “Ctrl+V”.

Experienced users can use the full-screen Polymath editor directly to enter all equations and boundary conditions. This feature also allows you to copy all or parts of other Polymath programs to your current problem. The "#" character can be used to put a comment in the program text.

Note: You may see the valid expressions and variables in Variables and Expressions

Integration Algorithm Selection

The drop-down menu provides a selection of available integration algorithms that can be used in problem solution as shown below with the default algorithm highlighted. These algorithms will be discussed in another section.

Program Output Selection

The selections are made by checking the appropriate boxes in the problem display:

Table - This option provides a table of all the problem variables at each of the values of the independent variable as it is varied from the initial condition to the final value. This summary table can be used to generate graphs within Polymath or these data can be copied and pasted into spreadsheet or graphical programs.

Graph - This option formulates a graph of all the differential equation variables plotted with the independent variable. Various options within Polymath from this graphical display allow for editing of the graph and the display of selected problem variables.

Report - This option generates a summary of all the problem variables indicating the initial value, minimal value, maximal value, and final value of each variable. Additionally, all the equations are summarized and details regarding the numerical solution are given.

The above program outputs are presented in the example problem that follows.

Example
Example 1: Three Simultaneous Ordinary Differential Equations and Two Explicit Algebraic Equations
Consider the following set of equations:
d(A)/d(t)= - k1A
d(B)/d(t)= k1A – k2B
d(C)/d(t)=  k2B

that is to be integrated from t=0 where A(0)=1, B(0)=0 and C(0)=0 (initial values) for up to t=3 with the constant values being: k1=1 and k2=2.

The equations can be inputted in any order as Polymath will order the equations prior to integration. To input the first differential equation, press the “Add DE” button. In the dialog box that opens put “A” (without the quotation marks) in the box between the parentheses of: d(…)/d(t)=. Put the expression: “-k1*A” (without the quotation marks) in the window after the = sign. (Note that POLYMATH does not allow use of subscripts or superscripts). Finally enter the initial value 1.0 for A(0). The equation entry dialog box with the completed first equation is shown below.

Enter the second and third differential equations according to the above procedure must be repeated when the appropriate variable names, expressions and initial values are inputted in the dialog boxes. To enter the constant values, the option “Add EE” should be used. To enter the value of k1, press the “Add EE” button. In the dialog box that opens put k1 in the box preceding the = sign and put 1.0 in the window after the equal sign. The completed dialog box is shown below.

Press Done to finish entering this constant. Assign a value to k2 similarly. Before the integration can be carried out the initial and final values of the independent variable must also be specified. The final form of the system of equations with the appropriate initial and final values, ready to be solved is shown below.

The program output selection is discussed in the section entitled Solution Report.

Integration Algorithms

There are five numerical integration algorithms available within Polymath. The two most useful algorithms will be discussed in some detail.

RKF45

The Runge-Kutta-Fehlberg (RKF45) is the default algorithm that is highly recommended for most problems. Details are available in the paper by Forsythe et al, 1977. This algorithm monitors the estimate of the integration error, and reduces or increases the step size of the integration in order to keep the error below a specified threshold. The accuracy requested is that both the relative and absolute (maximal) errors be less than the truncation error tolerance. The default value of this tolerance is 1.0E-6. (All the tolerances can be changed in “Settings”). If the integration progresses very slowly the reason for that may be that the system of equations is stiff. Stiff systems of equations contain variables that change (decay) in widely varying time scales. For such systems, the RKF algorithm may require a very small step size for integration and one of the available still algorithms, STIFF or STIFFBS, should be used.

STIFFBS

The recommended stiff algorithm is the semi-implicit midpoint rule of Bader and Deufhand (STIFFBS). Details are available in the paper by Bader and Deufhand, 1983. This algorithm also includes error estimation and step-size control. In this case, the requested maximal error tolerance is 1.0E-7

Other Algorithms (RKF56, BS, STIFF)

Additional algorithms include a higher order (higher precision) such as the Runge-Kutta-Fehlberg (RKF56). The Burlirsch-Stoer (BS) uses the extrapolation method. When this is used for non-stiff problems, and it requires less computational effort than the RKF methods in order to achieve the same high accuracy during the integration of smooth functions. Details are found in Press et al, 1992, pp. 735-739. For stiff problems the Rosenbrock method (STIFF) is also available. This method is simple to implement. For moderate accuracy and moderate sized systems, it is competitive with the more complicated algorithms. More information is also available in Press et al, 1992, pp. 735-739).

Solution Outputs

The output options are discussed below using the problem from Example 1:

Report

It is recommended that the Report always be one of the output options. This Example 1 report is presented below:

The initial part of the Report indicates the title of the problem as entered by the user and the date when the solution was obtained. This is followed by a table showing initial, minimal, maximal and final values for all the variables in the problem. The next section of the report displays the original equations separated into differential equations and explicit equations along with the comments, as entered by the user.

The final part of the report given below summarizes the problem equation, the execution time, the solution method, and the location where the problem file is stored.

The report is of significant value in checking to see that the problem is functioning properly and that the expected variables have the desired values. You may also find that copying this Report into a word processing document provides an easy way to document a particular problem.

Graph

When the graph option is checked, a graph containing all the integrated differential variables versus the independent variable are displayed with automatically scaling. The initial graph for the example is displayed below:

The options available on left side of this Graph display screen are summarized below. Please click on the description for more detailed information on selected options.

Icon | Description | Details
 | Refresh: Graph is restored to original state. |
 | Save: Creates a Polymath Graph file as *.plg |
 | Save As: Creates a new Polymath Graph file as *.plg |
 | Open: Opens a Polymath Graph file |
 | Print: Prints the current Graph |
 | Copy: Copies the current Graph to the clipboard |
 | Curves and Functions: Allows selection of variable for revised Graph | Curves and Functions
 | Design: Allows changes in Graph properties | Design
 | Table: Creates data table for selected curves | Table

Changing Displayed Variables

In the simple graph displayed above, the independent variable of the integration is being displayed on the horizontal (x) axis by default. The variable appearing on the x axis and the variables plotted on the vertical (y) axis can be controlled by clicking on the "Curves and Functions" icon.

Scaling Displayed Variables

If the magnitudes of the displayed variables differ widely, the details of some of the curves may be lost. The option to hide or show variables (in “Curves and Functions”) can be used to obtain graphs that are better scaled for a particular range. Manual re-scaling of the graph can also lead to the same results. Additional options for editing and manipulating the graph are discussed in the “Graph" section.

Smoothing Displayed Curves

When some of the curves are non-smooth and appear broken, this may be improved by increasing the number of data points saved during the integration and/or by reducing the integration interval. The default value for intermediate data points is 100. Increasing this up to 500 for the Ordinary Differential Equations (in settings) will usually lead to smooth, unbroken curves.

Troubleshooting

Most of the error messages issued by the program are self-explanatory and suggest the type of action that should be taken to correct the problem. In some cases, however, no error message is given or the message is less obvious. Common errors and the suggested corrective actions are presented in below.

The arrow [image] is not shown after finishing equation input.

The appearance of the pink arrow on the equation input window indicates that the problem has been completely defined and the program is ready to solve it. There are two common reasons for the arrow not to be pink:

  1. There are still undefined variables. Open the window by clicking on the [image] icon to show the list of defined and undefined variables. Use of letters and numbers with similar symbols (such as the letter I and the number 1 (one)) often causes the same variable to show up with different names.

  2. No initial and/or final value for the independent variable has been entered. Input initial and final values (You can press the “Tab” key after finished entering the first number).

Circular definition of explicit variables not allowed.

This message appears while the program is trying to solve a set of equations, when one (or more) variable is defined as a function of another variable, which itself is a function of the first variable. For example, attempting to define y=z/x, when z was already defined as a function of y, will cause this error message. Note that implicit algebraic equations are not allowed in the differential equation solver. To solve such (differential algebraic) systems with POLYMATH, the method by Shacham et al (1996) can be used.

Division by zero at the starting point.

Occasionally the initial value of a variable must be zero, but this value causes one or more equations to be undefined. Starting the integration using a value of eps (where eps is a very small number) for this variable instead of 0 can often solve this difficulty.

Some of the curves appear non-smooth when graphical results are displayed.

When some of the curves are non-smooth and appear broken, this may be improved by increasing the number of data points saved during the integration and/or by reducing the integration interval. The default value for intermediate data points is 100. Increasing this up to 500 for the Ordinary Differential Equations (in settings) will usually lead to smooth, unbroken curves.

Integration progresses very slowly (error message “Too many steps…” )

Some of causes and cures for very slow integration are:

  1. The integration algorithm is not appropriate. It may happen that the problem is very stiff and a non-stiff algorithm (such as RKF45) is used for integration. Try to change the integration algorithm to a stiff method (such as STIFFBS or STIFF). If the error message persists, check for other potential causes.
  2. The ratio between the integration interval and the error tolerance is too large. The integration algorithm will attempt to achieve precise solution as dictated by the error tolerance; therefore, very small step sizes are used. The resulting calculations take too many steps and thus too much time to cover the entire interval using such small steps. Try to increase the error tolerance if a less accurate solution is acceptable (in settings) or reduce the interval (final value) for integration.
  3. There are errors in the problem setup. If the error message still persists after reducing the integration interval and changing integration method, there are probably errors in the problem setup or input. Check and verify that the basic equations of the problem are correct. Double check the entered problem, the numerical values used, and the units of the equations and various constants.


Regression Package

Regression & Data Analysis

See Also: Data Table Linear & Polynomial Regression Multiple Linear Regression Nonlinear Regression

All of the regression and data analysis options within Polymath are available from the Data Table which is used for input, manipulation and storage of numerical data. This Data Table is much like a spreadsheet; however, it has more powerful and easy to use capabilities. Data can be entered directly into the Data Table, or it can be copied into the Data Table from spreadsheets or other tables. Several of the Polymath programs also place their output results within the Data Table. Options that are available from the Data Table includes: interpolation, differentiation, integration, graphical presentation, and data column analysis.

The Linear & Polynomial Regression capability from the Data Table allows the fitting of data to a polynomial of degree n with the general form:

P(x) = a0 + a1*x + a2*x^2 + . . . + an*x^n

or to a linear equation when the equivalent first degree polynomial is specified:

P(x) = a0 + a1*x

The Multiple Linear Regression capability from the Data Table will fit a linear function of the form:

y(x1, x2, ..., xn) = a0 + a1*x1 + a2*x2 + ... + an*xn

where a0, a1, ..., an are regression parameters, to a set of N tabulated values of x1, x2, ..., xn (independent variables) versus y (dependent variable).

The Nonlinear Regression option from the Data Table will fit a general nonlinear function of the form:

y = f (x1, x2, …, xn, a0, a1, a2, …, am)

where a0, a1, …, an are regression parameters to a set of N tabulated values of x1, x2, …, xn (independent variables) versus y (dependent variable).

Summary:

Data Table

Interpolation

Differentiation

Integration

Graphical Presentation

Data Column Statistical Analysis

Linear & Polynomial Regression
Multiple Linear Regression
Multiple Nonlinear Regression


Data Table

See Also: Linear & Polynomial Regression Multiple Linear Regression Nonlinear Regression

Expand All | Collapse All

Overview

All of the Polymath regression programs begin with the data table that is used for input, manipulation and storage of numerical data. The data is stored in a column-wise fashion where every column is associated with a name (variable) and can be addressed separately. The stored data can be regressed (fitting a straight line, various curves and equations to the data using linear, multiple linear, polynomial, and nonlinear regression techniques), analyzed ( interpolated, differentiated, integrated along with various statistical calculations) and plotted. The data table can be accessed directly by selecting the "REG" option when creating a new data file. Tabular results of solution of a set of ordinary differential equations are also stored in the data table. A data table with two columns of data is shown below:

Entering and Manipulating Data

The Polymath Data Table for data entry and manipulation is shown above. It is much like a spreadsheet. The top row of cells contains the column names (the default names being C01 to C30). The rest are data cells, which have 300 rows by 30 columns (default values, the total number of rows and columns can be changed in the setup dialog window).

The address of the current active cell is shown in the upper left corner of the data table. The active cell is also highlighted. You can move the highlight by using the arrow keys and the mouse.

To enter or modify a value in a data cell, move the highlight to the appropriate cell and start typing in a number. When you are done typing in the number, you may press the left or right arrow key to move to the next cell in the current row. Also the up or down arrow keys may be used to move to the next cell above or below.

When entering the data it is important to place data in all rows. Leaving rows empty (in particular the first row) may prevent POLYMATH from identifying the columns in regression and/or analysis.

Column names can be changed by using the change “Column Name” in the drop-down "Column" menu which is shown on the left. A name must begin with a letter, and may contain letters and digits. See the section Variables and Expressions for additional column naming rules.

Contents of a column can be defined as function of previously defined columns. Column definitions can be very useful when, for example, transformation functions are used to linearize a nonlinear regression model . To define such a column, select “Column definition” from the drop-down “Column” menu. Columns must be previously named before they can be used in an expression.

You may alternatively set or change the column name in the left side of the “=” sign and enter the column definition in the form of an expression where the expression may contain constants and names of previously defined columns.

For example, consider the following transformation of variables: logTempK=log(Temp+273.15) The values in a column defined in this manner are computed whenever the values in any of the columns involved in the expression are modified. You can not modify numbers in data cells of a defined column directly, unless the definition is deleted. Furthermore, the options 'clean', 'cut' and 'paste' are not active for the data tale cells that are generated by a column definition.

Note that the column manipulation options can be reached (in addition to using the dropdown menu) by marking a column and pressing the right mouse key. Plotting or regression of the data from the Data Table is by selecting the Regression tab at the bottom of the Data Table and then selecting the option at the top (Linear & Polynomial, Multiple Linear, or Nonlinear). The Linear & Polynomial Tab is shown in the Data Table given below:

Example

The following table presents vapor pressure versus temperature for benzene. (This is Example 2 - "Vapor pressure" in the Polymath REG Regression Program)

The appropriate columns (variables) must be created in order to fit the equation below:

log(P) = A + B/T + C log(T) + D T2

or log(P) = A + B*(1/T) +C*(log(T)) +D*(T2)

which has the general form for multiple linear regression that is given by

y(x1, x2, ..., xn) = a0 + a1*x1 + a2*x2 + ... + an*xn

Note that T is the temperature in Kelvin and A, B, C and D are the parameters. For this problem, log(P) corresponds to y(x1, x2, ..., xn), A corresponds to a0, B corresponds to a1, (1/T) corresponds to x1, C corresponds to a2, (log(T)) corresponds to x2, D corresponds to a3, and (T2) corresponds to x3.

The Data Table must be prepared for multiple linear regression by creating columns containing the variables (1/T), (log(T)), and (T2).

Step 1

Enter the above data into the Data Table with descriptive column names and without the row of unit information. This is shown in the Data Table below as columns "TC" and "P".

Step 2

Create a column named "TK" for the temperature in Kelvin using column "TC". The is indicated in the Data Table below where the desired column has been selected and both the descriptive name and the column definition have both been entered in their respective textboxes. Remember that

Column formula definition must start with an equals '=' sign, and calculation is carried out for the entire column overriding previous values.

Press the [image] button or press enter to finish entering the TK column name and column definition.

Step 3

The column “logP” which contains the values of log(P) can be named and column defined in a similar manner. Note that the log() function is used here.

Additional Steps

Three additional columns can be created where Trec = 1/TK, logT = log(TK) and T2 = TK^2.

The completed Data Table is shown below, after all the necessary columns have been defined.

Note that the names of the columns which were defined as functions of other columns appear in blue bold color.

Shortcuts

  • Enter '=' from the keyboard when in a particular cell is highlighted to modify that column formula definition.
  • Enter 'n' from the keyboard when in a particular cell is highlighted to modify the column name.

Transformation Functions

Often it is more convenient to fit a curve, a straight line or a linear function to a transformed form of the original data than to carry out nonlinear regression with the original nonlinear regression model.

For example, consider a data set that satisfies the relationship y = ax^b .

When logarithms to the base 10 are taken of both sides of the above equation, the result is log(y) = log(a) + b*log(x). If transformation functions xt = log(x) and yt = log(y) are defined, then the transformed data points will give a straight line when yt is plotted versus xt, with slope = b and intercept = log(a). The column definition option in Polymath can be conveniently used to create the columns of transformed variables. The Polymath "Linear and Polynomial Regression Option" can be used to determine b and log(a).

Some additional useful transformations:

General Notes
  1. The total number of rows and columns can be modified from the Polymath setup window. The changes will take place for new Table windows only.
  2. Table formats (Fonts, Colors, and Alignments) are not saved when saving the problem into data file. Only the contents of the cells and the formulas are saved.


Prepare Graph

See Also: Regression Data Table Graph Editing

The “Graph” dialog box is shown below for Example 2 of the Polymath Data Table. To prepare a graph you should select first the name of the variable, which will be put on the horizontal (X) axis using the selection box that will provide all column variables. Then you should select the variables that you desire to be placed on the vertical (Y) axis. Note that for selecting more than one variable the Cntr key and the right mouse button must be simultaneously pressed. Check the "Draw Markers" option to plot the data points and/or "Connected" to draw the line connecting the data points. Click the pink arrow or press F5 to obtain the graph.


Graph Editing

See Also: Data Table Differential Equations Solver

Polymath Graph from Data Table

The data contained in the Polymath Data Table can be integrated into graphs by pressing on the "Prepare Graph" tab at the top right of the Data Table window. This is illustrated below for Example 3 - Vapor Pressure from the Data Table.

Graphs are prepared by first selecting the independent variable to be placed on the horizontal (X) axis from the drop-down list at the top of the window. Then one or more dependent variable names, which will be put on the vertical (Y) axis, must be selected. Note that for selecting more than one variable, press and hold the Cntr key and use the left mouse button to select one or more variables. Note that once a variable is selected for the (X) axis, it no longer will appear in the (Y) axis drop-down list.

Example - Plotting Vapor Pressure

Select variable "P" for the (X) axis and variables "TC" and "TK" for the (Y) axis for Example 3 - Vapor Pressure from the Data Table (discussed above). Note that selection of several variables requires pressing and holding the Ctrl key while clicking on the desired variable names. Also select the "Draw Markers" option and the "Connected" options as shown below.

Press the pink arrow key [image] to have the initial graph displayed.

Scatter Points Graphical Display

The initial graphical display of this Example discussed above is shown below.

The options available on left side of this graphical display screen are summarized below. Please click on the description located under "Details" on the right for more information.

Icon | Description | Details
 | Refresh: Graph is restored to original state. |
 | Save: Creates a Polymath Graph file as *.plg |
 | Save As: Creates a new Polymath Graph file as *.plg |
 | Open: Opens a Polymath Graph file |
 | Print: Prints the current Graph |
 | Copy: Copies the current Graph to the clipboard |
 | Curves and Functions: Allows selection of variable for revised Graph | Curves and Functions
 | Design: Allows changes in Graph properties | Design
 | Table: Creates data table for selected curves | Table

Curves and Functions

This option allows the displayed curves and functions to be modified. For the Example, this resulting window is shown below.

The pull-down menu for the "Indep Var:" allows any single variable from the Data Table to be displayed on the (X) axis. The checked boxes indicate the variables that will be displayed on the (Y) axis. These changes take place immediately on the Graph once the above window is modified. The "Label" button allows the name of the highlighted variable to be changed. The "Hide All" button removes all dependent variables from the (Y) axis, while the "Show all" button displays all the dependent variables with automatic scaling. The "Functions" button allows additional additional functions of only the Independent Variable (use x in generating the function expression). Functions can also be turned “on” and “off” just like the variables.

Design

This option presents a window that allows the modification of the Graph. The options as indicated by the taps at the top of the window as shown below are indicated. These provide the user with the capability to

Table

This option presents a Table of all the variables available to the Graph display. The Table for this Example is as follows.


Data Column Analysis

Data Column Statistical Analysis

See Also: Data Table

This option can be reached by selecting “Statistics” in the “Column” dropdown menu of the Data Table window as shown below for Data Table Example 2:

The data column statistical report is then presented which gives the sum, arithmetic mean, the standard deviation, and the variance for each column in the Data Table as shown below.


Linear and Polynomial Regression

Linear & Polynomial Regression

See Also: Multiple Linear Regression Nonlinear Regression Data Table

Polymath can fit a polynomial of degree n with the general form:

P(x) = a0 + a1*x + a2*x^2 + . . . + an*x^n

or a linear equation when the equivalent first degree polynomial is specified

P(x) = a0 + a1*x

where a0, a1, ..., an are regression parameters to a set of N tabulated values of x (a single independent variable) versus y (a single dependent variable). The highest degree allowed for a polynomial is N - 1 (thus n >= N - 1). The program calculates the coefficients a0, a1, ..., an by minimizing the sum of squares of the deviations between the calculated y or P(x) and the data for y.

The Data Table window for Example 3 is shown below where the tabs for 'Regression' and for 'Linear & Polynomial' have been selected.

The options available in this window are the following:

Dependent Variable:
Select the dependent variable for regression.

Independent Variable:
Select the independent variable for regression (indicated by 'x' in the regression equation above).

Polynomial Degree:
Select the degree of the polynomial (indicated by 'n' in equation above), select the '1 Linear' polynomial for linear regression.

Through origin:
If this option is marked, the free parameter is set to zero in the regression model (a0=0).

Polynomial Integration:
If this parameter is marked, the integral of the polynomial between the specified boundaries is calculated.

Polynomial Differentiation:
If this parameter is marked, the derivative of the polynomial at the specified point is calculated.

Export to Excel:
Click on this icon to automatically transfer this problem to Excel and to carry out the regression and the requested calculations.

Solve (pink arrow):
Click on this icon to carry out the regression and the requested calculations.

Graph:
If this option is marked, a graph showing the calculated curve (or points) and the data points is prepared and displayed.

Residuals:
If this option is marked, a graph showing the deviation between the data and the calculated values of the dependent variable (error, residuals) points is prepared and displayed.

Store Model in Column:
Store the regression model and the calculated parameters in the next available empty column.

Report:
If this option is marked, a report showing the regression model the numerical values and confidence intervals of the parameters and some additional statistical and other information are presented and displayed.

Linear and Polynomial Regression

To carry out a linear or polynomial regression, select the column name of the independent variable and the column name of the dependent variable and the order of the polynomial you wish to fit. If you know that the physical model represented by the data requires that a straight line or the polynomial should pass through the origin (i.e., if the independent variable's value is 0.0, then the dependent variable must also be 0.0), mark the "Through origin" cell. To obtain a plot of the calculated polynomial and the data points versus the independent variable, mark the "Graph" option. To obtain a residual plot, mark the "Residuals" option.

Note that you are allowed to mark several polynomial orders at once. In such case several reports, graphs etc. will be generated for the various order polynomials. For selecting the polynomial, which represents the data best see, the section of "Assessing the quality of regression models".

Example 1: Fitting Polynomial of Degree 1 - Heat Capacity Data of Solid Hydrogen Bromide.

Consider the data set shown below that is from Example 3 - "Heat capacity" in the Polymath REG Regression Program. The data set may be obtained within the Polymath REG program by clicking on the Examples button and holding until Example 3 : Heat capacity is highlighted. This should bring the data into the Polymath Data Table.

Then verify that the "Regression" tab and the "Linear & Regression" tab are selected. Indicate the Dependent Variable: Cp, Independent Variable: T, Polynomial Degree: 1 Linear, and check only Report. Press the purple arrow [image] to achieve a Polymath Report of the Polynomial Degrees (Linear Regression) solution that is shown below:

POLYMATH Report | Heat capacity of Hydrogen Bromide
Linear Regression | 28-Sep-2004

Model: Cp = a0 + a1*T

Variable | Value | 95% confidence
a0 | 8.13858 | 0.402096
a1 | 0.0216109 | 0.0027439

General
Regression including a free parameter
Number of observations = 18

Statistics

R^2 | 0.9457227
R^2adj | 0.9423303
Rmsd | 0.0245012
Variance | 0.0121562

Source data points and calculated data points

 | T | Cp | Cp calc | Delta Cp
1 | 118.99 | 10.79 | 10.710059 | 0.0799412
2 | 120.76 | 10.8 | 10.74831 | 0.05168994
3 | 122.71 | 10.86 | 10.790451 | 0.06954872
4 | 125.48 | 10.93 | 10.850313 | 0.07968658
5 | 127.31 | 10.99 | 10.889861 | 0.10013866
6 | 130.06 | 10.96 | 10.949291 | 0.01070873
7 | 132.41 | 10.98 | 11.000077 | -0.02007684
8 | 135.89 | 11.03 | 11.075283 | -0.04528271
9 | 139.02 | 11.08 | 11.142925 | -0.06292477
10 | 140.25 | 11.1 | 11.169506 | -0.06950615
11 | 145.61 | 11.19 | 11.28534 | -0.09534048
12 | 153.45 | 11.25 | 11.45477 | -0.2047698
13 | 158.03 | 11.4 | 11.553748 | -0.15374764
14 | 162.72 | 11.61 | 11.655103 | -0.04510268
15 | 167.67 | 11.69 | 11.762077 | -0.07207654
16 | 172.86 | 11.91 | 11.874237 | 0.03576298
17 | 177.52 | 12.07 | 11.974944 | 0.09505627
18 | 182.09 | 12.32 | 12.073705 | 0.24629454

Example 2: Fitting Polynomial of Degree 2 (with Graph and Residuals) - Heat Capacity Data of Solid Hydrogen Bromide.

Consider the data set from Example 3 - "Heat capacity" in the Polymath REG Regression Program. The data set may be obtained within the Polymath REG program by clicking on the Examples button and holding until Example 3 : Heat capacity is highlighted. This should bring the data into the Polymath Data Table. For this example, please click on the Regression tab at the bottom of the Data Table and select Dependent Variable: Cp, Independent Variable: T, Polynomial Degree: 2, and check Graph, Residuals, and Report. The solution will result in three separate windows that can be easily observed if the Windows button is clicked and Cascade selected. The front window given the Polymath Regression Report for the 2nd degree polynomial as shown below:

Polymath Regression Graph

The Polymath Regression Graph window output, given below, presents a scaled plot of the 2nd degree polynomial as a solid curve and the actual data points that were used in the filling of the polynomial as the circles. The allows you to visually determine the goodness of fit for the polynomial.

Polymath Regression Residuals Plot

The Polymath Regression Residuals Plot, given below, presents a scaled plot of the difference between the dependent variable, Cp in this case, for each of the input data points for the 2nd degree polynomial. It is desirable for the residuals to appear to be randomly placed about the zero line. This allows you to visually determine the goodness of fit for the polynomial.

Example 3: Fitting Polynomial of Degree 3 (with Integration and Differentiation) - Heat Capacity Data of Solid Hydrogen Bromide.

Consider the data set from Example 3 - "Heat capacity" in the Polymath REG Regression Program. The data set may be obtained within the Polymath REG program by clicking on the Examples button and holding until Example 3 : Heat capacity is highlighted. This should bring the data into the Polymath Data Table. A Polymath solution as indicated in the Input window shown below. Note that the "Regression" and "Linear & Polynomial" tabs have been pressed.

For this Example, please select the following options:

"Report" gives the problem results.

"Store Model in column" stores the calculated values for the polynomial in the Data Table under the selected column heading C03.

"Dependent Variable" allows selection of Cp.

"Independent Variable" allows selection of T.

"Polynomial Degree" allows section of 3.

"Through origin" eliminates the constant from the regression of the polynomial.

"Polynomial Integration" integrates the dependent variable T from T1 = 120 to T2 = 200 using the 3rd degree polynomial.

"Polynomial Derivative" calculates the derivation value when the independent variable T = 150 using the 3rd degree polynomial.

The Polymath Report for this problem gives the integration and differentiation results as reproduced below:

POLYMATH Report | Heat capacity of Hydrogen Bromide
Polynomial Regression | 22-Nov-2004

Model: Cp = a1*T + a2*T^2 + a3*T^3

Variable | Value | 95% confidence
a1 | 0.2314379 | 0.0082055
a2 | -0.0017116 | 0.0001102
a3 | 4.459E-06 | 3.64E-07

Analytical polynomial integration
Cp = 0.2314379*T -0.0017116*T^2 + 4.459E-06*T^3
Integ(Cp,T1,T2) = 0.115719 *T^2 -0.0005705*T^3 + 1.115E-06*T^4
T(1) = 120
T(2) = 200
Integ(Cp,T1,T2) = 936.3613

Analytical polynomial derivative
Cp = 0.2314379*T -0.0017116*T^2 + 4.459E-06*T^3
d(Cp)/d(T) = 0.2314379 -0.0034231*T + 1.338E-05*T^2
T = 150
d(Cp)/d(T) = 0.0189173

T | d(Cp)/d(T)
118.99 | 0.013498
120.76 | 0.0131151
122.71 | 0.0127902
125.48 | 0.0125037
127.31 | 0.012427
130.06 | 0.0124801
132.41 | 0.0126859
135.89 | 0.0132619
139.02 | 0.0140568
140.25 | 0.0144408
145.61 | 0.016587
153.45 | 0.0211104
158.03 | 0.0245138
162.72 | 0.0285804
167.67 | 0.0335107
172.86 | 0.039384
177.52 | 0.0452715
182.09 | 0.0516094

General
Degree of polynomial = 3
Regression not including a free parameter
Number of observations = 18

Statistics

R^2 | 0.994862
R^2adj | 0.994177
Rmsd | 0.0075383
Variance | 0.0012274

Source data points and calculated data points

 | T | Cp | Cp calc | Delta Cp
1 | 118.99 | 10.79 | 10.816737 | -0.02673712
2 | 120.76 | 10.8 | 10.840277 | -0.04027734
3 | 122.71 | 10.86 | 10.865518 | -0.00551848
4 | 125.48 | 10.93 | 10.900503 | 0.02949683
5 | 127.31 | 10.99 | 10.923301 | 0.06669898
6 | 130.06 | 10.96 | 10.957502 | 0.00249811
7 | 132.41 | 10.98 | 10.987043 | -0.00704301
8 | 135.89 | 11.03 | 11.032098 | -0.00209822
9 | 139.02 | 11.08 | 11.074784 | 0.0052164
10 | 140.25 | 11.1 | 11.092305 | 0.00769451
11 | 145.61 | 11.19 | 11.175117 | 0.01488307
12 | 153.45 | 11.25 | 11.321817 | -0.07181677
13 | 158.03 | 11.4 | 11.426082 | -0.02608211
14 | 162.72 | 11.61 | 11.550358 | 0.05964194
15 | 167.67 | 11.69 | 11.703763 | -0.01376327
16 | 172.86 | 11.91 | 11.892613 | 0.01738653
17 | 177.52 | 12.07 | 12.089635 | -0.01963513
18 | 182.09 | 12.32 | 12.310795 | 0.00920485

The Data Table has been updated with column C03 which contains the calculated Cp from the 3rd degree polynomial:

Simultaneous Polynomial Degrees

You can request treatment of several polynomial degrees by holding down the "CNTR" key and at the same time clicking on the desired degrees with the left button of the mouse. You may also check the "Residual" and "Graph" options to obtain the desired plots for all selected degrees, and then press the pink arrow to solve. A report containing the numerical results for the selected polynomials will be obtained along with separate graphs and residual plots for each polynomial.

Additional Useful Information

See Assessing the Quality of Regression Models.


Multiple Linear Regression

See Also: Linear & Polynomial Regression Nonlinear Regression Data Table Assessing Quality of Regression Models

This Polymath option will fit a linear function of the form:

y(x1, x2, ..., xn) = a0 + a1*x1 + a2*x2 + ... + an*xn

where a0, a1, ..., an are regression parameters, to a set of N tabulated values of x1, x2, ..., xn (independent variables) versus y (dependent variable). Note that the number of data points must be greater than n+1 (thus N >= n+1). The program calculates the coefficients a0, a1, ..., an by minimizing the sum of squares of the deviations between the calculated and the data for y.

Multiple Linear Regressions are carried out with the Polymath Data Table. The tab setting of "Regression" and "Multiple Linear" must be pressed as shown below for Example 4 in the Data Table window.

The options available in this window are the following:

Report:
If this option is marked, a report showing the regression model the numerical values and confidence intervals of the parameters and some additional statistical and other information are presented and displayed.

Graph:
If this option is marked, a graph showing the calculated points and the data points is prepared and displayed.

Store Model in column:
Store the regression model and the calculated parameters in the next available empty column.

Residuals:
If this option is marked, a graph showing the deviation between the data and the calculated values of the dependent variable (error, residuals) points is prepared and displayed.

Dependent Variable:
Select the dependent variable column name for regression from the pull-down menu.

Independent Variables:
Select the independent variables for regression (indicated by x1, x2, ... ,xn' in the regression equation above). Note that holding down the Cntr key while then pressing left button of the mouse will select more than one variable.

Through origin:
If this option is marked, the free parameter is set to zero in the regression model (a0 = 0).

Solve ( [image] ):
Carry out the regression and the additional calculations.

Example: Fitting a Multiple Linear Model to Heat of Hardening of Portland Cement versus Weight Percent of Components Data.

Consider the data that can be loaded into Polymath from Example 4 under the Examples drop-down menu in the "Data Table" window. Select hard_heat as dependent variable and Wpc1, Wpc2, Wpc3 and Wpc4 as independent variables. (Note that you must hold down on the left mouse key when clicking on each variable name.) It is known from theoretical considerations that the free parameter should be zero in this case, so mark the "Through origin" option. Mark also the "Residual" and "Graph" options. Also mark the "Store Model" option. The selections made are shown below.

Press the pink arrow [image] to solve. A report containing the numerical results as well as a residual plot and a graph showing the measured and calculated values are obtained.

Multiple Linear Regression Report

POLYMATH Report | Heat of hardening of portland cement
Multiple linear regression | 22-Nov-2004

Model: hard_heat = a1*Wpc1 + a2*Wpc2 + a3*Wpc3 + a4*Wpc4

Variable | Value | 95% confidence
a1 | 2.189177 | 0.4182687
a2 | 1.154136 | 0.1082325
a3 | 0.7532949 | 0.3601112
a4 | 0.4885452 | 0.093483

General
Number of independent variables = 4
Regression not including a free parameter
Number of observations = 13

Statistics

R^2 | 0.9806563
R^2adj | 0.9742084
Rmsd | 0.5568439
Variance | 5.822523

Source data points and calculated data points

 | Wpc1 | Wpc2 | Wpc3 | Wpc4 | hard_heat | hard_heat calc | Delta hard_heat
1 | 7 | 26 | 6 | 60 | 78.7 | 79.164242 | -0.46424225
2 | 1 | 29 | 15 | 52 | 74.3 | 72.362883 | 1.9371171
3 | 11 | 56 | 8 | 20 | 104.3 | 104.5098 | -0.20980244
4 | 11 | 31 | 8 | 47 | 87.6 | 88.84713 | -1.2471299
5 | 7 | 52 | 6 | 33 | 95.9 | 95.98105 | -0.0810505
6 | 11 | 55 | 9 | 22 | 109.2 | 105.08605 | 4.113948
7 | 3 | 71 | 17 | 6 | 102.7 | 104.24845 | -1.548447
8 | 1 | 31 | 22 | 44 | 72.5 | 76.035858 | -3.5358576
9 | 2 | 54 | 18 | 22 | 93.1 | 91.008981 | 2.0910185
10 | 21 | 47 | 4 | 26 | 115.9 | 115.93244 | -0.03243851
11 | 1 | 40 | 23 | 34 | 83.8 | 82.290922 | 1.5090779
12 | 11 | 66 | 9 | 12 | 113.3 | 112.89609 | 0.40390716
13 | 10 | 68 | 8 | 12 | 109.4 | 112.26189 | -2.8618926

Multiple Linear Regression Graph

Multiple Linear Regression Residuals

See the Assessing the Quality of Regression Models for more information on whether the multiple linear regression represents the data appropriately and whether all the selected variables should be included in the regression.


Nonlinear Regression

See Also: Linear & Polynomial Regression Multiple Linear Regression Data Table Regression Report

Nonlinear regression involves a general mathematical function (model) of the form:

y = f (x1, x2, …, xn, a0, a1, a2, …, am)

where a0, a1, …, an are regression parameters to a set of N tabulated values of x1, x2, …, xn (independent variables) versus y (dependent variable). Note that the number of data points must be greater than m + 1 (thus N >= m + 1). The Nonlinear Regression capability is reached from the Polymath Data Table by first clicking on the lower tab marked "Regression" and then clicking on the upper tab marked "Nonlinear". The window for entering a nonlinear model is shown below.

Model:
Type in a new regression model equation or edit an existing model equation.

Enter Initial Guess for Model Parameters:
After entering the model, an initial guess for all the parameters should be provided in this area.

Graph:
If this option is marked, a graph showing the calculated points and the data points is prepared and displayed.

Residuals:
If this option is marked, a graph is displayed showing the deviation between the individual data points and the corresponding values as calculated from the nonlinear model. Additionally, the residual plot is presented (difference between the actual and the calculated dependent variable for the entire data set)..

Store Model in Column:
This option creates a new column in the Data Table using the converged nonlinear regression model and the calculated parameters.

Report:
If this option is marked, a report showing the regression model the numerical values and confidence intervals of the parameters and some additional statistical and other information is presented and displayed.
Solve ( [image] ):
Clicking on this arrow will carry out the regression and generate the requested outputs.

Solution Details:

The nonlinear expression must be entered in the entry box. The left-hand side of the model equation must be the name of the dependent variable, and it is required that this name must be one on the names of an existing data column in the Data Table. After the "=" sign, an explicit expression must be entered that uses column names as variables. Additional variables that are used become parameters for the regression. The model (nonlinear expression) can utilize all the intrinsic functions available within Polymath. For description of valid names and expressions see the Variables and Expressions. Once the model has been entered with the appropriate syntax, the parameters window becomes active. Initial estimates are required for all the model parameters. For moderately nonlinear models, the program will find the best parameter values even though the initial estimates may be poor. For highly nonlinear models, good initial estimates are required. Initial estimates should always be realistic for the physical phenomena that are being described. It is very important that the calculated model values for the data set using the initial estimates are reasonable and of the same order of magnitude when compared to the dependent variable values in the data set. For difficult situations, it may be useful to linearize or simplify the model and use the multiple linear regression option to determine parameter values that can then be used as the initial estimates for the nonlinear regression. See the following section for a detailed discussion of techniques for linearization of nonlinear models.

The program uses the Levenberg-Marquardt (LM) algorithm as the default for finding the parameter values. The objective function that is minimized is the ithe sum of squares of the errors. The error is the difference between the actual value of the dependent variable and the calculated value of the dependent variable from the model expression. A detailed explanation of this method can be found, for example, in the book by Press et al. Two different implementations of the LM method are included. The LM technique is an iterative solution method that usually converges very rapidly, except when the Hessian matrix becomes nearly singular. In such cases, the algorithm switches to the steepest descent method, the convergence of which can be very slow. A nearly singular Hessian matrix often indicates that there are more parameters in the model than are justified by the data. In case of slow convergence, it is recommended that you stop the iterations and check the display of statistical analysis to verify the correctness of the number of model parameters.

If there are more parameters than really needed, the 95% confidence interval for most of the parameters will tend to be much larger than the parameter value itself. For converged results, the graphical and statistical information provided can be used for assessing the quality of the fit. For further details see Assessing the Quality of Regression Models.

Example: Calculation of the Parameters of the Antoine Equation

Consider the data that appear as Example 2 in the Examples drop-down menu in the Polymath "Data Table" window. The Antoine equation given below is to be determined from the given data points. The Antoine equation is of the form

logP = A + B/(TC + C)

where logP = log(P) and TC = T °C are columns in the Data Table and A, B, and C are the model parameters.

Initial estimates for the parameters given by A = 6, B = -1000, and C = 200 are used in this example.

From the Data Table window, a mouse click on the bottom "Regression" tab followed by a mouse click on the upper "Nonlinear" tab displays the nonlinear regression window. This window is shown below where the model and parameter initial guesses for this example are shown.

Note that the requested output of "Graph", "Residuals", and "Report" must be checked on the right side of this window. A simple mouse click on the pick arrow ( [image]) will initiate the solution to this nonlinear regression problem.

EXAMPLE REPORT

POLYMATH Report | Fitting Polynomials to vapor pressure data
Nonlinear Regression (L-M) |

Model: logP = A+B/(TC+C)

Variable | Initial guess | Value | 95% confidence
A | 6. | 5.767347 | 0.1520845
B | -1000. | -677.094 | 48.15908
C | 200. | 153.8854 | 5.687091

Nonlinear regression settings
Max # iterations = 64

Precision

R^2 | 0.9996879
R^2adj | 0.9995987
Rmsd | 0.0047228
Variance | 0.0003186

General

Sample size | 10
Model vars | 3
Indep vars | 1
Iterations | 11

Source data points and calculated data points

 | TC | logP | logP calc | Delta logP
1 | -36.7 | 0 | -0.0106273 | 0.0106273
2 | -19.6 | 0.69897 | 0.7251442 | -0.0261742
3 | -11.5 | 1 | 1.011984 | -0.0119843
4 | -2.6 | 1.30103 | 1.291739 | 0.0092914
5 | 7.6 | 1.60206 | 1.574434 | 0.0276258
6 | 15.4 | 1.7781513 | 1.767627 | 0.0105243
7 | 26.1 | 2 | 2.005407 | -0.0054074
8 | 42.2 | 2.30103 | 2.314289 | -0.0132593
9 | 60.6 | 2.60206 | 2.610516 | -0.0084558
10 | 80.1 | 2.8808136 | 2.873601 | 0.0072121

EXAMPLE GRAPH

EXAMPLE NONLINEAR REGRESSION GRAPH

EXAMPLE RESIDUALS

DETERMINATION OF INITIAL GUESSES

Successful convergence of a nonlinear regression model is often dependent upon the use of good initial guesses for the model parameters. Good initial parameter guesses can typically be obtained from a linearization of the nonlinear expression so that linear regression or multiple linear regression can utilized. In the above example, the denominator of the nonlinear regression model can be approximated by setting the parameter "C" equal to 273 which is equivalent to using the temperature in Kelvin. The linear regression for this approximation yields

Model: logP = a0 + a1*Trec

Variable | Value | 95% confidence
a0 | 8.752017 | 0.5423357
a1 | -2035.333 | 153.6285

Use of the initial guesses of A = 8.75, B = -2035 and C = 273 in the nonlinear regression model gives identical results to the above Example Report.

INTERPRETATION OF RESULTS

For further details see Assessing the Quality of Regression Models.


Polymath Export to Excel

E xporting from Polymath to Excel

See Also: Nonlinear Equations Solver Differential Equations Regression Package

The Polymath programs listed below currently have the capability to export problems directly to Excel 2000 and later. In all cases, the equations are automatically translated into the appropriate equations within Excel and utilize the available functions within Excel. Error messages are given when needed functions are not available. The exporting process results in a well-documented program that is ready to solve completely within Excel. The Excel problem will be setup and provide results in a very similar way to that of the Polymath program. In every case, the "Export to Excel" command from the Program menu or pressing the [image] button. Instructions for the use of Excel with exported problems the Polymath programs are discussed below.

Nonlinear Equations Solver

The Excel "Solver" Add-In or software from some other vendor must be used to solve the system of nonlinear equations. In the automated exporting process, a sum-of-squares of the functions that are to be zero at the solution is formed. Then you must use "Solver" to minimize this sum-of-squares function by altering the variables. The "Export to Excel" keypress opens up the problem in the Excel spreadsheet. The problem is translated to the first sheet in a workbook, and solutions are generated on additional workbook sheets. Details are available.

Differential Equations Solver

Polymath Software has created an ODE_Solver Add-In for Excel that is able to solve simultaneous ordinary differential equations. In the automated exporting process, these differential equations, their initial conditions are arranged for easy access and use by the Polymath ODE_Solver. You must use this Add-In to solve the problem by indicating the initial and final values for the independent variable. The problem is translated to the first sheet in a workbook, and solutions are generated on additional workbook sheets.

Installation Details for ODE_Soilver

Regression Program

Linear & Polynomial Regression and Multiple Linear Regression

The exporting process for the regression program listed above generates Excel programs that are completely executed at the time of export. These regressions and the associated statistics are produced through the use of Excel's LINEST function which yields and output array that is used in the spreadsheet area that report the results. Details of Excel use with Linear, Polynomial, and Multiple Linear Regression are available.

Nonlinear Regression

The exporting of a nonlinear regression program creates a problem in Excel that must be solver with the "Solver" Add-In that is available to users. Details of Excel use with Nonlinear Regression are available.


Nonlinear Equations Export

Exporting Nonlinear Equations from Polymath to Excel

See Also: Exporting from Polymath to Excel Nonlinear Equations Solver Variables and Expressions

The "Export to Excel" function of Polymath is found in the drop-down Program menu at the top of the Nonlinear Equations problem screen. A problem should be exported after it has been completely entered successfully into Polymath and ready for solution. The desired Excel Workbook must be opened on the desktop before the problem is exported to Excel. It is good practice to also solve the problem in Polymath so that the solution in Excel can be compared and verified. Upon export, the problem in Polymath will be completely transferred into Excel to a new Worksheet in the current Excel Workbook. This transfer automatically includes the translation of logical statements and the intrinsic functions from Polymath into equivalent functions within Excel. This transfer is conveniently illustrated by using Example 3 of the Nonlinear Problem Solver. The export can be initiated by either clicking on the Excel icon or selecting 'Export to Excel' from the Problem menu:

The resulting problem is opened up in a new worksheet within Excel as shown below:

Note that all of the information from Polymath has been transferred including the variable names, the values, the Polymath equations, and the comments. The Sum of Squares cell, which is highlighted in red, is created from the sum of the squares of the errors in the nonlinear equations of the problem. This cell value should become very small during the Excel solution.

The solution of the problem within Excel must utilize the "Solver" Add-In which is a part of the Excel software package, but you must be sure that it is installed. This is accomplished from the Tools/Add-In menu of Excel where Solver should be checked. The solution is initiated by going to Tools/Solver... and then filling out the Solver window as shown below:

Note that the target cell for minimization is cell $C$16, the Min of this cell is set, and the cells to be changed are $C$12 to $C$13 (indicated in pink). Pressing the Solve button gives the Solver solution. Note that the function that is minimized is the sum of squares of the nonlinear equations which should be very close to zero at the desired solution.

Click "OK" to keep the Solver solution. Note that this Excel solution with Solver calculates D = .03952 and fF = .004927 which compares well with the Polymath solution of D = .03897 and fF = .004591.


Differential Equations Export

Exporting Differential Equations from Polymath to Excel

See Also: Exporting from Polymath to Excel Nonlinear Equations Solver Variables and Expressions

The "Export to Excel" function of Polymath is found in the drop-down Program menu at the top of the Differential Equations problem screen. A problem should be exported after it has been completely entered successfully into Polymath and ready for solution. It is good practice to also solve the problem in Polymath so that the solution in Excel can be compared and verified. Upon export, the problem in Polymath will be completely transferred into Excel. This transfer automatically includes the translation of logical statements and the intrinsic functions from Polymath into equivalent functions within Excel. This transfer is conveniently illustrated by using Example 1 of the Differential Equations Solver. The transfer to Excel is carried out by either clicking on the Excel icon or selecting 'Export to Excel' from the Problem menu:

The resulting problem is opened up in a new spreadsheet within Excel as shown below:

Note that all of the information from Polymath has been transferred including the variable names, the values, the Polymath equations, and the comments. The actual ordinary differential equations, which are highlighted in red, are ready for a numerical solution. The initial conditions are colored cyanide. This initial condition of the independent variable is in the black box. This entire solution is entered into Excel with variable cell addresses; therefore, the complete solution can be copies to any other location with the spreadsheet book for execution.

A special Polymath ODE_Solver Add-In must be used to carry out the numerical integration. You must insure that Ode_Solver Add-In is installed in your Excel software. This is accomplished from the Tools/Add-In menu of Excel where Ode_Sover should be checked.

Click here for more information on the Ode_Solver and its installation within Excel.

The solution is initiated by going to Tools/Polymath ODE... and then filling out the Solver window as shown below:

Note that you must place the initial conditions in the upper left box labeled ODE initial values vector (Y), and this can be simply accomplished by clicking in the empty box and them immediately taking the mouse from the upper cell to the lower cell for the initial conditions. Similar operations identify the needed inputs to Ode_Solver. Note that the "Intermediate cells to Store" is a vector of the additional problem variables to calculate during the solution, and it is optional. The "Adv." button lets you select the integration algorithm and adjust other solution variables. Usually the default RKF45 is quite adequate for all problems.

Shortcut: The "Reload" button will set up the exported problem completely with the exception of the "Intermediate Cell to Store". This button will also restore the settings for a previous integration as well.

A click on the Solver button will initiate the numerical integration. The variables will change as the integration proceeds. After the integration has reached the final value of the independent variable, "t" in this case, you will have the option of retaining the solution (OK) or canceling the solution (Cancel).

The problems solution will be provided in a worksheet on the Excel spreadsheet labeled "DEQ Solution". Make sure to "Exit" the Ode_Solver before you continue. When you click on the solution worksheet, you find the details of the differential equations solution as shown below:

This output sheet is very similar to the Polymath Report reproduced below:

You can also add the variable names to their appropriate cells by using your mouse by copying an pasting the names from the main program worksheet. Advanced Excel users might want to consider using the "Rename" feature.

The remainder of the output sheet contains the variable information for each of the points requested for the integration.

The plotting feature of Excel can be used to generate the needed curves from this output table.


ODE_Solver

ODE_Solver - Excel Add-In for Solving Ordinary Differential Equations

See Also: Exporting D ifferential Equations from Polymath to Excel Exporting from Polymath to Excel Differential Equations Solver

The Add-In file name is ODE_Solver.xla

This Polymath ODE_Solver Add-In enables simultaneous ordinary differential equations to be solved within Microsoft Excel. The needed file for this Polymath option is stored by default in the C:\Program Files\Polymath Software\Polymath EDU Site 2011-12\ directory during installation of Polymath. The file may have been stored along with the other Polymath files in another directory that was specified during the Polymath installation. This Add-In must be manually installed within Excel as discussed below.

  • Installation of the ODE_Solver Add-In

  • Running the ODE Solver with Problem Exported from Polymath

  • Setting up the ODE Solver for an Excel Problem that has not been Exported from Polymath

  • Using the ODE Solver for an Example Excel Problem

Installation of the ODE_Solver Add-In

Background:

  1. This Add-In will only work with Excel 2000 or later Excel versions. Note that earlier versions of Excel before 2000 will not support the ODE_Solver Add-In.

  2. The Polymath program setup will install the needed file named 'ODE_Solver.xla' file found in the C:\Program Files\Polymath Software\Polymath EDU Site 2010-11\ directory OR another directory that was specified during the Polymath installation.

Installation (Please scroll down to your version of Microsoft Office)

Office 2000, XP, 2002, and 2003 - You should use the 'Add-Ins...' option under the Tools drop-down menu in Excel to 'Browse' and then find the ODE_Solver Add-In file named 'ODE_Solver.xla'. This file is placed in the default directory for Polymath during installation (or in some other location as specified during installation). The default location is C:\Program Files\Polymath Software\Polymath EDU Site 2011-12\. The identification of ODE_Solver file when you 'Browse' will make it available to Excel as an Add-In. Note that there may be interferences between 'ODE_Solver' Add-In and the 'Solver Add-In' provided within Excel such that the 'Solver' Add-in may not work properly. Note that the 'Solver Add-In' is used in the solution of nonlinear equations within Excel. Please only check the Add-In you desire to use in the 'Add-In' window under Tools drop-down menu in Excel as shown below:

Office 2007 - From the Excel program, you should go to Office Button and then to the Excel Options and select Add-Ins. Select the option at the bottom of the display to Manage "Excel Add-ins" and press Go. Select the option to "Browse" to locate the ODE_Solver Add-In file named 'ODE_Solver.xla'. This file is placed in the default directory for Polymath during installation (or in some other location as specified during installation). The default location is C:\Program Files\Polymath Software\Polymath EDU Site 2011-12\. The identification of ODE_Solver file when you 'Browse' will make it available to Excel as an Add-In under the Add-Ins tab in Excel 2007. There may be interferences between 'ODE_Solver' Add-In and the 'Solver' Add-In provided within Excel 2007 such that the 'Solver' Add-in may not work properly. Note that the 'Solver Add-In' is used in the solution of nonlinear equations within Excel. Please only check the Add-In you desire to use in the location: Office Button/Excel Options/Add-Ins/Manage Excel Add-ins as shown above.

Office 2010 - From the Excel program, you should click of the File tab, click Options, and click the Add-Ins category. In the Manage box, click Excel Add-Ins, and click Go. In the Add-Ins available box, click on Browse to locate the ODE_Solver Add-In file named 'ODE_Solver.xla'. This file is placed in the default directory for Polymath during installation (or in some other location as specified during installation). The default location is C:\Program Files\Polymath Software\Polymath EDU Site 2011-12\. The identification of ODE_Solver file when you Browse will make it available to Excel as an Add-In under the Add-Ins tab in Excel 2010. There may be interferences between 'ODE_Solver' Add-In and the 'Solver' Add-In provided within Excel 2010 such that the 'Solver' Add-in may not work properly. Note that the 'Solver Add-In' is used in the solution of nonlinear equations within Excel. Please only check the Add-In you desire to use for a particular Excel problem in the Add-Ins available box as shown above.

Running the ODE Solver with Problem Exported from Polymath

The details of using the ODE_Solver Add-In with an exported problem from Polymath into Excel are available from Exporting D ifferential Equations from Polymath to Excel.

Setting up the ODE Solver for an Excel Problem that has not been Exported from Polymath

The ODE_Solver can be used independently of the Polymath program. This allows Excel users to solve simultaneous ordinary differential equations that have been formulated in an Excel worksheet. The Polymath ODE entry window for the current problem information, shown below, becomes visible when the 'Polymath ODE...' Add-In is selected from the Excel Tools drop-down menu.

The problem solution specification requires that the following continuous groupings of cells, a single cell, and a single value within a problem worksheet:

  1. ODE (Ordinary Differential Equations) initial values vector - This vertical selection of continuous cells in the same column must contain the initial values of the respective dependent variables in the simultaneous ordinary differential equations. Note that each ODE must have an initial value specified.

  2. ODE equations vector - This vertical selection of continuous cells must contain the respective set of ordinary differential equations for the problem.

  3. Differential variable cell - This is the storage cell for the independent variable for the set of ordinary differential equations.

  4. Differential variable final value - A numerical value for the final value of the independent variable must be entered.

  5. Intermediate Cells to Store - This optional selection of continuous cells contains the problem variables that should be calculated during the numerical solution of the ODE's as the independent variable is varied from the initial to the final value.

Note that placement of the cursor within a input site in the Polymath ODE entry window allows one to use the mouse to conveniently identify a group of cells or an individual cell.

Show Report - When checked, this automatically produces a new worksheet in the current workbook that contains the current ODE problem solution.

Data Points - This value indicates the desired number of data points where the the problem variables and the 'Intermediate Cells to Store' are to be automatically calculated and stored within the Report worksheet as a table.

Using the ODE Solver for an Example Excel Problem

This example involves a simple set of simultaneous ordinary differential equations and explicit variables that is given by:

d(CA)/d(t) = -k1 * CA

CA(0) = 10

d(CB)/d(t) = k1 * CA - k2 * CB

CB(0) = 0

d(CC)/d(t) = k2 * CB

CC(0) = 0

k1 = 2

k2 = 4

xA = (10 - CA) / 10

t(0) = 0

t(f) = 3

An Excel workbook with this equation entered into a worksheet is shown below. Selection of the Polymath ODE_Solver Add-In results in the Polymath ODE input window where the problem solution specification has been completed.

A mouse click on the 'Solve' button initiates the solution proceeds, and the various values in the cells are updated during the numerical integration process. The final values are shown below.

The Polymath ODE_Solver Report is automatically generated on a new worksheet titled 'DEQ Solution (1)' which is shown below where the variable names have been copied from the original problem worksheet.

The Intermediate data points can be graphed within Excel as shown below:

Subsequent execution of the Polymath ODE_Solver will produce additional worksheets with the corresponding problem solution numbers.

ODE_Solver Window: The 'Reload' button will restore the settings for a previous integration with the exception of the 'Intermediate Cells to Store'.

The 'Adv.' button will allow selection of a desired numerical integration algorithm and adjustment of the methods parameters as shown below.

The default algorithm of RKF45 is very robust and very suitable for most problems.


Linear & Polynomial Regression Export

Exporting Linear & Polynomial Regression from Polymath to Excel

See Also: Exporting from Polymath to Excel Variables and Expressions

The "Export to Excel" capability in the Data Table is executed by clicking on the Excel icon [image] found on the particular regression window. You must have your Excel program active on your desktop before exporting a program to Excel. A problem should be exported after it has been completely entered successfully into Polymath and ready for solution. It is also good practice to also solve the problem in Polymath so that the solution in Excel can be compared and verified. Upon export, the problem in Polymath will be completely transferred into Excel. This transfer automatically includes the translation of logical statements and the intrinsic functions from Polymath into equivalent functions within Excel.

Linear & Polynomial Regression

Example 1: Fitting Polynomial of Degree 1 - Heat Capacity Data of Solid Hydrogen Bromide.

Consider the data set shown below that is from Example 3 - Heat capacity in the Polymath REG Regression Program. The data set may be obtained within the Polymath REG program by clicking on the Examples button and holding until Example 3 : Heat capacity is highlighted. This should bring the data into the Polymath Data Table.

Select the Regression tab and the Linear & Polynomial tab at the right side of the Data Table. Select Dependent Variable: Cp, Independent Variable: T, Polynomial Degree: 1 Linear, and check only Report. (This is also indicated on the above window and may automatically be displayed when accessing Example 3.)

Press the Excel icon [image] to have this problem exported and automatically solved within an Excel spreadsheet:

Note that this problem has been automatically transformed and solved within the open Excel spreadsheet on a new worksheet. The results agree with the results obtained with Polymath for this same problem as shown below as discussed in more detail in Example 1 of Linear & Polynomial Regression.

Linear Regression 28-Sep-2004

Model: Cp = a0 + a1*T

Variable | Value | 95% confidence
a0 | 8.13858 | 0.402096
a1 | 0.0216109 | 0.0027439

General
Regression including a free parameter
Number of observations = 18

Statistics

R^2 | 0.9457227
R^2adj | 0.9423303
Rmsd | 0.0245012
Variance | 0.0121562

Note that the intrinsic function LINEST is used in the Excel solution of this linear regression problem.

Example 2: Fitting Polynomial of Degree 2 (with Graph and Residuals) - Heat Capacity Data of Solid Hydrogen Bromide.

Consider the data set from Example 3 - "Heat capacity" in the Polymath REG Regression Program. The data set may be obtained within the Polymath REG program by clicking on the Examples button and holding until Example 3 : Heat capacity is highlighted. This should bring the data into the Polymath Data Table. For this example, please click on the Regression tab at the bottom of the Data Table and select Dependent Variable: Cp, Independent Variable: T, and Polynomial Degree: 2 .

Press the Excel icon [image] to have this problem exported and automatically solved within an Excel spreadsheet:

Note that this problem has been automatically transformed and solved within the open Excel spreadsheet on a new worksheet. The results agree with the results obtained with Polymath for this same problem as shown below as discussed in more detail in Example 2 of Linear & Polynomial Regression for a 2nd degree polynomial.

POLYMATH Report | Heat capacity of Hydrogen Bromide
Polynomial Regression | 26-Oct-2004

Model: Cp = a0 + a1*T + a2*T^2

Variable | Value | 95% confidence
a0 | 14.43818 | 1.68923
a1 | -0.0643514 | 0.0229501
a2 | 0.0002877 | 7.67E-05

General
Degree of polynomial = 2
Regression including a free parameter
Number of observations = 18

Statistics

R^2 | 0.9896808
R^2adj | 0.9883049
Rmsd | 0.0106832
Variance | 0.0024652

The Polymath Graph can be produced within Excel by graphing both the "Cp calc" column as a line and the "Cp" column as a symbol on the Y axis versus the "T" column on the X axis.

Similarly the Polymath Regression Residual Plot can be produced within Excel:


Multiple Linear Regression Export

Exporting Multiple Linear Regression from Polymath to Excel

See Also: Exporting from Polymath to Excel Variables and Expressions

The "Export to Excel" capability in the Data Table is executed by clicking on the Excel icon [image] found on the particular regression window. You must have your Excel program active on your desktop before exporting a program to Excel. A problem should be exported after it has been completely entered successfully into Polymath and ready for solution. It is also good practice to also solve the problem in Polymath so that the solution in Excel can be compared and verified. Upon export, the problem in Polymath will be completely transferred into Excel. This transfer automatically includes the translation of logical statements and the intrinsic functions from Polymath into equivalent functions within Excel.

Multiple Linear Regression

Example: Fitting a Multiple Linear Model to Heat of Hardening of Portland Cement versus Weight Percent of Components Data

Consider the data set shown below that is from Example 4 - Heat of hardening in the Polymath REG Regression Program. The data set may be obtained within the Polymath REG program by clicking on the Examples button and holding until Example 4 : Heat of hardening is highlighted. This should bring the data into the Polymath Data Table.

A mouse click on the Regression tab at the right of the Data Table followed by another mouse click on the Multiple linear tab should bring up the window shown below.

Select Dependent Variable: hard_heat and the Independent Variables: Wpc1,Wpc2,Wpc3, and dWpd4. (Note that you must hold down on the left mouse key when clicking on each variable name.) This problem is to be solved with the "Through origin" option checked. The Excel program must be open prior to the export of the Polymath program. A single mouse click on the Excel icon [image] results in the automatic export and solution of the problem in a new worksheet in Excel as shown below.

The regression calculations within Excel agree with the results obtained with Polymath for this same problem as shown below in Example 4 - "Heat of hardening" from the Polymath REG Regression Program.

POLYMATH Report | Heat of hardening of portland cement
Multiple linear regression | 26-Oct-2004

Model: hard_heat = a1*Wpc1 + a2*Wpc2 + a3*Wpc3 + a4*Wpc4

Variable | Value | 95% confidence
a1 | 2.189177 | 0.4182687
a2 | 1.154136 | 0.1082325
a3 | 0.7532949 | 0.3601112
a4 | 0.4885452 | 0.093483

General
Number of independent variables = 4
Regression not including a free parameter
Number of observations = 13

Statistics

R^2 | 0.9806563
R^2adj | 0.9742084
Rmsd | 0.5568439
Variance | 5.822523

Note that the intrinsic function LINEST is used in the Excel solution of this multiple linear regression problem.

Multiple Linear Regression Graph (created in Excel from generated results)

Multiple Linear Regression Residuals (created in Excel from generated results)


Nonlinear Regression Export

Exporting Nonlinear Regression from Polymath to Excel

See Also: Exporting from Polymath to Excel Nonlinear Regression Variables and Expressions

The "Export to Excel" capability in the Data Table is executed by clicking on the Excel icon [image] found on the particular regression window. You must have your Excel program active on your desktop before exporting a program to Excel. A problem should be exported after it has been completely entered successfully into Polymath and ready for solution. It is also good practice to also solve the problem in Polymath so that the solution in Excel can be compared and verified. Upon export, the problem in Polymath will be completely transferred into Excel. This transfer automatically includes the translation of logical statements and the intrinsic functions from Polymath into equivalent functions within Excel.

Nonlinear Regression

Example: Calculation of the Parameters of the Antoine Equation

Consider the data set shown below that is from Example 2 - Vapor Pressure Data in the Polymath REG Regression Program. The data set may be obtained within the Polymath REG program by clicking on the Examples button and holding until Example 2 is highlighted. This should bring the data into the Polymath Data Table. Note that the original data of TC and P have been transformed for regression purposes.

The Antoine equation is of the form

logP = A + B/(TC + C)

where logP = log(P) and TC = T °C are predefined columns and A, B, and C are parameters.

A mouse click on the Nonlinear Regression tab on the right side of the Polymath Data Table should bring up the Nonlinear Regression window. Entry of the problem into the Model using columns names from the Data Table and parameters A, B, and C is shown below. Note that after the Model syntax is correct, then the Initial Guesses for the Model Parameter should be entered.

The Excel program must be open prior to the export of this Polymath program to Excel. A single mouse click on the Excel icon [image] results in the automatic export and setup of the problem in a new worksheet in the open Excel workbook as shown below.

Note that the pertinent information from Polymath problem has been transferred including the particular problem variables from the Data Table, the values, and the regression equation. The Sum cell, which is highlighted in yellow, is created from the sum of the squares of the errors between the independent variable, logP, and the calculated variable from the regression, logP calc. This cell value should be minimized during the Excel solution.

The solution of the problem within Excel must utilize the "Solver" Add-In which is a part of the Excel software package, but you must be sure that it is installed. This is accomplished from the Tools/Add-In menu of Excel where Solver should be checked. The solution is initiated by going to Tools/Solver... and then filling out the Solver window as shown below:

Note that the "By Changing Cells:" input is set to the three cells containing the initial guesses of the parameters A, B, and C as specified by $H$4:$J$4 and can be entered with the mouse with standard Excel entry. Pressing the Solve button gives the Solver solution.

Click "OK" to keep the Solver solution. Note that this Excel solution with Solver gives the same regression result as is obtained with the Polymath program for this same problem. See Polymath Nonlinear Regression Example.


Polymath Export to Matlab

See Also: Nonlinear Equations Solver Differential Equations Advanced Setup

The Polymath programs listed below currently have the capability to produce files that contain the equations and comments in a format for Matlab. In addition, these files are organized in the order of solution that is an additional requirement for MATLAB use.

Requesting MATLAB Files

The equations and comments from the Nonlinear Equation Solver and the Differential Equations Solver can be shown in MATLAB format. This requires specific Polymath Settings as indicated in the following discussion.

Nonlinear Equations Solver

The Advanced Setup for Nonlinear Equations under the "Show MATLAB formatted in report" should be set to "True" as shown in the following window.

This setting provides additional output in the Polymath Nonlinear Equations Report as shown below for Example 3 that can be copied directly into the MATLAB editor.

Differential Equations Solver

The Advanced Setup for Ordinary Differential Equations under the "Show MATLAB formatted in report" should be set to "True" as shown in the following window.

This setting provides additional output in the Polymath Differential Equations Report as shown below for Example 1 that can be copied directly into the MATLAB editor.

Templates for MATLAB Files

More details on the creation of MATLAB files from the formatted problem output from the Nonlinear and Differential Equations Solvers are available from materials that follow. Updated materials are available from the Polymath Web Site:

http://www.polymath-software.com/MATLAB/

MATLAB Conversion of Polymath Problems - Drivers for the NLE and ODE functions from Polymath

1. Single Nonlinear Equation

The MATLAB program template for a Polymath program involving a single nonlinear equation is given in the box below. This can be copied into the MATLAB editor alnd saved as OneNLEtemplate.m for future use.

function % Insert here your file name after function (Use Alphanumberic name only)
clear, clc, format short g, format compact
xguess= % Replace this line with the xguess line(s) from Polymath report
disp('Variable values at the initial estimate');
disp([' Unknown value ' num2str(xguess) ' Function Value ' num2str(NLEfun(xguess))]);
xsolv=fzero(@NLEfun,xguess);
disp(' Variable values at the solution');
disp([' Unknown value ' num2str(xsolv) ' Function Value ' num2str(NLEfun(xsolv))]);
%- - - - - - - - - - - - - - - - - - - - - -
% Replace this and the following line with the function copied from the Polymath report
% Do not include the xguess line(s)

The example Polymath program from the Polymath HELP section on the Nonlinear Equation Solver is given in the box below. This can be copied into the Polymath Editor while in the Nonlinear Equation Solver and used to generate the MATLAB code.

f(T) = x1 * P1 + x2 * P2 - 760
P1 = 10 ^ (6.85221 - 1064.63 / (T + 232.0))
P2 = 10 ^ (6.87776 - 1171.53 / (T + 224.366))
x1 = 0.1
x2 = 0.9
T(min) = 36
T(max) = 70

The generated MATLAB code from the Polymath Report is given in the box below.

xguess = 53. ;
function fT = NLEfun(T);
P1 = 10 ^ (6.85221 - (1064.63 / (T + 232)));
P2 = 10 ^ (6.87776 - (1171.53 / (T + 224.366)));
x1 = 0.1;
x2 = 0.9;
fT = x1 * P1 + x2 * P2 - 760;

Introduction of the MATLAB code from the Polymath report into the MATLAB program template for a single nonlinear equation yields the complete m-file that is given below.

function OneNLEexample

clear, clc, format short g, format compact

xguess = 53. ;

disp('Variable values at the initial estimate');

disp([' Unknown value ' num2str(xguess) ' Function Value ' num2str(NLEfun(xguess))]);

xsolv=fzero(@NLEfun,xguess);

disp(' Variable values at the solution');

disp([' Unknown value ' num2str(xsolv) ' Function Value ' num2str(NLEfun(xsolv))]);

%- - - - - - - - - - - - - - - - - - - - - -

function fT = NLEfun(T);

P1 = 10 ^ (6.85221 - 1064.63 / (T + 232.0));

P2 = 10 ^ (6.87776 - 1171.53 / (T + 224.366));

x1 = 0.1;

x2 = 0.9;

fT = x1 * P1 + x2 * P2 - 760;

The MATLAB result when running the above m-file is

Variable values at the initial estimate
Unknown value 53 Function Value -223.4561
Variable values at the solution
Unknown value 63.6645 Function Value 1.1369e-013

2. Several Nonlinear Equations

The MATLAB program template for a Polymath program involving a single nonlinear equation is given in the box below. This can be copied into the MATLAB editor and saved as MultipleNLEtemplate.m for future use.

function % Insert here your file name after function (Use Alphanumberic names only)
clear, clc, format short g, format compact
xguess= % Replace this line with the xguess line(s) from Polymath report
disp('Variable values at the initial estimate');
fguess=MNLEfun(xguess);
disp(' Variable Value Function Value')
for i=1:size(xguess,2);
disp([' x' int2str(i) ' ' num2str(xguess(i)) ' ' num2str(fguess(i))]);
end
options = optimset('Diagnostics',['off'],'TolFun',[1e-9],'TolX',[1e-9]);
xsolv=fsolve(@MNLEfun,xguess,options);
disp('Variable values at the solution');
fsolv=MNLEfun(xsolv);
disp(' Variable Value Function Value')
for i=1:size(xguess,2);
disp([' x' int2str(i) ' ' num2str(xsolv(i)) ' ' num2str(fsolv(i))])
end
%- - - - - - - - - - - - - - - - - - - - - -
% Replace this and the following line with the function copied from the Polymath report
% Do not include the xguess line(s

An example Polymath program from the Polymath HELP section of the Nonlinear Equation Solver is given in the box below. This can be copied into the Polymath Editor while in the Nonlinear Equation Solver and used to generate the MATLAB code.

f(CA1) = k * CA1 ^ 2 - v * (CA0 - CA1) /
V
f(V)
= k * CA2 ^ 2 - v * (CA1 - CA2) / V
k = 0.075
v = 30
CA0 = 1.6
CA2 = 0.2 * CA0
CA1(0) = 1
V(0) = 300

The generated MATLAB code from the Polymath Report is given in the box below.

  xguess
  = [1. 300.]; % initial guess vector
function fx
  = MNLEfun(x);
CA1 = x(1);
V = x(2);
k = 0.075;
v = 30;
CA0 = 1.6;
CA2 = 0.2 * CA0;
fx(1,1) = k * CA1 ^ 2 - (v * (CA0 - CA1) / V);
fx(2,1) = k * CA2 ^ 2 - (v * (CA1 - CA2) / V);

Introduction of the MATLAB code from the Polymath report into the MATLAB program template for several nonlinear equations yields the complete m-file that is given below.

function MultipleNLEexample
clear, clc, format short g, format compact
xguess = [1. 300.]; % initial guess vector
disp('Variable values at the initial estimate');
fguess=MNLEfun(xguess);
disp(' Variable Value Function Value')
for i=1:size(xguess,2);
disp([' x' int2str(i) ' ' num2str(xguess(i)) ' ' num2str(fguess(i))]);
end
options = optimset('Diagnostics',['off'],'TolFun',[1e-9],'TolX',[1e-9]);
xsolv=fsolve(@MNLEfun,xguess,options);
disp('Variable values at the solution');
fsolv=MNLEfun(xsolv);
disp(' Variable Value Function Value')
for i=1:size(xguess,2);
disp([' x' int2str(i) ' ' num2str(xsolv(i)) ' ' num2str(fsolv(i))])
end
%- - - - - - - - - - - - - - - - - - - - - -
function fx = MNLEfun(x);
CA1 = x(1);
V = x(2);
k = 0.075;
v = 30;
CA0 = 1.6;
CA2 = 0.2 * CA0;
fx(1,1) = k * CA1 ^ 2 - v * (CA0 - CA1) / V;
fx(2,1) = k * CA2 ^ 2 - v * (CA1 - CA2) / V;

The MATLAB result when running the above m-file is

Variable values at the initial estimate
Variable Value Function Value
x1 1 0.015
x2 300 -0.06032
Optimization terminated successfully:
Relative function value changing by less than OPTIONS.TolFun
Variable values at the solution
Variable Value Function Value
x1 0.602 -6.4852e-013
x2 1101.5493 -2.1504e-013

3. Differential Equations

The MATLAB program template for a Polymath program involving differential equations is given in the box below. This can be copied into the MATLAB editor and saved as MultipleDEQtemplate.m for future use.

function % Insert here your file name after function (Use Alphanumberic names only)
clear, clc, format short g, format compact
tspan= % Replace this line with tspan line from Polymath report
y0= % Replace this line with y0 line from Polymath report
disp(' Variable values at the initial point ');
disp([' t = ' num2str(tspan(1))]);
disp(' y dy/dt ');
disp([y0 ODEfun(tspan(1),y0)]);
[t,y]=ode45(@ODEfun,tspan,y0);
for i=1:size(y,2)
disp([' Solution for dependent variable y' int2str(i)]);
disp([' t y' int2str(i)]);
disp([t y(:,i)]);
plot(t,y(:,i));
title([' Plot of dependent variable y' int2str(i)]);
xlabel(' Independent variable (t)');
ylabel([' Dependent variable y' int2str(i)]);
pause
end
%- - - - - - - - - - - - - - - - - - - - - -
% Replace this and the following line with the function copied from the Polymath report
% Do not include the tspan and y0 lines

An example Polymath program from the Polymath HELP section of the Differentialr Equation Solver is given in the box below. This can be copied into the Polymath Editor while in the Nonlinear Equation Solver and used to generate the MATLAB code.

d(A)/d(t) = -k1 * A
d(B)/d(t) = k1 * A - k2 * B
d(C)/d(t) = k2 * B
k1 = 1
k2 = 2
A(0) = 1
B(0) = 0
C(0) = 0
t(0) = 0
t(f) = 3

The generated MATLAB code from the Polymath Report is given in the box below.

tspan
= [0 3.]; % Range for the independent variable
y0 = [1.; 0; 0]; % Initial values for the dependent variables
function dYfuncvecdt
= ODEfun(t,Yfuncvec);
A = Yfuncvec(1);
B = Yfuncvec(2);
C = Yfuncvec(3);
k1 = 1;
k2 = 2;
dAdt
= 0 - (k1 * A);
dBdt
= k1 * A - (k2 * B);
dCdt
= k2 * B;
dYfuncvecdt
= [dAdt;
dBdt;
dCdt];

Introduction of the MATLAB code from the Polymath report into the MATLAB program template for several differential equations yields the complete m-file that is given below.

function MultipleDEQexample
clear, clc, format short g, format compact
tspan = [0 3.]; % Range for the independent variable
y0 = [1.; 0; 0]; % Initial values for the dependent variables
disp(' Variable values at the initial point ');
disp([' t = ' num2str(tspan(1))]);
disp(' y dy/dt ');
disp([y0 ODEfun(tspan(1),y0)]);
[t,y]=ode45(@ODEfun,tspan,y0);
for i=1:size(y,2)
disp([' Solution for dependent variable y' int2str(i)]);
disp([' t y' int2str(i)]);
disp([t y(:,i)]);
plot(t,y(:,i));
title([' Plot of dependent variable y' int2str(i)]);
xlabel(' Independent variable (t)');
ylabel([' Dependent variable y' int2str(i)]);
pause
end
%- - - - - - - - - - - - - - - - - - - - - -
function dYfuncvecdt = ODEfun(t,Yfuncvec);
A = Yfuncvec(1);
B = Yfuncvec(2);
C = Yfuncvec(3);
k1 = 1;
k2 = 2;
dAdt = -k1 * A;
dBdt = k1 * A - k2 * B;
dCdt = k2 * B;
dYfuncvecdt = [dAdt; dBdt; dCdt];

A portion of the MATLAB result when running the above m-file is

Variable values at the initial point

t = 0

y dy/dt

1 -1

0 1

0 0

Solution for dependent variable y1

t y1

0 1

5.0238e-005 0.99995

0.00010048 0.9999

0.00015071 0.99985

0.00020095 0.9998

0.00045214 0.99955

0.00070333 0.9

An example MATLAB plot (Graph of variable y2 that represents B) is shown below.


Polymath Utilities

See Also: Polymath Calculator Polymath Units Converter Polymath Scientific Constants

Three separate utilities are provided to users from within the Polymath program as shown below,

and these are also available from the Windows Start/Programs/Polymath Software location for separate use as a stand-alone utility.

The Polymath Calculator allows an entered expression to be evaluated. The calculator can allow simple or complex calculations with many intrinsic functions. Complex sequential calculations can be easily documented. The calculator window pops up upon activation.

The Polymath Unit Converter provides conversion from one set of units to another. For each type of units, there are numerous sets of units that can be converted from/to with this utility. The calculator window pops up on activation.

The Polymath Scientific Constants presents a wide selection of the more relevant constants for scientific and engineering work. You may choose to add your own special constants to the handy pop-up utility.


Advanced Scientific Calculator

Calculator

See Also: Polymath Units Converter Polymath Scientific Constants Variables and Expressions

The POLYMATH calculator allows you to enter an expression to be evaluated. The calculator can be very beneficial for carrying out simple or more complicated sequential calculations and keeping documentation of the equations and the results. The "basic" form of the calculator's window is shown below.

 Erase Expression:
Pressing the Esc key deletes the entire expression appearing in the "expression" box. (This is used mainly when entering a new expression.)

Main Calculator Window Options
 Solve (Enter or [image] ):
When this button is pressed, the expression is evaluated and the solution is shown in the appropriate box.

On Top:
Selecting this option keeps the calculator window on top of all the windows on your desktop.

Access to Calculator Help:

Additional Calculator Options:

The options indicated on this window include the available intrinsic functions, the numeric format, the commands buffer, the desired input, and the results display control. Note that in Results, all the previously entered expressions and the calculated results are shown. There are options to "copy" a marked section of this field, to copy everything inside this field using "Copy All" and to clear this field by pressing "Clear"

Online Calculator Syntax Help:
The options indicated below appear when entering "Help" followed by Enter or [image]:

ENTERING AND EVALUATING EXPRESSIONS
An expression may be typed or copied into the calculator window and evaluated by a mouse click on [image] or by a keypress of function key F5. (You may also have specified the CR to be "Solve" in the Calculator Options Display, and the Enter key will then also solve the calculation.) Note that an expression may contain numbers, arithmetic operators, intrinsic functions, and previously defined local variables. Scientific notation can also be used to enter numbers. The calculator will recognize 'E' or 'e' as being equivalent to the notation '*10^'. For example, these two strings are equivalent: 4.71*10^6 = 4.71e6 . The expressions and the solution values can be copied by marking the part of the expression to be copied and using either the menu obtained by pressing the right mouse button or by holding down "Cntr" and pressing "C" on the keyboard. The copied expression can be inserted in a different window by marking the location it should be inserted and using either the menu obtained by pressing the right mouse button or by holding down "Cntr" and pressing "V" on the keyboard.

Calculator Examples

Example 1. This example provides a simple calculation of one of the roots of the quadratic equation: x^2-12*x+35 = 0

You should type the following expression into the calculator:

Pressing [image] with the mouse or the F5 function key places the calculation result in the solution box. (You may also have specified the CR to be "Solve" in the Calculator Options Display, and the Enter key will also carry out the calculation.)

USE OF LOCAL VARIABLES

The assignment capability is a way of storing your results. You may specify a variable name in which to store the result of a computation by first typing in the variable name, then an equals sign, then the expression you wish stored. For example, if you wished to store the value of sin(4/3)^2 in variable 'a', you would enter: a = sin(4/3)^2 . You may then use variable 'a' in any subsequent expression, and POLYMATH will use the value stored in the variable. These variables are stored as long as you do not return to the POLYMATH main menu. Variable names must start with a letter and can contain letters and digits. There is no limit on the length of variable names or on how many variables you can use. Note that the calculator distinguishes between lower- and upper-case letters, so the variables 'MyVar2' and 'myvar2' are NOT the same. Further discussion of valid variable names and expressions can be found in Variables and Expression.

Example 2. This example utilizes local variables to calculate one of the roots of the quadratic equation: a*x^2+b*x+c=0 for the values a=1, b=-12 and c=35

First the numerical value of the variables a, b and c should be defined. (Note that a mouse click on the <eraser> button or pressing the ESC keyboard clears the current expression). After that the expression for x1 can be entered, as shown below. There is a separate list of the local variables and their numerical value. A variable can be marked and deleted (press "Delete" with the mouse) or its numerical value can be changed (press "Modify" with the mouse).

 USE OF THE IF FUNCTION
Sometimes you may need to make conditional calculations. For such calculations a special 'if' function is available, with the following syntax: if (condition) then (expression) else (expression). The parentheses are optional. The condition(s) may include the following operators: >, <, >=, <=, == (equals).

Example 3. In this example the drag coefficient (Cd) is calculated using the following equations:
Cd=24/Re if Re<0.1 and Cd=(24/Re)(1+0.14Re^0.7) for Re>=0.1
where Re=Dp*vt*rho/vis.

The complete set of equations, including the solution for one particular set of data values is shown below.


Units Convertor

Units Converter

See Also: Polymath Calculator Polymath Scientific Constants

The POLYMATH unit conversion utility allows you to convert selected units. The unit converters’ window is shown below where you can select the type of unit, set the number and specific unit, specify the desired unit, and the conversion will be found in the "Equal To:" box. This number can then be copied to other locations.

Sample of the classes of the available unit conversions as well as the listing of the various units available in each class are given below:

Unit | Measures
Length | meter, centimeter, millimeter, nanometer, inch, mile, yard, foot, micron, angstrom
Mass | kilogram, gram, milligram, pound, ton (metric), ton (long), ton (short)
Area | square meter, square feet, square centimeter, square millimeter, square inch
Energy | joule, kilo-joule, erg, cal, hphr, liter atm, kwh, Btu, ft-lb, kg m2/s2
Temperature | Celsius, Fahrenheit, Kelvin, Rankine
Temp. Difference | delta degree Celsius, delta degree Fahrenheit, delta degree Kelvin, delta degree Rankine
Pressure | pascal, kilo-pascal, mm Hg (torr), atm, bar, psi [ lb-f/sq in],in Hg
Force | newton, kg, lb, poundal, dyne, g cm/s2, kg m/s2
Power | watt, kilo-watt, joule/sec, cal/sec, Btu/sec, hp(metric), hp(British), ft lbf/sec
Volume | cu. meter, cu. centimeter, liter, cu. feet, Imperial gal, gal (U.S.), barrel (oil)

UNIT CONVERSION EXAMPLE

Suppose you want to convert 100 BTU’s to kilo-joules. First you have to select the “type of the unit” as “Energy”. Next, you should type in “100” in the upper “Convert” box and select “Btu” in the lower “from” box. The conversion factor result is in the "Equals To:" box.

The conversion is carried out immediately after any changes are made. The result obtained is: 105.5075. Note that this result can be copied by marking the part of the number to be copied and pressing “Cntr” and “C”. The copied number can be inserted in a different window by marking the destination location and pressing “Cntr” and “V”.

OPTIONS

The "File" menu presents some options for this utility. This is shown below where the "On Top" option has been activated.:

On Top: | When active, this keeps the Units Converter window on top of all the active programs within your Windows desktop.
Calc Digits: | This option brings up a window in which you can select the number of digits for calculated values.
Load Units Database As... | Special units databases can be loaded.
Save Existing Units Database As... | Special units databases can be saved after modification.
Admin | This option (normally dimmed) allows you to customize your own units database - see below

ADDING CUSTOM UNITS

Unlocking/Locking Administrative Options

You can add your own custom units by multiple keypress Cntl+Shift+U to unlock the Administration options (Clicking Cntl+Shift+L will lock/disable the administration rights). These options must be accomplished from the main Polymath Units Conversion window is active. When active, the "Admin" option is available in the "File" menu.

Setup Units Option - This administrative option is available from the File/Admin/Setup Units/(Modify/Delete) menu or from the main Polymath Unit Conversion window by the shortcut keypress CtrlL+E. The unit displayed in the main window is the one that can be modified or deleted as shown below where the conversion from [Unit A] to [N] is divided by C1 and then add C2.

Add Units Option - This administrative option is available from the File/Admin/Setup Units/Add menu or from the main Polymath Unit Conversion window by the shortcut keypress CtrlL+A. The unit displayed in the main window is the one that can be modified or deleted as shown below where the conversion from [Unit A] to [N] is divided by C1 and then add C2.

Setup Units Category Option - This administrative option is available from the File/Admin/Setup Unit Category menu or from the main Polymath Unit Conversion window by the shortcut keypress CtrlL+U.

Load Units Database - This option allows you to load a Units database that has been created. Note that the default Polymath database has file name units.mdb and is usually stored in the main Polymath Software directory under Programs on your computer.

Save Existing Units Database As - This option allows you to store a Units database that has been created. This should normally be stored in the main Polymath Software directory under Programs on your computer.


Scientific Constants

See Also: Units Converter Calculator

The POLYMATH “Scientific constants” utility provides values of constants that are frequently used in engineering and science. The “Mathematics” window is shown below.

The following options are available:

On Top: Selecting this option (from the Units Tab) keeps the window on top of all the other windows.

: This button copies the highlighted constant so that you can paste it into a document.

Samples of the constant classes as well as the listing of the various constants available in each class are given below:
# | Class | Constants
1 | Atmospheric conditions at sea level | Temperature, Pressure, Density of air, Viscosity of air
2 | Earth science | Mean distance of Earth to Sun, Mass of the Sun, Mass of the Earth
3 | Fundamental physical constants | Avogadro constant, Boltzman constant, Speed of light, Elementary charge, Electron mass, Faraday constant, Plank constant, Rydberg constant, Bohr radius, Newtonian constant of gravitation, Permittivity of vacuum, Permeability of vacuum, Standard gravitational acceleration, Stefan-Boltzmann constant, Universal gas constant
4 | Gas constant (available in the following units) | ft * lbf / (pound mole * R), atm * ft^3 / (pound mole * R), J / (Kmol * K), cm-Hg * m^3 / (Kmol K), erg/ (gmol * K), l * atm / (gmol * K), atm * cm^3 / (gmol * K), J / (gmol * K), Btu / ( poundmole * R), gram-calorie / (gmol * K), psi * ft^3 / (lbmol * R)
5 | Mathematics | Pi, Euler constant
6 | Properties of air | Molecular mass, Gas Constant, Heat capacity, Ratio of heat capacities, Viscosity
7 | Properties of water | Molecular mass, Gas constant, Heat capacity, Ratio of heat capacities, Triple point temperature

Additional classes are: Volume of Ideal Gas, Heat Transfer Conversion Factors, Mass Transfer Conversion Factors, and Thermodynamic Conversion Factors.

ADDING CUSTOM CONSTANTS

You can add your own custom constants by modifying the file constant.txt file in the directory where your Polymath program files were installed. This is usually in the Polymath Software subdirectory of your Programs directory. You can edit this ASCII file using Notepad or any other text editor. The rules for entering the constants are explained in the file constant.txt.

Important: Save a copy of the original constant.txt file before modifying it. If the file modification rules are not followed properly the "useful constants" utility may fail.

EXAMPLE FOR FINDING A CONSTANT’S VALUE

Suppose you want to find the universal gas constant in units of: (liter*atm)/(gmol*K). First you select “Universal gas constant” as type of the constant and then you choose the desired units. The desired value is shown below.


Polymath Setup

Setup

See Also: Troubleshooting Nonlinear Equations Troubleshooting Differential Equations

Several general program parameters and parameters of numerical solution algorithms can be adjusted by the user. The adjustable parameters can be reached by pressing “setup”. After changing a parameter its value is kept until it is changed again by the user or its default value is "restored". There is also the "Reset All" option to restore all the parameter values to their default value. Note that reloading POLYMATH does not change the stored parameter values.

Following is a brief description of the adjustable parameters, their default values and their significance in numerical computations.

Data table

1. Initial number of columns: The total number of columns in the table - Default value = 30

2. Initial number of rows: The total number of rows in the table - Default value = 300

General

1. Show Polymath logo upon startup -Default value = True

2. Show recent files startup dialog - Default value = False

3. Show status bar - Default value = True

4. Maximize sub windows - Default value = True

5. Undo buffer size - Default value = 20

Graph

1. Use vertical gridlines - Default value = False.
2. Use horizontal gridlines - Default value = False.
3. Default marker size - Default value = 70
4. Default title = Graph Title
5. Default subtitle - blank
6. Query for save on close - Default value = False

Linear equations (LIN)

1. Initial number of equations - Default value = 5
2. Show equations in report - Default value = False

Nonlinear equations (NLE)

1. Reporting digits - Default value = 9
2. Calculate initial guess values - Default value = False
3. Font name - Default value = Arial
4. Font size - Default value = 9.75
5. Auto color syntax - Default value = True

6. Auto unpaint on Byte size - Default value = 70
7. Show comments in report - Default value = True

8. Show MATLAB formatted problem in report - Default value = False

The parameter names and their default values in the various algorithms are shown in the table below:

 | fastnewt | safenewt | safebroyd | constrained
Max # iterations | 150 | 150 | 150 | 150
Tolerance f, functions | 1.00E-07 | 1.00E-07 | 1.00E-07 | -
Tolerance x, unknowns | 1.00E-07 | 1.00E-07 | 1.00E-07 |
Tolerance min |  | 1.00E-07 | 1.00E-07 |
Relative convergence tolerance |  |  |  | 1.00E-07

In the iterative solution of the nonlinear algebraic equations the algorithms fastnewt, safenewt and fastbroyd use the absolute function values and the relative x corrections for convergence test. If the maximal, absolute function value is smaller than “Tolerance f” or the maximum, relative x correction is smaller than “Tolerance x” the iterations are stopped and the solution is accepted as a valid solution. Safenewt and safebroyd include function minimization along the Newton or Broyden directions. If a normalized gradient value along this direction is smaller than “Tolerance min” it is assumed that the convergence is to a local minimum, the iterations are stopped and the solution is not accepted. In “constrained” the norm of the relative x correction values is checked against the “Relative error tolerance”. If the norm is smaller than the tolerance the iterations are stopped and the solution is accepted.

In case of no convergence, possible remedial actions include tolerance, and maximum number of iteration changes. For suggestions in this respect see the “Troubleshooting” section.

Ordinary differential equations (DEQ)

1. Reporting digits - Default value = 9
2. Intermediate data points - Default value = 100

  • Intermediate data points: The number of equally spaced points along the solution where values are being stored. Default value = 100. If the solution curves appear to be non-smooth, broken lines the number of data points must be increased (maximum 500 points). Note however that increasing the number of data points may lead to memory shortage problems especially if there are many equations in the system.

3. Show intermediate data points on report - Default value = False
4. Font name - Default value = Arial
5. Font size - Default value = 9.75

6. Auto color syntax - Default value = True

7. Auto unpaint on Byte size - Default value = 70

8. Show comments in report - default value = True

9. Show MATLAB formatted problem in report - Default value = False

The additional parameter names and their default values in the various algorithms are shown in the table below:

 | RKF45 | RKF56 | BS | STIFF | STIFFBS
Initial step size | 1.0E-06 | 1.0E-06 | 1.0E-05 | 1.0E-04 | 1.0E-03
Truncation error tolerance | 1.0E-06 | 1.0E-06 |  |  |
Scaled truncation error tolerance |  |  | 1.0E-05 | 1.0E-05 | 1.0E-05
Minimum allowed step-size |  |  | 1.0E-08 | 1.0E-08 | 1.0E-05

In the numerical solution of ordinary differential equations, all algorithms in the program adjust the integration step-size in order to reduce the estimate of the local truncation error below a specified error tolerance. “Initial step size” is the step size with which the integration starts, the step size is being increased or decreased so that to keep the maximal truncation error estimate (scaled with the respective dependent variable values) below the “Scaled truncation error tolerance”. If the specified tolerance requires reducing the step-size below the “Minimum allowed step-size” the integration stops and the error message “Step-size is too small” is displayed. Possible remedial actions that can be taken in such case are discussed in the “Troubleshooting” section.

Regression, Nonlinear

mrqmin

1. Maximum number of iterations - Default value = 64

2.Tolerance: Tolerance for the sum of squares of the differences between the calculated and measured values of the dependent variable. Default value =0.0001

LM (Levenberg-Marquardt)

The convergence rate of the Levenberg-Marquardt algorithm, used for solution, can often be slow. Furthermore, the default error tolerance may not be sufficient to obtain accurate results. It is a good practice to run a problem for which solution has been found, starting with the parameter values that were found as solution with smaller error tolerance. If the converged solution yields parameter values close to the previous ones the solution is accurate enough. Otherwise the tolerance should be further reduced.


Assessing Quality of Regression Models

Assessing the Quality of Regression Models

See Also: Linear & Polynomial Regression Multiple Linear Regression Nonlinear Regression

The statistical indicators and the various plots provided by the Polymath program can be used to assess the quality of the regression models and to compare between various models. A practical guide for the use of the indicators and plots for these purposes follows:

Graph: This creates a plot of the calculated and measured values of the dependent variable. When the plots show different trends, this usually indicates an inappropriate model. If the difference between the measured and calculated points is large, but no clear trend exists, this may also indicate very “noisy” data (excessive experimental error) that cannot be accurately modeled.

Residual plot: The residual plot shows the difference between the calculated and measured values of the dependent variable as function of the measured values. If the regression model represents the data correctly, the residuals should be randomly distributed around the line of err=0 with zero mean. If the residuals show a clear trend, this indicates that an inappropriate model is being used. (For example, a straight-line representation is used instead of a polynomial.) If there is a point where the residual (error) is much larger, in absolute value, than in the rest of the points this may be indication of an “outlier”, which can be removed under certain circumstances.

Confidence intervals: For the regression model to be stable and statistically valid, the confidence intervals must be much smaller (or at least smaller) than the respective parameter values (in absolute values). An unstable model may yield very inaccurate derivative values and absurd results for even a small range of extrapolation. For an unstable model, a small change in the data (by adding or removing a data point, for example) may lead to large changes of the parameter values.

R2 and R2adj: The correlation coefficients are frequently used to judge whether the model represents correctly the data, implying that if the correlation coefficient is close to one then the regression model is correct. There are, however, many examples where the correlation coefficient is close enough to one but the model is still not appropriate. The residual plot should be used for judging the appropriateness of the model while the correlation coefficients can be used for comparing various models representing the same dependent variable.

In the following formulas, n is the number of scores (or observations) and yi is a specific observation. The notation "obs" relates to observed data and the notation "calc" relates to calculated data.

Variance and Rmsd: Just like the correlation coefficients, these two indicators are recommended to be used for comparing various models representing the same dependent variable. A model with smaller variance and Rmsd represents the data more accurately than a model with larger values of these indicators.

The following equations describe the Variance (s2), Standard Deviation (s), and Chi-Square respectively:

Reference: Selection of the most appropriate regression model is discussed in detail by Shacham et al (1996b)

Examples

Example 1: Insufficient Number of Terms/parameters in the Model

Note that this problem is Example 2 under the Examples drop-down menu in the Data Table window.

TC | P | TK | logP | Trec | logT | T2
-36.7 | 1 | 236.45 | 0 | 0.004229 | 2.373739 | 55908.6
-19.6 | 5 | 253.55 | 0.69897 | 0.003944 | 2.404064 | 64287.6
-11.5 | 10 | 261.65 | 1 | 0.003822 | 2.417721 | 68460.72
-2.6 | 20 | 270.55 | 1.30103 | 0.003696 | 2.432248 | 73197.3
7.6 | 40 | 280.75 | 1.60206 | 0.003562 | 2.44832 | 78820.56
15.4 | 60 | 288.55 | 1.778151 | 0.003466 | 2.460221 | 83261.1
26.1 | 100 | 299.25 | 2 | 0.003342 | 2.476034 | 89550.56
42.2 | 200 | 315.35 | 2.30103 | 0.003171 | 2.498793 | 99445.62
60.6 | 400 | 333.75 | 2.60206 | 0.002996 | 2.523421 | 1.11E+05
80.1 | 760 | 353.25 | 2.880814 | 0.002831 | 2.548082 | 1.25E+05

In this example a model including logP as dependent variable and Trec as independent variable (Clapeyron's equation) is fitted to the data that has been transformed in the Data Table prior to the Linear Regression. The model also includes a free parameter. Some of the results appearing on the "Report" display are shown below.

Model: logP = a0 + a1*Trec

Variable | Value | 95% confidence
a0 | 8.752017 | 0.5423357
a1 | -2035.333 | 153.6285

General
Regression including a free parameter
Number of observations = 10

Statistics

R^2 | 0.9915016
R^2adj | 0.9904393
Rmsd | 0.024644
Variance | 0.0075916

The "Report" above shows that both R^2 and R^2adj are very close to one, the variance is small, and the 95% confidence intervals are much smaller than the parameter values. From those results we get the (false) impression that the data are represented correctly by the linear equation involving the transformed variables. The residual plot (shown below) shows, however, a clear curvature indicating that that this model is insufficient for precise representation of the data.

Better results are obtained when more of the transformed variables are utilized in a multiple linear regression.

Example 2: Excessive Number of Terms/parameters in a Polynomial Model

Note that this problem is Example 3 - Heat Capacity under the Examples drop-down menu in the Data Table window.

In this example, a 3rd order polynomial including P as dependent variable and T as independent variable is fitted to the data. The model also includes a free parameter. Some of the results appearing on the "Report" screen are shown below.

Model: Cp = a0 + a1*T + a2*T^2 + a3*T^3

Variable | Value | 95% confidence
a0 | -4.710354 | 10.32547
a1 | 0.3273543 | 0.2104189
a2 | -0.002356 | 0.0014169
a3 | 5.887E-06 | 3.153E-06

General
Degree of polynomial = 3
Regression including a free parameter
Number of observations = 18

Statistics

R^2 | 0.9951909
R^2adj | 0.9941604
Rmsd | 0.007293
Variance | 0.0012309

For this example both R^2 and R^2adj are very close to one, the variance is small but the 95% confidence interval for the free parameter a0 is much larger than the parameter value itself. This may indicate that the free parameter is not needed. Carrying out the regression again but marking the "Through origin" option yields the following results:

Model: Cp = a1*T + a2*T^2 + a3*T^3

Variable | Value | 95% confidence
a1 | 0.2314379 | 0.0082055
a2 | -0.0017116 | 0.0001102
a3 | 4.459E-06 | 3.64E-07

General
Degree of polynomial = 3
Regression not including a free parameter
Number of observations = 18

Statistics

R^2 | 0.994862
R^2adj | 0.994177
Rmsd | 0.0075383
Variance | 0.0012274

The regression without the free parameter has very little effect on R^2 and the variance but now all the 95% confidence intervals are much smaller than the parameter values. This indicates that the 3rd order polynomial without free parameter representation of the data is more statistically valid and stable.

Example 3: Excessive Number of Terms/parameters in Multiple Linear Regression

Note that this problem is Example 4 - Heat of hardening under the Examples drop-down menu in the Data Table window.

This example illustrates a multiple linear regression with hard_heat as dependent variable and W%1, W%2, W%3, and W%4 as independent variables. The model also includes a free parameter. Some of the results appearing on the "Report" screen are shown below.

Model: hard_heat = a0 + a1*Wpc1 + a2*Wpc2 + a3*Wpc3 + a4*Wpc4

Variable | Value | 95% confidence
a0 | 60.89893 | 161.6172
a1 | 1.562729 | 1.717796
a2 | 0.5265028 | 1.669402
a3 | 0.1125452 | 1.740721
a4 | -0.1266181 | 1.635414

General
Number of independent variables = 4
Regression including a free parameter
Number of observations = 13

Statistics

R^2 | 0.9823245
R^2adj | 0.9734867
Rmsd | 0.5322918
Variance | 5.985442

This regression produces both R^2 and R^2adj values that are close to one, but the fairly large value of the variance indicates that the data are noisy.
The 95% confidence intervals for all the parameters are larger than the parameter values themselves. There is also some trend that can be seen in the residual plot (see below).

In this case physical considerations indicate that the data must be modeled with a multiple linear regression model that does not include a free parameter. Repeating the solution while marking the "Through origin" option yields the following results:

Model: hard_heat = a1*Wpc1 + a2*Wpc2 + a3*Wpc3 + a4*Wpc4

Variable | Value | 95% confidence
a1 | 2.189177 | 0.4182687
a2 | 1.154136 | 0.1082325
a3 | 0.7532949 | 0.3601112
a4 | 0.4885452 | 0.093483

General
Number of independent variables = 4
Regression not including a free parameter
Number of observations = 13

Statistics

R^2 | 0.9806563
R^2adj | 0.9742084
Rmsd | 0.5568439
Variance | 5.822523

The elimination of the free parameter has very little effect on R^2 and the variance, but now all the 95% confidence intervals are considerably smaller than the parameter values. This indicates that the linear model, without free parameter representation of the data, is statistically valid and stable. It is interesting to compare the parameter values for the cases or with and without free parameter. In can be seen that the differences are very substantial and the derivative of "hard_heat" with respect to W4 (value of parameter a4) may change from positive to negative if the inappropriate model is used. The error distribution when using the statistically valid model is fairly random, as shown in the residual plot below:


Data Analysis

See Also: Regression Data Table

Tabulated data often cannot be represented satisfactorily by a regression model or it can be difficult to find such a model. Polymath can be used to help you interpolate, differentiate, integrate and plot data for which no regression model is available. Note, however, that if an adequate model is available, then its use is preferable to the use of the options discussed. Furthermore, if the data contains smooth and non-smooth regions, it is recommended that such regions are separated before starting the analysis because methods that give accurate results for smooth regions may give absurd results in non-smooth regions. In any case extrapolation of the data is not recommended, and Polymath won’t allow extrapolation in any of the analysis options.

The window that allows selection of the type of the data analysis is one of the tabs at the bottom of the Data Table. The options available in this window are the following.
Interpolation | Calculate the value of the dependent variable for a specified value of the independent variable
Differentiation | Calculate the derivative of the dependent variable for a specified value of the independent variable
Integration | Calculate the integral of the dependent variable for a specified region of the independent variable
Independent variable | Select the independent variable(s) for the analysis.
Dependent variable | Select the dependent variable for the analysis.
Solve with | Select the solution method.
Solve (Pink arrow icon) | Carry out the analysis.

The number of data points included in the analysis is also shown (as N= <number> ).

The Data Table options are shown below for Analysis and Interpolation and for all Analysis discussions in HELP. The data are from Example 3 - "Heat capacity" in the Polymath REG Regression Program.

Detailed additional information is available for the following subjects:

  • Interpolation
  • Differentiation
  • Integration
  • Graph preparation
  • Data column analysis


Interpolation

See Also: Regression & Data Analysis Differentiation Integration Data Table

The “Interpolation” dialog box from the Analysis tab of the Polymath Regression and Analysis Program is shown below. These data are from Example 3 - "Heat capacity" in the Polymath REG Regression Program. To carry out interpolation, you should select first the independent variable name and the dependent variable’s name from the scroll-down menus. After specifying the independent variable value, the dependent variable value is calculated at this point. Note that the selected independent variable value must lie inside the region where data is available.

Three algorithms are available for interpolation: Rational function (RATINT), Cubic spline (SPLINT) and Linear (LINEAR). In linear interpolation a straight line is passed through the two data points adjacent to the independent variable value for which extrapolation is requested. In cubic spline interpolation, a curve is passed through the two adjacent point so that the curve is smooth in its first derivative and continuous in its second derivative. In rational fraction interpolation the data is approximated by rational functions, that is quotients of polynomials. The various methods are discussed in detail in pp. 99-110 of Press et al. For data that can be represented with a smooth function with fairly regular shape, the rational fraction interpolation should be used. For non-smooth data with irregular shape (broken lines with sharp edges), the linear interpolation is the best. In between these two extreme cases the cubic spline interpolation yields the most accurate values. Polymath gives a warning message if there are large differences in the values obtained using the different interpolation techniques.


Integration

See Also: Regression Interpolation Differentiation Data table

The “Integration” dialog box is shown below. These data are from Example 3 - "Heat capacity" in the Polymath REG Regression Program. To find the integral of a dependent variable over a range of an independent variable you should select first the independent variable’s name and the dependent variable’s name. After specifying a lower and upper limit for the independent variable the integral (area under the curve) is calculated over the specified region. Note that both the lower and the upper limits of the independent variable value must lie inside the region where data is available.

Three algorithms are available for integration: Gauss-Legendre orthogonal polynomial approximation (GAULEG), Simpson’s rule (QSIMP and SIMPSON) and Cubic spline approximation (SPLINE). The various methods are discussed in detail in pp. 123-145 of Press et al. For data that can be represented with a smooth function with fairly regular shape the Cubic spline approximation can be used. The program gives a warning message if there is large differences in the values obtained using the different techniques.

In the screen display shown above, the integral CpdT is calculated from the lower bound of 120 K up to the upper bound of 180 K for the data of Example Problem 3. The calculated integral value (using a cubic spline function) is 680.37 and the estimated error is essentially zero. Calculating the integral using alternative methods shows that the calculated value is very accurate indeed.


Differentiation

See Also: Regression Interpolation Integration Data table

The “Differentiation” dialog box from the Differentiation tab of the Polymath Regression and Analysis program is shown below. These data are from Example 3 - "Heat capacity" in the Polymath REG Regression Program. To find the first derivative of a dependent variable with respect to an independent variable, you should select first the independent variable’s name and the dependent variable’s name. After you specifiy the independent variable value, the first derivatives’ value is calculated at this point. Note that the selected independent variable value must lie inside the region where data is available.

Three algorithms are available for interpolation: Linear (STANDA), Lagrange polynomial (LAGRANGE) and Cubic spline (SPLINE). In linear interpolation, a straight line is passed through the two data points adjacent to the independent variable value for which the derivative is requested. In cubic spline interpolation a curve is passed through the two adjacent point so that the curve is smooth in its first derivative and continuous in its second derivative. In Lagrange polynomial approximation, the data is approximated by a polynomial which passes through all the data points. The various methods are discussed in detail in pp. 99-110 of Press et al . For data that can be represented with a smooth function with fairly regular shape, the Lagrange approximation can be used. For non-smooth data with irregular shape (broken lines with sharp edges), the linear approximation is the best. In between these two extreme cases, the cubic spline approximation yields the most accurate values. The program gives a warning message if there are large differences in the values obtained using the different techniques.

In the screen display shown above, the derivative d(Cp)/dT is calculated at 120 K for this data set. The calculated derivative value (using a cubic spline function) is 0.0054875 and the estimated error is about 24%. There is a warning that the calculated value may be inaccurate. The data of example 2 are indeed not smooth enough. These data should be smoothened by fitting a statistically valid polynomial to the data set. For these particular data a 3rd order polynomial passing through the origin is the most appropriate. Using such a polynomial to calculate the derivative at the same temperature gives d(Cp)/d(T)=0.0132692, which is very different from the spline function value, indeed.


Polymath Capabilities

There are many versions of Polymath 6.2 that are available to users. These are identified on the main Polymath menu page. The following capabilities apply to Polymath 6.2 and depend on the particular version:

Module | Limitation | Educational Versions | Professional Version
POLYMATH | Min # of represented digits | 9 | 8
POLYMATH | Max # of represented digits | 20 | 22
LEQ | Max # of simultaneous linear equations | 100 | 264
NLE | Max # of simultaneous nonlinear equations | 30 | 300
NLE | Max # of simultaneous explicit equations | 40 | 300
DEQ | Max # of simultaneous differential equations | 30 | 300
DEQ | Max # of simultaneous explicit equations | 40 | 300
DEQ | Max # of intermediate data points | 151 | 1200
REG | Max polynomial regression degree | 5 | 12
REG | Max nonlinear regression model variables | 60 | 60
REG | Max nonlinear regression independent variables | 60 | 60
Data Table | Max # of rows (data points) | 301 | 1001
Data Table | Max # of columns | 50 | 200


License Agreements

License Agreement

License Agreement for Educational Institutions

The authors of POLYMATH and the CACHE Corporation agree to provide this site license version of Polymath titled “Polymath EDU Site License.”

This site license allows unlimited use and unlimited distribution of this version to current faculty, staff and teaching assistants of the licensing educational institution for educational use in computer labs, on computer networks, and on computers owned by the institution or by these individuals. Distribution to individual students and any other individuals is strictly prohibited.

Students are given various options for purchase of Polymath Educational software and faculty/staff who are consulting or have left the educational institution must update to the Professional Version at the POLYMATH web site:

http://www.polymath-software.com/

Permission to otherwise copy, distribute, modify or otherwise create derivative works of this software is prohibited.

This software is provided AS IS, WITHOUT REPRESENTATION AS TO ITS FITNESS FOR AND PURPOSE, AND WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, including with limitation the implied warranties of merchantability and fitness for a particular purpose. The authors of POLYMATH and the CACHE Corporation shall not be liable for any damages, including special, indirect, incidental, or consequential damages, with respect to any claim arising out of or in connection with the use of the software even if users have not been or are hereafter advised of the possibility of such damages.

License Agreement for an Individual at an Educational Institution

The authors of POLYMATH agree to license this Educational Version of POLYMATH to the owner for noncommercial and educational uses exclusively. Only one copy of this software is to be in use on only one computer or computer terminal at any one time.

This individual-use educational license is for POLYMATH Version 6.2 and applies to the owner of this software. Permission to otherwise copy, distribute, modify or otherwise create derivative works of this software is prohibited.

Students who have graduated must update to the individual Professional Version that can be purchased at the POLYMATH web site:

http://www.polymath-software.com

This software is provided AS IS, WITHOUT REPRESENTATION AS TO ITS FITNESS FOR AND PURPOSE, AND WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, including with limitation the implied warranties of merchantability and fitness for a particular purpose. The authors of POLYMATH shall not be liable for any damages, including special, indirect, incidental, or consequential damages, with respect to any claim arising out of or in connection with the use of the software even if users have not been or are hereafter advised of the possibility of such damages.

License Agreement for an Individual Professional User

The authors of POLYMATH agree to license this Professional Version of POLYMATH to the owner of this software. Only one copy of this software is to be in use on only one computer or computer terminal at any one time.

This individual-use license is for POLYMATH Version 6.2. Permission to otherwise copy, distribute, modify or otherwise create derivative works of this software is prohibited. Internet distribution is not allowed under any circumstances.

This software is provided AS IS, WITHOUT REPRESENTATION AS TO ITS FITNESS FOR AND PURPOSE, AND WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, including with limitation the implied warranties of merchantability and fitness for a particular purpose. The authors of POLYMATH shall not be liable for any damages, including special, indirect, incidental, or consequential damages, with respect to any claim arising out of or in connection with the use of the software even if users have not been or are hereafter advised of the possibility of such damages.

License Agreement for the Demonstration Version

The authors of POLYMATH agree to license this Demonstration Version of POLYMATH 6.2 for evaluation purposes and is intended for noncommercial and educational uses exclusively.

Permission is hereby granted to copy and distribute to others for evaluation purposes only.

Detailed information on the various versions of POLYMATH can be obtained from:

http://www.polymath-software.com

This software is provided AS IS, WITHOUT REPRESENTATION AS TO ITS FITNESS FOR AND PURPOSE, AND WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, including with limitation the implied warranties of merchantability and fitness for a particular purpose. The authors of POLYMATH shall not be liable for any damages, including special, indirect, incidental, or consequential damages, with respect to any claim arising out of or in connection with the use of the software even if users have not been or are hereafter advised of the possibility of such damages.

License Agreement for a Special Educational Version

The authors of POLYMATH agree to license this Educational Version of POLYMATH to the owner of this Prentice Hall textbook for noncommercial and educational uses exclusively. Only one copy of this software is to be in use on only one computer or computer terminal at any one time.

This individual-use license is for POLYMATH Version 6.2 and applies to the owner of this software. Permission to otherwise copy, distribute, modify or otherwise create derivative works of this software is prohibited.

Students who have graduated must update to the individual professional version that can be purchased at the POLYMATH web site:

http://www.polymath-software.com

This software is provided AS IS, WITHOUT REPRESENTATION AS TO ITS FITNESS FOR AND PURPOSE, AND WITHOUT WARRANTY OF ANY KIND, EITHER EXPRESS OR IMPLIED, including with limitation the implied warranties of merchantability and fitness for a particular purpose. The authors of POLYMATH shall not be liable for any damages, including special, indirect, incidental, or consequential damages, with respect to any claim arising out of or in connection with the use of the software even if users have not been or are hereafter advised of the possibility of such damages.


Contact Polymath Software

Polymath Home Page

http://www.polymath-software.com

Polymath Corporate Sales

sales@polymath-software.com

Polymath Academic sales

academic@polymath-software.com

Polymath Webmaster

webmaster@polymath-software.com


References

See Also: Main

  1. Bader, G. and Deuflhard, P. 1983, Numerische Mathematik, Vol. 44, pp. 373-398.
  2. Forsythe, G.E., M.A. Malcolm, and C.B. Moler, Computer Methods for Mathematical Computation, Prentice-Hall, Englewood Cliffs, 1977.
  3. Press, W.H., P.B. Flannery, S.A. Teukolsky and W.T. Vetterling, Numerical Recipes, 2nd Ed., Cambridge University Press, Cambridge, 1992.
  4. Shacham, M., “Numerical Solution of Constrained Nonlinear Algebraic Equations”, International Journal of Numerical Methods in Engineering, 23, 1455-1481 (1986)
  5. Shacham, M., N. Brauner, and M. Pozin, "Application of Feedback Control Principles for Solving Differential-Algebraic Systems of Equations in Process Control Education", Computers chem. Engng. 20(Suppl), s1329-s1334 (1996a)
  6. Shacham, M., N. Brauner and M. B. Cutlip, "Replacing the Graph Paper by Interactive Software in Modeling and Analysis of Experimental Data",Comput. Appl. Eng. Educ.,4(3),241-251(1996b)


Curves and Functions

See Also: Graph

The current independent variable name is shown inside the indicated box. A different independent variable can be selected from the list of names given in the same box.

The dependent variables shown on the graph can be turned “on” and “off” by clicking the associated check box. A variable which is turned “off “ is not shown on the graph and its values are not taken into account by the automatic scaling routine (unless the Auto Scale option is turned off).

The name of a depended variable can be changed by marking it and then clicking on the "Label" button

There is also an option to add function curves to the graph. An expression for such a function may contain the variable “x” as the independent variable. To enter a function mark the “Functions” option and enter in the dialog box that opens the required expression (for example: sin(x)). Functions can also be turned “on” and “off” just like the variables.

Derived curves can be built from other existing curves by clicking the Add button when the "Scatters" option is marked.


Graph

Graph Editing

See Also: Curves and Functions Differential Equations Solver

The graph editing options can be reached using either the “Curves”, “Xaxis” and “Yaxis” options or by pressing the appropriate icon on the right toolbar.

The following options are available:

Max Y axis: | Change the upper bound on the Y (vertical) axis
Min Y axis: | Change the lower bound on the Y (vertical) axis
Max X axis: | Change the upper bound on the X (horizontal) axis
Min X axis: | Change the lower bound on the X (horizontal) axis
Connected: | Show the curve connecting the calculated and/or stored data points.
Draw points: | Show the calculated and/or stored data points.

At least one of the options: “Scatter connected” and “Draw points” must be marked otherwise an empty graph is shown.

Auto scale: Determines whether the program automatically changes the scale as users remove/add function curves.
Curves and Functions: Option to remove variables and to add function plots to the graph. See more detailed explanation below.
Title: Add or change graph title. Enter a blank here if you don’t want a title to appear.
Subtitle: Add or change graph subtitle. Enter a blank here if you don’t want a subtitle to appear.
Inverse grid lines: Show grid lines if they are not shown, remove them if they are shown
Legend box: The legend box can be “dragged” to a different location, if necessary, using the mouse.

In addition to the options presented here there are options available to change the format of the labels in the X and Y axes, change the width of the various lines and curves and change the size of the points drown. These options can be reached using the dropdown menus.


Regression Report, Graph and Residual Plot

See Also: Linear & Polynomial Regression Multiple Linear Regression

Example 1, using logP as dependent and Trec, logT and T2 as independent variables, employing multiple linear regression is used to show the various information presented in the regression report, graph and residual plot windows. The first part of the report is shown below.

POLYMATH Report Fitting Polynomials to vapor pressure data
Nonlinear Regression

Model: logP = a0 + a1*Trec + a2*logT + a3*T2

Variable | Initial guess | Value | 95% confidence
a0 | 200. | 216.7214 | 156.4115
a1 | -9000. | -9318.66 | 4857.135
a2 | -100. | -75.74818 | 58.42643
a3 | 0 | 4.445E-05 | 5.001E-05

In this section the title of the problem as entered by the user, the date when the solution was obtained, the regression model and its parameter values (including 95% confidence intervals) are presented. In order for the regression results to be statistically valid the confidence intervals must be much smaller (or at least smaller) than the respective parameter values (in absolute values). This subject is further discussed in the Assessing the quality of regression models section. Additional information shown in the regression report is the following:

Number of independent variables = 3
Regression including free parameter
Number of observations = 10

R^2 = 0.9997514
R^2adj = 0.9996271
Rmsd = 0.0042151
Variance = 2.961E-04

The statistical indicators presented in this part of the report include R^ 2: the correlation coefficient (or coefficient of the multiple determination), R^ 2adj: the adjusted coefficient of the multiple determination, Rmsd: Root mean square deviation and the variance. These indicators measure the deviation between the calculated values and the data for the dependent variable, and they can be used for comparing various models representing the same dependent variable. Model A, for example, represents the data better than model B if the values of R^2 and R^2adj are closer to one and the values of Rmsd and the variance are smaller for model A than for model B. Note that models where the independent variables are different (P versus log(P), for example) cannot be compared directly. This subject is further discussed in the Assessing the quality of regression models section.

If the “Graph” option is turned on in the “Regression solver” dialog box, the following graph is obtained for the Example problem:

In this plot the dependent variable values (log (P)) values are shown, the data values are marked by small squares and the calculated values by small circles. In this particular case the differences between the calculated and experimental values are very small, almost indiscernible with the particular graph scaling being used. The data points are connected to help to see the differences but in order to really appreciate the quality of the fit the residual plot that follows should be consulted. Note that the text “Title” in the graph can be erased or replaced by real title and a subtitle can also be added. These and additional graph editing options are discussed in the “Graph editing options” section.

The residual plot for the Example is shown below.

The residual plot shows the difference between the calculated and measured values of the dependent variable as function of the measured values. If the regression model represents the data correctly, the residuals are randomly distributed around the line of err=0 with zero mean. In the residual plot shown here no clear trend can be identified the number of data points is, however, insufficient for verifying the randomness of the error distribution.


DEQ Table

Table

See Also: Data Table

The table option on the ODE Solver "Results Graph" gives the results for all of the variables associated with the problem as shown below for Example 1 problem involving differential equations:

The number of data points is equal to the number that is specified for intermediate data points as specified in settings.