Bottom Page

Thread Rating:
  • 1 Vote(s) - 3 Average
  • 1
  • 2
  • 3
  • 4
  • 5
 Calculus in python
#11
"Average value of curve" on wolframalpha is calculated as definite integral of function on interval[A, B] divided by length of that interval (that is B - A). So in this case resulting definite integral must be divided by (b - 1).
Quote
#12
Awesome!

integrate.quad(lambda x: ((a*b/c) * 1.05**(-x))/(b-1), 1, b)

Even better is that you pointed out I don't need to use calculus at all:

(-(a*b/c) / math.log(1.05) * ( 1.05**-b - 1.05**-a ))/(b-1)

Thank you for your help!
Larz60+ likes this post
Quote
#13
I'm running into division by zero when b=1.  This formula works in that case:

a / ( c * 1.05 )

But is there any way to gracefully use the same formula regardless of the value of b?  I'm working in the pyspread python spreadsheet so I'm trying to use one-liners.
Quote
#14
What about just special-casing it? 0 if not b else (formula)
Quote

Top Page

Possibly Related Threads...
Thread Author Replies Views Last Post
  Some help with some calculus and fish agritheory 4 502 Aug-17-2018, 07:40 PM
Last Post: agritheory

Forum Jump:


Users browsing this thread: 1 Guest(s)