Sysop: | Amessyroom |
---|---|
Location: | Fayetteville, NC |
Users: | 42 |
Nodes: | 6 (0 / 6) |
Uptime: | 00:39:41 |
Calls: | 220 |
Calls today: | 1 |
Files: | 824 |
Messages: | 121,521 |
Posted today: | 6 |
Alright, so here's how I approached it: We know that when the
price x is 5 bucks, the number of people n is 120 (^1).
def ddx(f,x,h=0.001): return (f(x+h)-f(x-h))/(2*h) # numerical derivative
def newton(f,x0): return x0 - f(x0)/ddx(f,x0) # Newton-Raphson iteration
It's hella rad to see you bust out those "next-level math tricks"
with just a single line each!
It's hella rad to see you bust out those "next-level math tricks"
with just a single line each!
The "next-level math trick" Newton-Raphson has nothing to do with
functional programming. I have written solvers in purely iterative
style.
As far as I know, Newton-Raphson is the opposite of functional
programming as you iteratively solve for the root. Functional programming
is stateless where you are not allowed to store any state (current best
guess root).
The "next-level math trick" Newton-Raphson has nothing to do with
functional programming.
And you can totally implement anything in an imperative or functional
style.
Nobody up the thread was claiming it was functional. And you can
totally implement anything in an imperative or functional style.
def f_prime(x: float) -> float:
return 2*x
def f_prime(x: float) -> float:
return 2*x
You might enjoy implementing that with automatic differentiation (not
to be confused with symbolic differentiation) instead.
http://blog.sigfpe.com/2005/07/automatic-differentiation.html
totally implement anything in an imperative or functional style.
(names, not values; i.e., "obj.dict.keys()" shouldn't
- Use slots.
Off topic, but quick. Are you the paul rubin who I knew back in 70's
in nyc, on E. 84th st?