You are viewing a single comment's thread from:

RE: Computation Contest #4 [2 SBI]

in #programming4 years ago

integrate.JPG

So the idea here is to approximate the function in some way in small steps. I used rectangles, triangles would be fine too. You calculate the area of each rectangle and sum them all up to get the area under e^(x)/x within the given intervall. I slowly decreased the step size because I wasn't sure how much my PC could handle.
My reputation is currently 57, and the code gave a result of 1.0156373595307505e+23. This is in good accordance with wolfram alpha (1.015643...e+23), a deviation shows up 5 digits behind the comma. You can improve this with more computation power or time.