lua-users home
lua-l archive

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


Hi,
       Once these functions are removed don't we just have to include the following code in our Lua program if we use all these and we are good to go?

math.sinh = function(x)
    return 0.5*(math.exp(x)-math.exp(-x))
end

math.cosh = function(x)
   return 0.5*(math.exp(x)+math.exp(-x))
end

math.tanh = function(x)
   return (math.exp(2*x)-1)/(math.exp(2*x)+1)
end

math.deg = function(x)
    return x*180/math.pi
end

math.rad = function(x)
     return x*math.pi/180
end

math.pow = function(x,y)
   return x^y
end

Would these not be equivalent? If they are it is really trivial replacing them. Also the math library does not support complex numbers and arguably many times you need these functions you are dealing with complex numbers, at least for me. So when you do need them you turn to more complete math libraries. Removing them I think makes sense and works with the Lua policy of providing the tools to do things not directing the way you do them or not giving you the tools which you may not need most of the time like classes etc. .

Milind



On Thu, Apr 3, 2014 at 1:35 PM, Roberto Ierusalimschy <roberto@inf.puc-rio.br> wrote:
We are considering removing some functions from the standard math lib,
either because we think few people use them or because they are trivially
implemented without the library. The current list is this:

- sinh, cosh, tanh: (They are quite specialized, on par with several
other functions offered by external libraries, such as lhf's mathlibx.)

- deg, rad, pow: trivially done without the library.

Comments?

-- Roberto