Anonymous user
Numeric error propagation: Difference between revisions
m
→{{header|REXX}}: added whitespace, used a template for the output section.
m (→{{header|REXX}}: added whitespace, used a template for the output section.) |
|||
Line 2,329:
parse var ax ax '±' axe; parse var bx bx '±' bxE /* " err " Ax and Bx.*/
parse var ay ay '±' aye; parse var by by '±' byE /* " " " Ay " By.*/
if axE=='' then axE= 0;
if ayE=='' then ayE= 0;
say ' A point (x,y)= ' ax "±" axE', ' ay "±" ayE
say ' B point (x.y)= ' bx "±" bxE', ' by "±" byE
say /*blank line for the eyeballs.*/
dx= ax-bx; dxE= sqrt(axE**2 + bxE**2);
dy= ay-by; dyE= sqrt(ayE**2 + byE**2);
D= sqrt(dx**2 + dy**2)
say 'distance=' D "±" #(D**2, .5, sqrt(xE**2 + yE**2)) /*display " " " */
exit
/*──────────────────────────────────────────────────────────────────────────────────────*/
#: procedure; arg x,p,e; if p=.5 then z=1/sqrt(abs(x)); else z=abs(x)**(p-1); return p*e*z
Line 2,346:
m.=9; do j=0 while h>9; m.j=h; h=h%2+1; end /*j*/
do k=j+5 to 0 by -1; numeric digits m.k; g=(g+x/g)*.5; end /*k*/
numeric digits d; return g/1
/*──────────────────────────────────────────────────────────────────────────────────────*/
'''output''' when using the default inputs:▼
sqrt: procedure; parse arg x; if x=0 then return 0; d=digits(); numeric digits; h=d+6
numeric form; parse value format(x,2,1,,0) 'E0' with g "E" _ .; g= g * .5'e'_ % 2
m.= 9; do j=0 while h>9; m.j= h; h= h%2+1; end /*j*/
do k=j+5 to 0 by -1; numeric digits m.k; g= (g+x/g)*.5; end /*k*/
numeric digits d; return g/1</lang>
<pre>
A point (x,y)= 100 ± 1.1, 50 ± 1.2
|