lua-users home
lua-l archive

[Date Prev][Date Next][Thread Prev][Thread Next] [Date Index] [Thread Index]


On Apr 30, 2018, at 7:11 AM, Gavin Wraith <gavin@wra1th.plus.com> wrote:
fixpoint = function (f)
          local g = guess
          while math.abs(g-f(g)) < epsilon do
             g = g - f(g)/df(g)
          end
          return g
          end

Using while do loop is a bad idea, as it can easily get 
into infinite loop.  It would be better if the solver "give-up" 
if it cannot converge within some maximum iterations.

Another problem is the df function.
A symbolic df function may be hard to get (or messy)

Even the f function may be hard to get.
Most engineering problem involve simultaneous system of
equations, which were hard to simplify into a single f

It is much easier using, say TK solver, instead of Lua.
Instead of a bunch of equations for solving different variable,
Just leave the input field(s) blank (or guess values), and type !

Excel spreadsheet solver is another option.