Return to the home page.

The Ultimate Windows Math Toolbox

 

bullet Ver 3.0.697
23 June 2008
bullet Free support
bullet Only $44.85 (US)
(Professional)
Click to buy UltimaCalc Professional
bullet Only $34.85 (US)
(Standard)
Click to buy UltimaCalc Standard.

bullet Free download

<<< Prev  Next >>>

 

Simultaneous Nonlinear Equations

To gain access to this window, select the menu item File / Nonlinear Equations.

Solving Simultaneous Nonlinear Equations - equaations to solve

The Nature of the Problem

Suppose that we have a set of equations and a set of an equal number of variables. (Or maybe just a single equation and one variable.) What we would like to do is to find the values of the variables that satisfy all of the equations. If all of the equations are linear, this is a comparatively simple matter, even though the calculation does get tedious for large numbers of equations and variables. (UltimaCalc has a special tool for simultaneous linear equations.)

However, what if some or all of the equations are non-linear? Not only is it usually not clear as to how to proceed, but we usually do not even know how many solutions there are. There may be none, one, several, or an infinite number of soultions. Some solutions may be close together.

In the general case, if we want to find the solutions, we have no choice but to go hunting for them. We select a starting point (a set of initial values for the variables), investigate the behaviour of the system in the vicinity of this point, and hope to make an intelligent guess as to the location of the solution. We use this guess as our new starting point, and try again, and again, until either we are sure that we have indeed found a solution, or until we have tried so many times without success that we give up.

When we fail, as we often do, we can choose some other starting point, and hope for better luck next time.

If we should find a solution, we can search again, looking for another one. However, we need to take precautions that we do not end up at a solution that we have found previously. Once we have found the easy solutions, the next ones tend to be harder to find.

Simultaneous Non-linear Equations - defining the variablesEnter the Variables

The first step is to provide the names of all the variables. It is convenient at this time to also specify the expected range of values for each variable. For each attempt at finding a solution, the program will randomly choose a starting point that is within the specified range(s).

It is generally better to specify fairly wide ranges for the values, especially if multiple solutions are to be sought for. Note that the range set for a variable does not enforce a limit on its value in a solution.

To enter a new variable, click on the 'Variables' tab if necessary, then type its name into the edit box in the lower left, type one end of the range into the middle edit box, and the other end of the range into the right-hand edit box. Hit the 'Enter' key or click on the 'Enter' button to enter the data. The edit boxes will clear and you can repeat the process for the next variable.

Use the 'Tab' key to move from one edit box to the next. Alternatively, hitting the 'Enter' key after entering each item will move the focus to the next edit box until they all have data entered into them.

You can change the range of initial values for a variable by simply typing its name and values into the edit boxes and hitting 'Enter', or by right-clicking on its entry and selecting 'Change data' from the menu that pops up. This menu also has a 'Delete data' item, which deletes the variable.

Constants

If an equation contains a term whose value never changes, but which takes some time to compute, it can be advantageous to define this as a constant. It is also a good idea to use a constant if two or more equations contain the same value, and you would like to change this value later and find new solutions.

To enter constants, click on the 'Constants' tab. Enter the name of the constant in the left-hand edit box and its value in the right-hand edit box. Hit the 'Enter' key or click the 'Enter' button to insert the constant into the list. To change or delete a constant, right click on it in the list, and select the required option from the menu that pops up. You can also change a constant's value by typing its name and value into the edit boxes and hitting 'Enter'.

Enter the Equations

To enter the equations, click on the 'Equations' tab, enter an equation into the edit box at the bottom, then hit the 'Enter' key or click on the 'Enter' button. Repeat this process until all the equations are entered. After entering an equation, you can change it or remove it by right-clicking on it and selecting the appropriate option from the menu that pops up.

You can enter either an equation with a left hand side, an equals sign, and a right hand side, or you can enter an expression that is to evaluate to zero.

Calculation runs best when the 'most linear' equations are put first, in other words, the equations that have the gentlest or most predictable behaviour.

Options

When a system has many solutions, the order in which they are found may be rather arbitrary, due to the deliberately random choice of starting positions. It may therefore be useful to have these solutions sorted according to their distance from a target point that you specify. This ordering is performed on the solutions after they have been found; specifying an ordering has no effect on the calculations of the solutions.

You can choose to specify a target point after the solutions have been found.

This tab also allows you to specify how many solutions are to be searched for, the precision of the final results, and the maximum number of iterations to be performed when seeking a solution from an initial starting point. These three choices must of course be made before performing a calculation.

Calculate a Solution

After specifying the variables (with their range of values), the equations, and any optional constants, click on 'Calculate'. If there is a problem, this will be described in a balloon. Click on the balloon to dismiss it.

If all is well, a progress bar will appear. This will be updated every time a solution is found, and the calculation will complete before the bar has reached its full extent if no more solutions seem likely.

When all the solutions have been found, or the program has given up trying to find any more, the results will be shown on the 'Results' tab. The left-hand column shows the values of the variables for a particular solution, and the right-hand column will show the residual errors of the equations. A blank horizontal line separates the solutions.

After finding solutions, you can go to the 'Options' tab and choose a sorting option. Return to the 'Results' tab and click on the 'Update' button to have the solutions displayed according to your new criterion.

If the expressions are complicated or are hard to compute, finding a solution can take some time. While a calculation is in progress, the caption of the 'Calculate' button changes to indicate the number of trials per attempt to find a solution. At this time, clicking on this button will instruct the calculation engine to stop. There can be a few moments' pause before stopping. Any solutions found so far will be displayed.

Caution

Sometimes, solutions may be found which are in fact not valid solutions at all.

For example, the equation x*exp(-x^2) = 0 has only one solution, namely x = 0. All other 'solutions' are fictitious, caused by the fact that the function asymptotically (and rapidly) tends to 0 for large values of x. The expression can certainly seem to be 0 at these other solutions, but the expression's value does not pass through zero except at the one true solution.

Erase the Data

All of the data can be conveniently cleared away by clicking on the 'Erase' button. button and providing confirmation that you do want to do this.

Open and Save

The 'Open...' and 'Save...' buttons allow you to store the calculation data to a plain text file, and reload them later. The 'Notes' button 'Notes' button. A closed notebook indicates that there are no notes. allows you to write some notes to be saved along with the data, and to view any notes you wrote previously.

Logging

When calculation logging is enabled in UltimaCalc's main window, the equations and solutions are automatically recorded to the log file when they are calculated. If logging is not enabled, a log file button 'Logging' button, inactive. is shown. Clicking on this when it is highlighted will calculate the current solution and log the data and solution.

Copy to Clipboard

When a calculation has been performed, click on the 'Copy' button to copy the details of the calculation to the clipboard as plain text.