예제 #1
0
        /// <summary>
        /// Computes e to the power of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The value of e^<sup>x1</sup>.</returns>
        public static UncertainValue Exp(UncertainValue x)
        {
            double v = Math.Exp(x.Value);
            double u = v * x.Uncertainty;

            return(new UncertainValue(v, u));
        }
예제 #2
0
        /// <summary>
        /// Computes an uncertain value raised to an arbitrary power.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <param name="p">The power.</param>
        /// <returns>The argument raised to the specified power.</returns>
        public static UncertainValue Pow(UncertainValue x, double p)
        {
            double v = Math.Pow(x.Value, p);
            double u = Math.Abs(p * v * x.RelativeUncertainty);

            return(new UncertainValue(v, u));
        }
예제 #3
0
        /// <summary>
        /// Computes the natural logarithm of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The value of ln(x1).</returns>
        public static UncertainValue Log(UncertainValue x)
        {
            double v = Math.Log(x.Value);
            double u = x.RelativeUncertainty;

            return(new UncertainValue(v, u));
        }
예제 #4
0
        /// <summary>
        /// Computes the hyperbolic sine of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The hyperbolic sine of the argument.</returns>
        public static UncertainValue Sinh(UncertainValue x)
        {
            double v = Math.Sinh(x.Value);
            double u = Math.Cosh(x.Value) * x.Uncertainty;

            return(new UncertainValue(v, u));
        }
예제 #5
0
 /// <summary>
 /// Computes the arctangent of an uncertain value.
 /// </summary>
 /// <param name="x">The argument.</param>
 /// <returns>The arctanget of the argument.</returns>
 public static UncertainValue Atan(UncertainValue x)
 {
     double xv = x.Value;
     double v = Math.Atan(xv);
     double u = x.Uncertainty / (1 + xv * xv);
     return (new UncertainValue(v, u));
 }
예제 #6
0
        /// <summary>
        /// Computes the hyperbolic tangent of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The hyperbolic tanget of the argument.</returns>
        public static UncertainValue Tanh(UncertainValue x)
        {
            double v = Math.Tanh(x.Value);
            double u = x.Uncertainty / MoreMath.Sqr(Math.Cosh(x.Value));

            return(new UncertainValue(v, u));
        }
예제 #7
0
 /// <summary>
 /// Computes the arccosine of an uncertain value.
 /// </summary>
 /// <param name="x">The argument.</param>
 /// <returns>The arccosine of the argument.</returns>
 public static UncertainValue Acos(UncertainValue x)
 {
     UncertainValue y = new UncertainValue();
     y.Value = Math.Acos(x.Value);
     y.Uncertainty = x.Uncertainty / Math.Abs(Math.Sin(y.Value));
     return (y);
 }
예제 #8
0
        // basic functions of uncertain values

        /// <summary>
        /// Computes the square root of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The square root of the argument.</returns>
        public static UncertainValue Sqrt(UncertainValue x)
        {
            double v = Math.Sqrt(x.Value);
            double u = 0.5 * x.Uncertainty / v;

            return(new UncertainValue(v, u));
        }
예제 #9
0
        /// <summary>
        /// Computes the cosine of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The cosine of the argument.</returns>
        public static UncertainValue Cos(UncertainValue x)
        {
            double v = Math.Cos(x.Value);
            double u = Math.Abs(Math.Sin(x.Value)) * x.Uncertainty;

            return(new UncertainValue(v, u));
        }
예제 #10
0
        /// <summary>
        /// Computes the tangent of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The tanget of the argument.</returns>
        public static UncertainValue Tan(UncertainValue x)
        {
            double v = Math.Tan(x.Value);
            double u = (1.0 + v * v) * x.Uncertainty;

            return(new UncertainValue(v, u));
        }
예제 #11
0
        /// <summary>
        /// Computes the arccosine of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The arccosine of the argument.</returns>
        public static UncertainValue Acos(UncertainValue x)
        {
            double v = Math.Acos(x.Value);
            double u = x.Uncertainty / Math.Abs(Math.Sin(v));

            return(new UncertainValue(v, u));
        }
예제 #12
0
 public void UncertainMathSinASin()
 {
     UncertainValue y = new UncertainValue(0.5, 0.1);
     UncertainValue x = UncertainMath.Asin(y);
     UncertainValue sx = UncertainMath.Sin(x);
     Assert.IsTrue(TestUtilities.IsNearlyEqual(sx.Value, y.Value));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(sx.Uncertainty, y.Uncertainty));
 }
예제 #13
0
        /// <summary>
        /// Computes the sine of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The sine of the argument.</returns>
        public static UncertainValue Sin(UncertainValue x)
        {
            UncertainValue y = new UncertainValue();

            y.Value       = Math.Sin(x.Value);
            y.Uncertainty = Math.Abs(Math.Cos(x.Value)) * x.Uncertainty;
            return(y);
        }
예제 #14
0
        /// <summary>
        /// Divides two uncertain values.
        /// </summary>
        /// <param name="v1">The first uncertain value.</param>
        /// <param name="v2">The second uncertain value.</param>
        /// <returns>The quotient of the two uncertain values.</returns>
        public static UncertainValue operator /(UncertainValue v1, UncertainValue v2)
        {
            UncertainValue v = new UncertainValue();

            v.Value       = v1.Value / v2.Value;
            v.Uncertainty = Math.Abs(v.Value) * MoreMath.Hypot(v1.RelativeUncertainty, v2.RelativeUncertainty);
            return(v);
        }
예제 #15
0
        /// <summary>
        /// Computes e to the power of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The value of e^<sup>x1</sup>.</returns>
        public static UncertainValue Exp(UncertainValue x)
        {
            UncertainValue y = new UncertainValue();

            y.Value       = Math.Exp(x.Value);
            y.Uncertainty = y.Value * x.Uncertainty;
            return(y);
        }
예제 #16
0
        /// <summary>
        /// Computes the natural logarithm of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The value of ln(x1).</returns>
        public static UncertainValue Log(UncertainValue x)
        {
            UncertainValue y = new UncertainValue();

            y.Value       = Math.Log(x.Value);
            y.Uncertainty = x.RelativeUncertainty;
            return(y);
        }
예제 #17
0
        /// <summary>
        /// Computes the arccosine of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The arccosine of the argument.</returns>
        public static UncertainValue Acos(UncertainValue x)
        {
            UncertainValue y = new UncertainValue();

            y.Value       = Math.Acos(x.Value);
            y.Uncertainty = x.Uncertainty / Math.Abs(Math.Sin(y.Value));
            return(y);
        }
예제 #18
0
        /// <summary>
        /// Computes an uncertain value raised to an arbitrary power.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <param name="p">The power.</param>
        /// <returns>The argument raised to the specified power.</returns>
        public static UncertainValue Pow(UncertainValue x, double p)
        {
            UncertainValue y = new UncertainValue();

            y.Value       = Math.Pow(x.Value, p);
            y.Uncertainty = Math.Abs(p * y.Value * x.RelativeUncertainty);
            return(y);
        }
예제 #19
0
 public void UncertainMathCosACos()
 {
     UncertainValue y = new UncertainValue(0.5, 0.1);
     UncertainValue x = UncertainMath.Acos(y);
     UncertainValue cx = UncertainMath.Cos(x);
     Assert.IsTrue(TestUtilities.IsNearlyEqual(cx.Value, y.Value));
     Assert.IsTrue(TestUtilities.IsNearlyEqual(cx.Uncertainty, y.Uncertainty));
 }
예제 #20
0
        /// <summary>
        /// Computes the hyperbolic tangent of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The hyperbolic tanget of the argument.</returns>
        public static UncertainValue Tanh(UncertainValue x)
        {
            UncertainValue y = new UncertainValue();

            y.Value       = Math.Tanh(x.Value);
            y.Uncertainty = y.Uncertainty / Math.Pow(Math.Cosh(x.Value), 2);
            return(y);
        }
예제 #21
0
        /// <summary>
        /// Computes the arctangent of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The arctanget of the argument.</returns>
        public static UncertainValue Atan(UncertainValue x)
        {
            double xv = x.Value;
            double v  = Math.Atan(xv);
            double u  = x.Uncertainty / (1 + xv * xv);

            return(new UncertainValue(v, u));
        }
예제 #22
0
 /// <summary>
 /// Computes the arcsine of an uncertain value.
 /// </summary>
 /// <param name="x">The argument.</param>
 /// <returns>The arcsine of the argument.</returns>
 public static UncertainValue Asin(UncertainValue x)
 {
     double v = Math.Asin(x.Value);
     double u = x.Uncertainty / Math.Abs(Math.Cos(v));
     return (new UncertainValue(v, u));
     //UncertainValue y = new UncertainValue();
     //y.Value = Math.Asin(x.Value);
     //y.Uncertainty = x.Uncertainty / Math.Abs(Math.Cos(y.Value));
     //return (y);
 }
예제 #23
0
 /// <summary>
 /// Computes the arctangent of the ratio of two uncertain values.
 /// </summary>
 /// <param name="x">The argument of the numerator.</param>
 /// <param name="y">The argument of the denominator.</param>
 /// <returns>The arctangent of the quotient.</returns>
 public static UncertainValue Atan2(UncertainValue x, UncertainValue y)
 {
     double xv = x.Value;
     double yv = y.Value;
     double v = Math.Atan2(xv, yv);
     double u1 = x.Uncertainty * yv;
     double u2 = y.Uncertainty * xv;
     double u = Math.Sqrt(u1 * u1 + u2 * u2) / (xv * xv + yv * yv);
     return (new UncertainValue(v, u));
 }
예제 #24
0
 /// <summary>
 /// Computes the cosine of an uncertain value.
 /// </summary>
 /// <param name="x">The argument.</param>
 /// <returns>The cosine of the argument.</returns>
 public static UncertainValue Cos(UncertainValue x)
 {
     double v = Math.Cos(x.Value);
     double u = Math.Abs(Math.Sin(x.Value)) * x.Uncertainty;
     return (new UncertainValue(v, u));
     //UncertainValue y = new UncertainValue();
     //y.Value = Math.Cos(x.Value);
     //y.Uncertainty = Math.Abs(Math.Sin(x.Value)) * x.Uncertainty;
     //return (y);
 }
예제 #25
0
        /// <summary>
        /// Computes the arctangent of the ratio of two uncertain values.
        /// </summary>
        /// <param name="x">The argument of the numerator.</param>
        /// <param name="y">The argument of the denominator.</param>
        /// <returns>The arctangent of the quotient.</returns>
        public static UncertainValue Atan2(UncertainValue x, UncertainValue y)
        {
            double xv = x.Value;
            double yv = y.Value;
            double v  = Math.Atan2(xv, yv);
            double u1 = x.Uncertainty * yv;
            double u2 = y.Uncertainty * xv;
            double u  = Math.Sqrt(u1 * u1 + u2 * u2) / (xv * xv + yv * yv);

            return(new UncertainValue(v, u));
        }
예제 #26
0
        /// <summary>
        /// Computes the tangent of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The tanget of the argument.</returns>
        public static UncertainValue Tan(UncertainValue x)
        {
            double v = Math.Tan(x.Value);
            double u = (1.0 + MoreMath.Pow2(v)) * x.Uncertainty;

            return(new UncertainValue(v, u));
            //UncertainValue y = new UncertainValue();
            //y.Value = Math.Tan(x.Value);
            //y.Uncertainty = (1.0 + Math.Pow(y.Value, 2)) * x.Uncertainty;
            //return (y);
        }
예제 #27
0
        /// <summary>
        /// Computes the arcsine of an uncertain value.
        /// </summary>
        /// <param name="x">The argument.</param>
        /// <returns>The arcsine of the argument.</returns>
        public static UncertainValue Asin(UncertainValue x)
        {
            double v = Math.Asin(x.Value);
            double u = x.Uncertainty / Math.Abs(Math.Cos(v));

            return(new UncertainValue(v, u));
            //UncertainValue y = new UncertainValue();
            //y.Value = Math.Asin(x.Value);
            //y.Uncertainty = x.Uncertainty / Math.Abs(Math.Cos(y.Value));
            //return (y);
        }
예제 #28
0
 /// <summary>
 /// Determines whether the given object represents the same uncertain value.
 /// </summary>
 /// <param name="obj">The object.</param>
 /// <returns>True if the object represents the same reference point, otherwise false.</returns>
 public override bool Equals(object obj)
 {
     if (obj is UncertainValue)
     {
         UncertainValue uv = (UncertainValue)obj;
         return(this == uv);
     }
     else
     {
         return(false);
     }
 }
예제 #29
0
 internal IntegrationResult(UncertainValue estimate, int evaluationCount, EvaluationSettings settings)
     : base(evaluationCount, settings)
 {
     this.estimate = estimate;
 }
예제 #30
0
 /// <summary>
 /// Computes the hyperbolic tangent of an uncertain value.
 /// </summary>
 /// <param name="x">The argument.</param>
 /// <returns>The hyperbolic tanget of the argument.</returns>
 public static UncertainValue Tanh(UncertainValue x)
 {
     UncertainValue y = new UncertainValue();
     y.Value = Math.Tanh(x.Value);
     y.Uncertainty = y.Uncertainty / Math.Pow(Math.Cosh(x.Value), 2);
     return (y);
 }
예제 #31
0
 /// <summary>
 /// Computes the natural logarithm of an uncertain value.
 /// </summary>
 /// <param name="x">The argument.</param>
 /// <returns>The value of ln(x1).</returns>
 public static UncertainValue Log(UncertainValue x)
 {
     UncertainValue y = new UncertainValue();
     y.Value = Math.Log(x.Value);
     y.Uncertainty = x.RelativeUncertainty;
     return (y);
 }
예제 #32
0
 /// <summary>
 /// Computes the hyperbolic cosine of an uncertain value.
 /// </summary>
 /// <param name="x">The argument.</param>
 /// <returns>The hyperbolic cosine of the argument.</returns>
 public static UncertainValue Cosh(UncertainValue x)
 {
     UncertainValue y = new UncertainValue();
     y.Value = Math.Cosh(x.Value);
     y.Uncertainty = Math.Abs(Math.Sinh(x.Value)) * x.Uncertainty;
     return (y);
 }
예제 #33
0
 /// <summary>
 /// Computes the tangent of an uncertain value.
 /// </summary>
 /// <param name="x">The argument.</param>
 /// <returns>The tanget of the argument.</returns>
 public static UncertainValue Tan(UncertainValue x)
 {
     double v = Math.Tan(x.Value);
     double u = (1.0 + MoreMath.Pow2(v)) * x.Uncertainty;
     return (new UncertainValue(v, u));
     //UncertainValue y = new UncertainValue();
     //y.Value = Math.Tan(x.Value);
     //y.Uncertainty = (1.0 + Math.Pow(y.Value, 2)) * x.Uncertainty;
     //return (y);
 }
예제 #34
0
 // basic functions of uncertain values
 /// <summary>
 /// Computes the square root of an uncertain value.
 /// </summary>
 /// <param name="x">The argument.</param>
 /// <returns>The square root of the argument.</returns>
 public static UncertainValue Sqrt(UncertainValue x)
 {
     double v = Math.Sqrt(x.Value);
     double u = 0.5 * x.Uncertainty / v;
     return (new UncertainValue(v, u));
 }
예제 #35
0
 /// <summary>
 /// Computes an uncertain value raised to an arbitrary power.
 /// </summary>
 /// <param name="x">The argument.</param>
 /// <param name="p">The power.</param>
 /// <returns>The argument raised to the specified power.</returns>
 public static UncertainValue Pow(UncertainValue x, double p)
 {
     UncertainValue y = new UncertainValue();
     y.Value = Math.Pow(x.Value, p);
     y.Uncertainty = Math.Abs(p * y.Value * x.RelativeUncertainty);
     return (y);
 }
예제 #36
0
 public void UncertainValueConstructorTest()
 {
     UncertainValue u = new UncertainValue(1.0, -1.0);
 }
예제 #37
0
        public void UncertainValueZeroUncertaintiesTest()
        {
            UncertainValue p = new UncertainValue(3.141592653, 0.0);
            UncertainValue q = new UncertainValue(2.718281828, 0.0);

            UncertainValue sum = p + q;
            Assert.IsTrue(sum.Value == p.Value + q.Value);
            Assert.IsTrue(sum.Uncertainty == 0.0);

            UncertainValue difference = p - q;
            Assert.IsTrue(difference.Value == p.Value - q.Value);
            Assert.IsTrue(difference.Uncertainty == 0.0);

            UncertainValue product = p * q;
            Assert.IsTrue(product.Value == p.Value * q.Value);
            Assert.IsTrue(product.Uncertainty == 0.0);

            UncertainValue quotient = p / q;
            Assert.IsTrue(quotient.Value == p.Value / q.Value);
            Assert.IsTrue(quotient.Uncertainty == 0.0);

            UncertainValue exp = UncertainMath.Exp(p);
            Assert.IsTrue(exp.Value == Math.Exp(p.Value));
            Assert.IsTrue(exp.Uncertainty == 0.0);

            UncertainValue log = UncertainMath.Log(q);
            Assert.IsTrue(log.Value == Math.Log(q.Value));
            Assert.IsTrue(log.Uncertainty == 0.0);

            UncertainValue tan = UncertainMath.Tan(q);
            Assert.IsTrue(TestUtilities.IsNearlyEqual(tan.Value, Math.Tan(q.Value)));
            Assert.IsTrue(tan.Uncertainty == 0.0);

            UncertainValue atan = UncertainMath.Atan(q);
            Assert.IsTrue(TestUtilities.IsNearlyEqual(atan.Value, Math.Atan(q.Value)));
            Assert.IsTrue(atan.Uncertainty == 0.0);
        }
예제 #38
0
 /// <summary>
 /// Multiplies two uncertain values.
 /// </summary>
 /// <param name="v1">The first uncertain value.</param>
 /// <param name="v2">The second uncertain value.</param>
 /// <returns>The product of the two uncertain values.</returns>
 public static UncertainValue operator *(UncertainValue v1, UncertainValue v2)
 {
     UncertainValue v = new UncertainValue();
     v.Value = v1.Value * v2.Value;
     v.Uncertainty = Math.Abs(v.Value) * MoreMath.Hypot(v1.RelativeUncertainty, v2.RelativeUncertainty);
     return(v);
 }
예제 #39
0
 /// <summary>
 /// Computes e to the power of an uncertain value.
 /// </summary>
 /// <param name="x">The argument.</param>
 /// <returns>The value of e^<sup>x1</sup>.</returns>
 public static UncertainValue Exp(UncertainValue x)
 {
     UncertainValue y = new UncertainValue();
     y.Value = Math.Exp(x.Value);
     y.Uncertainty = y.Value * x.Uncertainty;
     return (y);
 }