  lua-l archive

• Subject: Lua Math package
• From: Milind Gupta <milind.gupta@...>
• Date: Thu, 26 Jun 2014 12:01:35 -0700

Hi,
I started putting together a set of libraries under a github repository(https://github.com/aryajur/LuaMath) to build a Math package for Lua. I needed something I could use from the standard latest Lua interpreter directly so can be embedded into programs that embed the standard interpreter. I am building it as I need features. For now it has the following:

- Complex numbers (Thanks to library from Philippe Castagliola http://philippe.castagliola.free.fr/LUA/complex.html)
- Basic plotting (Using IUP and help from Steve Donovan's code http://www.tecgraf.puc-rio.br/iup/en/basic/)
- Solving single variable equations using Newton Raphson method

An example for plotting a bode plot is this:

require("LuaMath")
local plot = require "lua-plot"

function func(s)
return 1000/((1+s)*(1+s/100))
end

local bp = plot.bodePlot{
func = func,
ini = 0.01,
finfreq = 1000,
steps = 20
}

bp.mag:Show({title="Magnitude Plot",size="HALFxHALF"})
bp.phase:Show({title="Phase Plot",size="HALFxHALF"})

More stuff is welcome.

Regards,
Milind