Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- class Funkcja
- def initialize
- @function = Proc.new
- end
- def value(x)
- return @function.call(x)
- end
- def poch(x) #http://www.obliczeniowo.com.pl/706
- f_x1 = @function.call(x)
- x += 0.0000001
- f_x2 = @function.call(x)
- return (f_x2 - f_x1) / 0.0000001
- end
- def pole(a, b) #http://www.obliczeniowo.com.pl/704
- dx = (b - a) / 100
- integr = 0
- (0..100).each do |i|
- i = (i * dx) + a
- fx1 = @function.call(i)
- i += dx
- fx2 = @function.call(i)
- integr += (0.5 * dx * (fx1 + fx2))
- end
- return integr
- end
- def zerowe(a,b,e)
- return "do zaimplementowania leniwy smieciu"
- end
- end
- syf = Funkcja.new{ |x| x*x }
- puts syf.value(42)
- puts syf.poch(1)
- puts syf.pole(0,1)
- puts syf.zerowe(0,0,0)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement