Numeric error propagation: Difference between revisions

Content deleted Content added
Updated D entry
GP work-in-progress
Line 727: Line 727:
{{Out}}
{{Out}}
<pre>111.803 ± 2.48717</pre>
<pre>111.803 ± 2.48717</pre>
=={{header|PARI/GP}}==
''This is a work-in-progress.''
<lang parigp>add(a,b)=if(type(a)==type(b), a+b, if(type(a)=="t_VEC",a+[b,0],b+[a,0]));
sub(a,b)=if(type(a)==type(b), [a[1]-b[1],a[2]+b[2]], if(type(a)=="t_VEC",a-[b,0],[a,0]-b));
mult(a,b)=if(type(a)=="t_VEC", if(type(b)=="t_VEC", [a[1]*b[1], abs(a[1]*b[1])*sqrt(norml2([a[2]/a[1],b[2]/b[1]]))], [b*a[1], abs(b)*a[2]]), [a*b[1], abs(a)*b[2]]);
div(a,b)=if(type(b)!="t_VEC", mult(a,1/b), mult(a,[1/b[1],b[2]/b[1]^2]));
pow(a,b)=[a[1]^b, abs(a[1]^b*b*a[2]/a[1])];
x1=[100,1.1];y1=[50,1.2];x2=[200,2.2];y2=[100,2.3];
pow(add(pow(sub(x1,x2),2),pow(sub(y1,y2),2)),.5)</lang>

=={{header|Perl}}==
=={{header|Perl}}==
Following code keeps track of covariance between variables. Each variable with error contains its mean value and components of error source from a set of indepentent variables. It's more than what the task requires.
Following code keeps track of covariance between variables. Each variable with error contains its mean value and components of error source from a set of indepentent variables. It's more than what the task requires.
Line 917: Line 927:


covariance between 300±2.46 and -350±4.56: -9.68</lang>
covariance between 300±2.46 and -350±4.56: -9.68</lang>

=={{header|Perl 6}}==
=={{header|Perl 6}}==
{{trans|Perl}}
{{trans|Perl}}