Skip to content

Instantly share code, notes, and snippets.

@Demonstrandum
Created July 7, 2019 17:48
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save Demonstrandum/3591116dd1aaca936f272c994cc17675 to your computer and use it in GitHub Desktop.
Save Demonstrandum/3591116dd1aaca936f272c994cc17675 to your computer and use it in GitHub Desktop.
Helping Sam Frost
def f x; x**2 + 2*x + 1; end
def integrate sym, a, b
dx = 0.001
fn = method sym
dx * (a..b - dx).step(dx).map(&fn).sum
end
puts integrate :f, 2, 4
def differentiate sym, x
h = 0.001
fn = method sym
(fn.call(x + h) - fn.call(x)) / h
end
puts differentiate :f, 7
@Demonstrandum
Copy link
Author

hai

@Shiimoe
Copy link

Shiimoe commented Jul 7, 2019

very cool kanye

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment