```
eqsolver.html - Multidimensional Equation Solver
Copyright (C) 2009  Clifford Wolf <clifford@clifford.at>

This program is free software; you can redistribute it and/or modify
the Free Software Foundation; either version 2 of the License, or
(at your option) any later version.

This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
GNU General Public License for more details.

---------------------------------------------------------------------

This scripts implements a simple equation solver based on the
Gauss-Newton algorithm for non-linear least square fitting. The
algorithm has been altered to improve it for some corner cases
and add support for weighted equations.

The Jacobi Matrices are creating using a rather simple numerical
differentiation approach.

Normal equations can spezified using the '=' operator. Inequations
can be written using the '<' and '>' operators.

Variable aliases, macros or static constants can be declared using
special ':=' equations, with the macro name on the left side.

The start value for all variables is '1'. Another start value can
be defined using special '?=' equations, with the variable name
on the left and a numerical value on the right side.

Since this program is based on a least square fitter it can also
'solve' overdefined quation systems with no real solution. For this
cases the "Remaining error: X" line has been included in the output.

It is also possible to use this script for solving underdefined
quation systems. In this cases any numerically valid solution is
returned.

Some special commands can be used to modify the behavior of the
equation solver:

\$tryhard
Deactivates the close-to-singularity detection. In some
scenarios the equation solver returns better results with
this option set. But it also incrases the solver runtime.

\$scalehack
Setting this option enables a small hack in the Gauss-Newton
solver that helps finding solutions in equations that are
otherwise problematic with Gauss-Newton solvers (such as
the equation 'pow(x,3)-2*x+2 = 0') and speeds up solving of
some equation systems.

\$showindep
Also print the independent variables/expressions.

\$range:X:Min:Max
This command can be used to specify the valid range for
fitted variable. That e.g. usefull when using a variable as
argument sqrt() and thus only positive values are valid. Open
ranges can be implemented by leaving the Min or Max field empty.

\$weight:X
This command sets the weight for all (in)equations following
this statement. The default weight is '1'. A higher weight
for an (in)equation results in a higher impact on the
solution.

\$function:avg(a, b)
return (a+b) / 2;
\$endfunction
Such a code block can be used to define a javascript function
which can be used in the equation system.

Note that all JavaScript Math.* functions can be used in the
equations, but without the "Math." prefix. I.e. '0.8 = sin(x)' is
a valid equation.

Beware of bugs in this program. I haven't tested it much yet..

```

` `