Parabolic Arc Length
Description:
We want to approximate the length of a curve representing a function y = f(x)
with a <= x <= b
.
First, we split the interval [a, b]
into n sub-intervals with widths
h1, h2, ... , hn
by defining points
x1, x2 , ... , xn-1
between a and b.
This defines points
P0, P1, P2, ... , Pn
on the curve
whose x-coordinates are a, x1, x2 , ... , xn-1, b
and y-coordinates f(a), f(x1), ..., f(xn-1), f(b)
.
By connecting these points, we obtain a polygonal path approximating the curve.
Our task is to approximate the length of a parabolic arc representing the curve y = x * x
with x
in the interval [0, 1]
.
We will take a common step h
between the points xi: h1, h2, ... , hn = h = 1/n
and we will consider the points
P0, P1, P2, ... , Pn
on the curve.
The coordinates of each Pi
are (xi, yi = xi * xi)
.
The function len_curve
(or similar in other languages) takes n
as parameter (number of sub-intervals) and returns the length of the curve.
Note:
When you "Attempt" tests are done with a tolerance of 1e-06 (except in PureScript where you must truncate your result to 9 decimal places).
Similar Kata:
Stats:
Created | Oct 26, 2015 |
Published | Oct 26, 2015 |
Warriors Trained | 12267 |
Total Skips | 3707 |
Total Code Submissions | 13945 |
Total Times Completed | 3076 |
Ruby Completions | 66 |
Python Completions | 860 |
JavaScript Completions | 433 |
CoffeeScript Completions | 10 |
Haskell Completions | 80 |
Java Completions | 263 |
C# Completions | 169 |
Clojure Completions | 14 |
C++ Completions | 323 |
PHP Completions | 62 |
Crystal Completions | 5 |
F# Completions | 22 |
C Completions | 229 |
TypeScript Completions | 57 |
Rust Completions | 168 |
Swift Completions | 61 |
Go Completions | 161 |
R Completions | 50 |
Shell Completions | 19 |
OCaml Completions | 17 |
Kotlin Completions | 65 |
Fortran Completions | 22 |
Elixir Completions | 22 |
Julia Completions | 31 |
Scala Completions | 37 |
PowerShell Completions | 11 |
Nim Completions | 9 |
PureScript Completions | 14 |
Reason Completions | 3 |
Racket Completions | 14 |
Forth Completions | 9 |
Prolog Completions | 10 |
Haxe Completions | 6 |
Pascal Completions | 6 |
Lua Completions | 25 |
Perl Completions | 11 |
Elm Completions | 2 |
D Completions | 7 |
Erlang Completions | 4 |
Total Stars | 199 |
% of votes with a positive feedback rating | 88% of 537 |
Total "Very Satisfied" Votes | 425 |
Total "Somewhat Satisfied" Votes | 93 |
Total "Not Satisfied" Votes | 19 |