Bottom Page

• 1 Vote(s) - 3 Average
• 1
• 2
• 3
• 4
• 5
 Calculus in python zivoni Minister of Silly Walks Posts: 331 Threads: 3 Joined: Feb 2017 Reputation: 65 Likes received: 192 #11 Mar-21-2017, 05:03 PM "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). pythonforumrocks Programmer named Tim Posts: 7 Threads: 1 Joined: Mar 2017 Reputation: 0 Likes received: 1 #12 Mar-22-2017, 09:08 AM 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 pythonforumrocks Programmer named Tim Posts: 7 Threads: 1 Joined: Mar 2017 Reputation: 0 Likes received: 1 #13 Mar-24-2017, 03:59 PM 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. nilamo Last Thursdayist Posts: 3,174 Threads: 80 Joined: Sep 2016 Reputation: 129 Likes received: 707 #14 Mar-24-2017, 04:10 PM What about just special-casing it? `0 if not b else (formula)` « Next Oldest | Next Newest »

Top Page

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

Forum Jump:

Users browsing this thread: 1 Guest(s)