6 kyu

Parabolic Arc Length

66 of 3,085g964

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.

alternative text

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).

Fundamentals

Similar Kata:

More By Author:

Check out these other kata created by g964

Stats:

CreatedOct 26, 2015
PublishedOct 26, 2015
Warriors Trained12211
Total Skips3715
Total Code Submissions13961
Total Times Completed3085
Ruby Completions66
Python Completions862
JavaScript Completions434
CoffeeScript Completions10
Haskell Completions81
Java Completions263
C# Completions169
Clojure Completions14
C++ Completions324
PHP Completions62
Crystal Completions5
F# Completions22
C Completions229
TypeScript Completions57
Rust Completions168
Swift Completions61
Go Completions162
R Completions50
Shell Completions19
OCaml Completions17
Kotlin Completions65
Fortran Completions22
Elixir Completions25
Julia Completions31
Scala Completions37
PowerShell Completions11
Nim Completions9
PureScript Completions14
Reason Completions3
Racket Completions14
Forth Completions9
Prolog Completions10
Haxe Completions6
Pascal Completions6
Lua Completions25
Perl Completions11
Elm Completions2
D Completions7
Erlang Completions5
Total Stars200
% of votes with a positive feedback rating88% of 538
Total "Very Satisfied" Votes426
Total "Somewhat Satisfied" Votes93
Total "Not Satisfied" Votes19
Ad
Contributors
  • g964 Avatar
  • joh_pot Avatar
  • donaldsebleung Avatar
  • kazk Avatar
  • Blind4Basics Avatar
  • Voile Avatar
  • monadius Avatar
  • hobovsky Avatar
  • trashy_incel Avatar
  • user8436785 Avatar
  • Just4FunCoder Avatar
Ad