January 6th, 2011, 05:12 AM
Join Date: Jan 2011
Time spent in forums: 40 m 28 sec
Reputation Power: 0
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))
(loop for i from 1 to (1- n) do
(incf x h)
(incf integral (funcall f x)))
(* integral h)))
lower bound (0)
upper bound (2)
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..