Calculating the value of e: Difference between revisions

m
→‎{{header|J}}: slightly more readable
m (→‎{{header|J}}: slightly more readable)
Line 2,216:
2.71828
</pre>
 
This is a floating point value (and, thus, accurate to 16 decimal places (15 places after the decimal point, in this example)).
 
The unary power verb ^ uses Euler's number as the base, hence
Line 2,223 ⟶ 2,225:
</pre>
 
FinallyIf we need higher accuracy, towe can use an approximation expressed as a rational number. To compute e: find the sum as insert plus +/ of the reciprocals % of factorials ! of integers i. . Using x to denote extended precision integers j will give long precision decimal expansions of rational numbers. Format ": several expansions to verify the number of valid digits to the expansion. Let's try for arbitrary digits.
<pre>
NB. approximation to e as a rational number
Line 2,231 ⟶ 2,233:
 
NB. 31 places shown with 20 terms
32j300j30 ": +/ % ! i. x: 20
2.718281828459045234928752728335
 
NB. 40 terms
32j300j30 ": +/ % ! i. x: 40
2.718281828459045235360287471353
 
NB. 50 terms,
32j300j30 ": +/ % ! i. x: 50
2.718281828459045235360287471353
 
6,962

edits