6 kyu
Euler method for numerical integration
198stok
Description:
In this Kata, we use the Euler method for integrating a function (see wiki).
Remember that integrating a function basically means 'calculating the area under a curve'. One way to approximate the area is to chop it up into rectangles (whose area is just height * width) and sum them (see this other wiki page which has a nice gif illustrating this point). We are going to do just this.
Let y = 5 + 2 * x + 3 * x^2
.
Write a function
def euler(stop, step_size)
that calculates the integral of y between x = 0
and x = stop
. For the sake of simplicity, stop > 0
.
As the example test shows, the code will be verified by using a step_size of 0.0001
, then rounding the output to the nearest integer.
Algorithms
Similar Kata:
Stats:
Created | Jan 16, 2017 |
Published | Jan 16, 2017 |
Warriors Trained | 378 |
Total Skips | 17 |
Total Code Submissions | 664 |
Total Times Completed | 198 |
Python Completions | 198 |
Total Stars | 13 |
% of votes with a positive feedback rating | 84% of 70 |
Total "Very Satisfied" Votes | 48 |
Total "Somewhat Satisfied" Votes | 22 |
Total "Not Satisfied" Votes | 0 |
Total Rank Assessments | 12 |
Average Assessed Rank | 6 kyu |
Highest Assessed Rank | 5 kyu |
Lowest Assessed Rank | 8 kyu |