6 kyu

Parabolic Arc Length

61 of 3,110g964

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

Stats:

CreatedOct 26, 2015
PublishedOct 26, 2015
Warriors Trained12268
Total Skips3730
Total Code Submissions14031
Total Times Completed3110
Ruby Completions67
Python Completions865
JavaScript Completions438
CoffeeScript Completions10
Haskell Completions82
Java Completions265
C# Completions171
Clojure Completions14
C++ Completions328
PHP Completions62
Crystal Completions5
F# Completions22
C Completions230
TypeScript Completions61
Rust Completions169
Swift Completions62
Go Completions164
R Completions50
Shell Completions19
OCaml Completions18
Kotlin Completions66
Fortran Completions22
Elixir Completions27
Julia Completions31
Scala Completions38
PowerShell Completions12
Nim Completions9
PureScript Completions14
Reason Completions3
Racket Completions14
Forth Completions9
Prolog Completions10
Haxe Completions7
Pascal Completions6
Lua Completions25
Perl Completions13
Elm Completions2
D Completions7
Erlang Completions5
Total Stars200
% of votes with a positive feedback rating88% of 543
Total "Very Satisfied" Votes430
Total "Somewhat Satisfied" Votes94
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