Hello!

I would write a function for Trapezoidal rule! I wrote this in a LISP programming language:

(defun integrate (f a b n)
"Numerical integration using the trapezoidal rule"
(let ((h (/ (- b a) n))
(integral (/ (+ (funcall f a) (funcall f b)) 2.0))
(x a))
(loop for i from 1 to (1- n) do
(incf x h)
(incf integral (funcall f x)))
(* integral h)))

Input is
f-function(like: 0.2+25x)
lower bound (0)
upper bound (2)
step(100)

Could you please anyone wrote this in Ruby?
I have no idea how to calculate function(lower bound) and how to insert on output that would be recognize as function..

Please help!

Thanks!