RosettaCodeData/Task/Numeric-error-propagation/00-TASK.txt

41 lines
2.9 KiB
Plaintext
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

If &nbsp; '''f''', &nbsp; '''a''', &nbsp; and &nbsp; '''b''' &nbsp; are values with uncertainties &nbsp; σ<sub>f</sub>, &nbsp; σ<sub>a</sub>, &nbsp; and &nbsp; σ<sub>b</sub>, &nbsp; and &nbsp; '''c''' &nbsp; is a constant;
<br>then if &nbsp; '''f''' &nbsp; is derived from &nbsp; '''a''', &nbsp; '''b''', &nbsp; and &nbsp; '''c''' &nbsp; in the following ways,
<br>then &nbsp; σ<sub>f</sub> &nbsp; can be calculated as follows:
:;Addition/Subtraction
:* If &nbsp; f = a &plusmn; c, &nbsp; or &nbsp; f = c &plusmn; a &nbsp; then &nbsp; '''σ<sub>f</sub> = σ<sub>a</sub>'''
:* If &nbsp; f = a &plusmn; b &nbsp; then &nbsp; '''σ<sub>f</sub><sup>2</sup> = σ<sub>a</sub><sup>2</sup> + σ<sub>b</sub><sup>2</sup>'''
:;Multiplication/Division
:* If &nbsp; f = ca &nbsp; or &nbsp; f = ac &nbsp; &nbsp; &nbsp; then &nbsp; '''σ<sub>f</sub> = |cσ<sub>a</sub>|'''
:* If &nbsp; f = ab &nbsp; or &nbsp; f = a / b &nbsp; then &nbsp; '''σ<sub>f</sub><sup>2</sup> = f<sup>2</sup>( (σ<sub>a</sub> / a)<sup>2</sup> + (σ<sub>b</sub> / b)<sup>2</sup>)'''
:;Exponentiation
:* If &nbsp; f = a<sup>c</sup> &nbsp; then &nbsp; '''σ<sub>f</sub> = |fc(σ<sub>a</sub> / a)|'''
Caution:
::This implementation of error propagation does not address issues of dependent and independent values. &nbsp; It is assumed that &nbsp; '''a''' &nbsp; and &nbsp; '''b''' &nbsp; are independent and so the formula for multiplication should not be applied to &nbsp; '''a*a''' &nbsp; for example. &nbsp; See &nbsp; [[Talk:Numeric_error_propagation|the talk page]] &nbsp; for some of the implications of this issue.
;Task details:
# Add an uncertain number type to your language that can support addition, subtraction, multiplication, division, and exponentiation between numbers with an associated error term together with 'normal' floating point numbers without an associated error term. <br>Implement enough functionality to perform the following calculations.
# Given coordinates and their errors:<br>x1 = 100 &plusmn; 1.1<br>y1 = 50 &plusmn; 1.2<br>x2 = 200 &plusmn; 2.2<br>y2 = 100 &plusmn; 2.3<br> if point p1 is located at (x1, y1) and p2 is at (x2, y2); calculate the distance between the two points using the classic Pythagorean formula: <br> <big><big> d = &radic;<span style="text-decoration:overline"> &nbsp; (x1 - x2)² &nbsp; + &nbsp; (y1 - y2)² &nbsp; </span> </big></big>
# Print and display both &nbsp; <big> '''d''' </big> &nbsp; and its error.
<!-- the superscript
2 glyph [²]
had to be used instead of the
<sup>2</sup>
notation which causes the overline "text-decoration" to either overlay the superscript or it causes a "break" in the continuous overline part of the radic. Gerard Schildberger. -->
;References:
* [http://casa.colorado.edu/~benderan/teaching/astr3510/stats.pdf A Guide to Error Propagation] B. Keeney, 2005.
* [[wp:Propagation of uncertainty|Propagation of uncertainty]] Wikipedia.
;Related task:
* &nbsp; [[Quaternion type]]
<br><br>