public void SuccessfullyCalculateHyperbolicArccosineOfPositiveAngle() { var value = 60; var function = new HyperbolicArccosineFunction(); var phase = function.Calculate(); Assert.NotNull(phase); Assert.Equal("Specify Argument", phase.Name); Assert.Equal("Specify angle to find the hyperbolic arccosine of.", phase.Description); Assert.Collection(phase.Inputs, i => { Assert.Equal("Angle", i.Info.Name); Assert.Null(i.Info.Description); Assert.Equal(new RadianUnit(), i.Info.Unit); }); phase.Inputs[0].Value = value; Assert.Null(function.Calculate(phase)); Assert.Collection(function.CurrentResult, i => { Assert.Equal(typeof(double), i.ValueType); Assert.Equal(Math.Acosh(value), TypeConverter.ToObject <double>(i.Value)); }); }
static void Main(string[] args) { Console.WriteLine("Enter x : "); int x = int.Parse(Console.ReadLine()); Console.WriteLine("Enter y : "); int y = int.Parse(Console.ReadLine()); double z = 0; if (x < 0 && y > 10) { z = Math.Asinh(x) + 2; } else if (x > 0 && y <= 1) { z = Math.Acosh(x) - y; } else { Console.WriteLine("You enter wrong \"x\" and \"y\"!!!"); } Console.WriteLine("z = " + z); //test coment }
public static double HyperbolicTransversalLength(int p, int q) { double a = 2 * Math.PI / p; double b = Math.PI / q; return(Math.Acosh((Math.Cos(b) + Math.Cos(a) * Math.Cos(b)) / (Math.Sin(a) * Math.Sin(b)))); }
//Finds The Hyperbolic Arc Cosine Of The Number public static Numbers ArcCosineh(Numbers num) { Numbers result = new Numbers(); result.number = Math.Acosh(num.number); result.Nbase = num.Nbase; return(result); }
// (F: f1 -- f2) private int FAcoshAction() { _interpreter.FStackExpect(1); _interpreter.FFunction((a) => Math.Acosh(a)); return(1); }
public override IValue[] Calculate(IValue[] inputs) { this.CheckInputs(inputs); var angle = (AgnosticValue)inputs[0]; var result = Math.Acosh(angle.GetValueAs <double>()); return(this.CreateResults(result)); }
// Calculates the angle that gives a specified hyperbolic cosine (1 ≤ input). public static CalcValue AcoshFunction(CalcObject[] pars, CLLocalStore vars, CLContextProvider context) { if (pars.Length == 0) { throw new CLException("{!acosh} requires a number."); } CalcNumber num = NumberAt(pars, 0, "!acosh", vars, context); return(new CalcNumber((decimal)Math.Acosh((double)num.Value))); }
private void MathMethod(int value1) { Math.Round(10.897890, 2); // یک عدد را رند میکند //Rand a number Math.Sqrt(50.90); Math.Abs(-10); Math.Ceiling(10.98); Math.Cos(270); Math.Cosh(234.324); Math.Max(20, 100); // خروجی = 100 // Max value = 100 Math.Min(14, Math.Acos(0.2343232)); // میتوان در ورودی یک متد ریاضی یک متد را پاس داد Math.Sin(180); Math.Pow(2, 16); // یک عدد را به توان میرساند(2 به توان 18)در ورودی وارد شده double f = Math.PI; // عدد پی دا در خود ذخیره دارد int result = 0; Math.DivRem(57777, 78, out result); Math.Floor(54.7657); Math.Log(100);// لگاریتم Math.Acosh(6.89879); Math.Asinh(54.876); Math.Atan(76.89); Math.Atan2(34.234, 23.23); Math.Atanh(8.34); Math.BigMul(12, 120); Math.BitDecrement(12.12); Math.BitIncrement(12.12); Math.Cbrt(23.123); Math.Clamp(12, 4334, 3444); Math.CopySign(23.432, 11.98); Math.Equals(12, 12); Math.Exp(55.99); Math.FusedMultiplyAdd(24.1, 25.7, 26.8); Math.IEEERemainder(88.8, 44.4); Math.ILogB(4.66666); Math.Log(5.0001); Math.Log10(5.0001); Math.Log2(5.0001); Math.MaxMagnitude(5.0001, 52.0001); Math.MinMagnitude(88.8, 44.4); Math.ReferenceEquals(88.8, 44.4); Math.ScaleB(88.8, 44); Math.Sign(88); Math.Sinh(88.8); Math.Tanh(88.8); Math.Truncate(22.2); double e = Math.E; double sum = e + f; // Methods of Math class...^ Math.Max(Math.Sin(180), Math.Cos(270)); }
public void ArcoshTest() { for (Int64 i = 100; i <= 400; i++) { MultiPrecision <Pow2.N8> x = (MultiPrecision <Pow2.N8>)i / 100; MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Arcosh(x); Console.WriteLine(x); Console.WriteLine(y); TestTool.Tolerance(Math.Acosh((double)x), y); } }
public static void AcoshTest() { double result = 0.0, value = 1.0; for (int iteration = 0; iteration < MathTests.Iterations; iteration++) { result += Math.Acosh(value); value += acoshDelta; } double diff = Math.Abs(acoshExpectedResult - result); if (double.IsNaN(result) || (diff > MathTests.DoubleEpsilon)) { throw new Exception($"Expected Result {acoshExpectedResult,20:g17}; Actual Result {result,20:g17}"); } }
public void SuccessfullyCalculateHyperbolicArccosineWithNoAngleSpecified() { var function = new HyperbolicArccosineFunction(); var phase = function.Calculate(); Assert.NotNull(phase); Assert.Null(function.Calculate(phase)); Assert.Collection(function.CurrentResult, i => { Assert.Equal(typeof(double), function.CurrentResult[0].ValueType); Assert.Equal(Math.Acosh(0.0), TypeConverter.ToObject <double>(function.CurrentResult[0].Value)); }); }
public void TestAcosh() { Skip.IfNot(NetVips.AtLeastLibvips(8, 12), "requires libvips >= 8.12"); dynamic Acosh(dynamic x) { if (x is Image image) { return(image.Acosh()); } return(Math.Acosh(x)); } var im = (Image.Black(100, 100) + new[] { 4, 5, 6 }) / 3.0; RunUnary(new[] { im }, Acosh, Helper.NonComplexFormats); }
public void SuccessfullyCalculateHyperbolicArccosineOfNegativeAngle() { var value = -54; var function = new HyperbolicArccosineFunction(); var phase = function.Calculate(); Assert.NotNull(phase); phase.Inputs[0].Value = value; Assert.Null(function.Calculate(phase)); Assert.Collection(function.CurrentResult, i => { Assert.Equal(typeof(double), i.ValueType); Assert.Equal(Math.Acosh(value), TypeConverter.ToObject <double>(i.Value)); }); }
public void ArcoshBorderTest() { MultiPrecision <Pow2.N8>[] borders = new MultiPrecision <Pow2.N8>[] { 1, 2 }; foreach (MultiPrecision <Pow2.N8> b in borders) { List <MultiPrecision <Pow2.N8> > ys = new(); foreach (MultiPrecision <Pow2.N8> x in TestTool.EnumerateNeighbor(b)) { if (x < 1) { continue; } MultiPrecision <Pow2.N8> y = MultiPrecision <Pow2.N8> .Arcosh(x); Console.WriteLine(x); Console.WriteLine(x.ToHexcode()); Console.WriteLine(y); Console.WriteLine(y.ToHexcode()); Console.Write("\n"); TestTool.Tolerance(Math.Acosh((double)x), y, ignore_expected_nan: true, ignore_sign: true); ys.Add(y); } TestTool.SmoothnessSatisfied(ys, (b == 1) ? 2.5 : 1); TestTool.MonotonicitySatisfied(ys); Console.Write("\n"); } }
/// <inheritdoc /> public double Acosh(double value) { return(Math.Acosh(value)); }
public Test(Mode modeParam, TextWriter errorOutParam, TextWriter infoOutParam, Table table) { _table = table; _mode = modeParam; _errorOut = errorOutParam; _infoOut = infoOutParam; _failedOperations = new HashSet <string>(); // Validate parsing, this whole program expects little endian { uint val = 1234567891; if (Convert.ToUInt32(ToBinary(Convert.ToUInt32(ToBinary(val), 2)), 2) != val) { ReportError($"{nameof(ToBinary)} and back failed"); } } for (int testIndex = 0; testIndex < _table.Data.Length; testIndex++) { for (int testResult = 0; testResult < (_table.Data[testIndex].results?.Length ?? 0); testResult++) { var result = _table.Data[testIndex].results[testResult]; var asFloat = To <uint, float>(result.i); if (asFloat != result.f && !NaNAndBitsMatch(asFloat, result.f)) { ReportError($"FAILED PARSING {ToBinary(result.i)} to value {result.f.ToString("G9", CultureInfo.InvariantCulture)}, expected {ToBinary(result.f)}"); } } } for (int testIndex = 0; testIndex < _table.Data.Length; testIndex++) { float value = To <uint, float>(_table.Data[testIndex].initialValue); // Certain operations are funneling tests into specific ranges of values // so we aren't just using them as is, that is dVal's purpose in this code StartValidation(value); Validate(testIndex, "BIN", value); Validate(testIndex, "+", value + 0.1735f); Validate(testIndex, "-", value - 17f); Validate(testIndex, "*", value * 7.7757f); Validate(testIndex, "/", value / 0.3353f); Validate(testIndex, "%", value % 7.0f); // MATHF Validate(testIndex, nameof(MathF.Abs), MathF.Abs(value)); Validate(testIndex, nameof(MathF.Acos), MathF.Acos(value % 1f)); Validate(testIndex, nameof(MathF.Acosh), MathF.Acosh(1f + MathF.Abs(value))); Validate(testIndex, nameof(MathF.Asin), MathF.Asin(value % 1f)); Validate(testIndex, nameof(MathF.Asinh), MathF.Asinh(value)); Validate(testIndex, nameof(MathF.Atan), MathF.Atan(value)); Validate(testIndex, nameof(MathF.Atan2), MathF.Atan2(value, 0.17f)); Validate(testIndex, nameof(MathF.Atanh), MathF.Atanh(value % 1f)); Validate(testIndex, nameof(MathF.Cbrt), MathF.Cbrt(value)); Validate(testIndex, nameof(MathF.Ceiling), MathF.Ceiling(value)); Validate(testIndex, nameof(MathF.Cos), MathF.Cos(value)); Validate(testIndex, nameof(MathF.Cosh), MathF.Cosh(value % 2f)); Validate(testIndex, nameof(MathF.Exp), MathF.Exp(1f / value)); Validate(testIndex, nameof(MathF.Floor), MathF.Floor(value)); Validate(testIndex, nameof(MathF.FusedMultiplyAdd), MathF.FusedMultiplyAdd(value, 1.33f, -1.5f)); Validate(testIndex, nameof(MathF.IEEERemainder), MathF.IEEERemainder(value, 25.78f)); Validate(testIndex, nameof(MathF.Log), MathF.Log(MathF.Abs(value))); Validate(testIndex, nameof(MathF.Log) + "(x,y)", MathF.Log(MathF.Abs(value), 4f)); Validate(testIndex, nameof(MathF.Log2), MathF.Log2(MathF.Abs(value))); Validate(testIndex, nameof(MathF.Log10), MathF.Log10(MathF.Abs(value))); Validate(testIndex, nameof(MathF.Pow), MathF.Pow(MathF.Abs(value) % 1E+23f, 1.7f)); Validate(testIndex, nameof(MathF.ScaleB), MathF.ScaleB(value % 1E+23f, 2)); Validate(testIndex, nameof(MathF.Sin), MathF.Sin(value)); Validate(testIndex, nameof(MathF.Sinh), MathF.Sinh(value % 2f)); Validate(testIndex, nameof(MathF.Sqrt), MathF.Sqrt(MathF.Abs(value))); Validate(testIndex, nameof(MathF.Tan), MathF.Tan(value)); Validate(testIndex, nameof(MathF.Tanh), MathF.Tanh(value)); Validate(testIndex, nameof(MathF.Max), MathF.Max(value, 0.9f)); Validate(testIndex, nameof(MathF.MaxMagnitude), MathF.MaxMagnitude(value, -0.7f)); Validate(testIndex, nameof(MathF.Min), MathF.Min(value, 307f)); Validate(testIndex, nameof(MathF.MinMagnitude), MathF.MinMagnitude(value, -8.89f)); Validate(testIndex, nameof(MathF.Round), MathF.Round(value)); if (float.IsNaN(value) == false) { Validate(testIndex, nameof(MathF.Sign), MathF.Sign(value)); } Validate(testIndex, nameof(MathF.Truncate), MathF.Truncate(value)); // MATH double valueAsDouble = value; Validate(testIndex, $"D.{nameof(Math.Abs)}", Math.Abs(valueAsDouble)); Validate(testIndex, $"D.{nameof(Math.Acos)}", Math.Acos(valueAsDouble % 1d)); Validate(testIndex, $"D.{nameof(Math.Acosh)}", Math.Acosh(1d + Math.Abs(valueAsDouble))); Validate(testIndex, $"D.{nameof(Math.Asin)}", Math.Asin(valueAsDouble % 1d)); Validate(testIndex, $"D.{nameof(Math.Asinh)}", Math.Asinh(valueAsDouble)); Validate(testIndex, $"D.{nameof(Math.Atan)}", Math.Atan(valueAsDouble)); Validate(testIndex, $"D.{nameof(Math.Atan2)}", Math.Atan2(valueAsDouble, 0.17d)); Validate(testIndex, $"D.{nameof(Math.Atanh)}", Math.Atanh(valueAsDouble % 1d)); Validate(testIndex, $"D.{nameof(Math.Cbrt)}", Math.Cbrt(valueAsDouble)); Validate(testIndex, $"D.{nameof(Math.Ceiling)}", Math.Ceiling(valueAsDouble)); Validate(testIndex, $"D.{nameof(Math.Cos)}", Math.Cos(valueAsDouble)); Validate(testIndex, $"D.{nameof(Math.Cosh)}", Math.Cosh(valueAsDouble % 2d)); Validate(testIndex, $"D.{nameof(Math.Exp)}", Math.Exp(1d / valueAsDouble)); Validate(testIndex, $"D.{nameof(Math.Floor)}", Math.Floor(valueAsDouble)); Validate(testIndex, $"D.{nameof(Math.FusedMultiplyAdd)}", Math.FusedMultiplyAdd(valueAsDouble, 1.33d, -1.5d)); Validate(testIndex, $"D.{nameof(Math.IEEERemainder)}", Math.IEEERemainder(valueAsDouble, 25.78d)); Validate(testIndex, $"D.{nameof(Math.Log)}", Math.Log(Math.Abs(valueAsDouble))); Validate(testIndex, $"D.{nameof(Math.Log)}" + "(x,y)", Math.Log(Math.Abs(valueAsDouble), 4d)); Validate(testIndex, $"D.{nameof(Math.Log2)}", Math.Log2(Math.Abs(valueAsDouble))); Validate(testIndex, $"D.{nameof(Math.Log10)}", Math.Log10(Math.Abs(valueAsDouble))); Validate(testIndex, $"D.{nameof(Math.Pow)}", Math.Pow(Math.Abs(valueAsDouble) % 1E+23d, 1.7d)); Validate(testIndex, $"D.{nameof(Math.ScaleB)}", Math.ScaleB(valueAsDouble % 1E+23d, 2)); Validate(testIndex, $"D.{nameof(Math.Sin)}", Math.Sin(valueAsDouble)); Validate(testIndex, $"D.{nameof(Math.Sinh)}", Math.Sinh(valueAsDouble % 2d)); Validate(testIndex, $"D.{nameof(Math.Sqrt)}", Math.Sqrt(Math.Abs(valueAsDouble))); Validate(testIndex, $"D.{nameof(Math.Tan)}", Math.Tan(valueAsDouble)); Validate(testIndex, $"D.{nameof(Math.Tanh)}", Math.Tanh(valueAsDouble)); Validate(testIndex, $"D.{nameof(Math.Max)}", Math.Max(valueAsDouble, 0.9d)); Validate(testIndex, $"D.{nameof(Math.MaxMagnitude)}", Math.MaxMagnitude(valueAsDouble, -0.7d)); Validate(testIndex, $"D.{nameof(Math.Min)}", Math.Min(valueAsDouble, 307d)); Validate(testIndex, $"D.{nameof(Math.MinMagnitude)}", Math.MinMagnitude(valueAsDouble, -8.89d)); Validate(testIndex, $"D.{nameof(Math.Round)}", Math.Round(valueAsDouble)); if (float.IsNaN(value) == false) { Validate(testIndex, $"D.{nameof(Math.Sign)}", Math.Sign(valueAsDouble)); } Validate(testIndex, $"D.{nameof(Math.Truncate)}", Math.Truncate(valueAsDouble)); } }
private static void SolveVieta(double[] coefficients, out Complex fSolve, out Complex sSolve, out Complex tSolve) { var tmp = new double[4]; Array.Copy(coefficients, tmp, 4); for (var i = 0; i < coefficients.Length; ++i) { tmp[i] /= coefficients[0]; } double a = tmp[1], b = tmp[2], c = tmp[3]; double Q = (a * a - 3 * b) / 9, R = (2 * a * a * a - 9 * a * b + 27 * c) / 54; var S = Q * Q * Q - R * R; if (S > 0) { var phi = Math.Acos(R / Math.Pow(Q, 3.0 / 2)) / 3; fSolve = -2 * Math.Sqrt(Q) * Math.Cos(phi) - a / 3; sSolve = -Math.Sqrt(Q) * Math.Cos(phi + 2 * Math.PI / 3) - a / 3; tSolve = -Math.Sqrt(Q) * Math.Cos(phi - 2 * Math.PI / 3) - a / 3; } else if (S < 0) { if (Q > 0) { var phi = Math.Acosh(Math.Abs(R) / Math.Pow(Math.Abs(Q), 3.0 / 2)) / 3; fSolve = -2 * Math.Sign(R) * Math.Sqrt(Math.Abs(Q)) * Math.Cosh(phi) - a / 3; sSolve = Math.Sign(R) * Math.Sqrt(Math.Abs(Q)) * Math.Cosh(phi) - a / 3 + Math.Sqrt(3 * Math.Abs(Q)) * Math.Sinh(phi) * Complex.ImaginaryOne; tSolve = Math.Sign(R) * Math.Sqrt(Math.Abs(Q)) * Math.Cosh(phi) - a / 3 - Math.Sqrt(3 * Math.Abs(Q)) * Math.Sinh(phi) * Complex.ImaginaryOne; } else if (Q < 0) { var phi = Math.Asinh(Math.Abs(R) / Math.Pow(Math.Abs(Q), 3.0 / 2)) / 3; fSolve = -2 * Math.Sign(R) * Math.Sqrt(Math.Abs(Q)) * Math.Sinh(phi) - a / 3; double real = Math.Sign(R) * Math.Sqrt(Math.Abs(Q)) * Math.Sinh(phi) - a / 3, im = Math.Sqrt(3 * Math.Abs(Q)) * Math.Cosh(phi); sSolve = real + Complex.ImaginaryOne * im; tSolve = real - Complex.ImaginaryOne * im; } else { fSolve = -Math.Cbrt(c - a * a * a / 27) - a / 3; var solve = -Math.Cbrt(c - a * a * a / 27) - a / 3; double real = -(a + solve) / 2, im = 0.5 * Math.Sqrt(Math.Abs((a - 3 * solve) * (a + solve) - 4 * b)); sSolve = real + Complex.ImaginaryOne * im; tSolve = real - Complex.ImaginaryOne * im; } } else { fSolve = -2 * Math.Pow(R, 1.0 / 3) - a / 3; sSolve = tSolve = Math.Pow(R, 1.0 / 3) - a / 3; } }
public void Run() { featureTest.FailureMessage = "\tFailed Math Test"; featureTest.Send("Math Test"); featureTest.AssertTrue(Math.Abs(-3.0) == 3.0); featureTest.AssertTrue(Math.Abs(3.0) == 3.0); featureTest.AssertTrue(Math.Abs(((short)-3)) == 3); featureTest.AssertTrue(Math.Abs(((short)3)) == 3); featureTest.AssertTrue(Math.Abs(((int)-3)) == 3); featureTest.AssertTrue(Math.Abs(((int)3)) == 3); featureTest.AssertTrue(Math.Abs(((long)-3)) == 3); featureTest.AssertTrue(Math.Abs(((long)3)) == 3); featureTest.AssertTrue(Math.Abs(((sbyte)-3)) == 3); featureTest.AssertTrue(Math.Abs(((SByte)3)) == 3); featureTest.AssertTrue(Math.Abs(((float)-3.0F)) == 3.0); featureTest.AssertTrue(Math.Abs(((float)3.0F)) == 3.0); featureTest.AssertTrue(Math.Acos(0.5), 1.0471975511966); featureTest.AssertTrue(Math.Acosh(4.0), 2.0634370); featureTest.AssertTrue(Math.Asin(0.25), 0.25268); featureTest.AssertTrue(Math.Asinh(-6.82), -2.61834); featureTest.AssertTrue(Math.Atan(57.74), 1.55348); featureTest.AssertTrue(Math.Atanh(0.32), 0.331647); featureTest.AssertTrue(Math.Atan2(-10, 10), -0.785398); featureTest.AssertTrue(Math.BigMul(10000, 10000) == 10000 * 10000); featureTest.AssertTrue(Math.Cbrt(0.70710678118654752), 0.89089871814033930); featureTest.AssertTrue(Double.IsNaN(Math.Cbrt(Double.NaN))); featureTest.AssertTrue(Math.Ceiling(0.31830988618379067), 1.0); featureTest.AssertTrue(Math.Ceiling(2.3025850929940457), 3.0); featureTest.AssertTrue(Math.Ceiling(-3.1415926535897932), -3.0); featureTest.AssertTrue(Double.IsNaN(Math.Ceiling(Double.NaN))); featureTest.AssertTrue(Math.Clamp((Byte)3, (Byte)2, (Byte)4) == 3); featureTest.AssertTrue(Math.Clamp((Byte)1, (Byte)2, (Byte)4) == 2); featureTest.AssertTrue(Math.Clamp((Byte)5, (Byte)2, (Byte)4) == 4); featureTest.AssertTrue(Math.Clamp((Double)3, (Double)2, (Double)4) == 3); featureTest.AssertTrue(Math.Clamp((Double)1, (Double)2, (Double)4) == 2); featureTest.AssertTrue(Math.Clamp((Double)5, (Double)2, (Double)4) == 4); featureTest.AssertTrue(Math.Clamp((Int16)3, (Int16)2, (Int16)4) == 3); featureTest.AssertTrue(Math.Clamp((Int16)1, (Int16)2, (Int16)4) == 2); featureTest.AssertTrue(Math.Clamp((Int16)5, (Int16)2, (Int16)4) == 4); featureTest.AssertTrue(Math.Clamp((Int32)3, (Int32)2, (Int32)4) == 3); featureTest.AssertTrue(Math.Clamp((Int32)1, (Int32)2, (Int32)4) == 2); featureTest.AssertTrue(Math.Clamp((Int32)5, (Int32)2, (Int32)4) == 4); featureTest.AssertTrue(Math.Clamp((Int64)3, (Int64)2, (Int64)4) == 3); featureTest.AssertTrue(Math.Clamp((Int64)1, (Int64)2, (Int64)4) == 2); featureTest.AssertTrue(Math.Clamp((Int64)5, (Int64)2, (Int64)4) == 4); featureTest.AssertTrue(Math.Clamp((SByte)3, (SByte)2, (SByte)4) == 3); featureTest.AssertTrue(Math.Clamp((SByte)1, (SByte)2, (SByte)4) == 2); featureTest.AssertTrue(Math.Clamp((SByte)5, (SByte)2, (SByte)4) == 4); featureTest.AssertTrue(Math.Clamp((UInt16)3, (UInt16)2, (UInt16)4) == 3); featureTest.AssertTrue(Math.Clamp((UInt16)1, (UInt16)2, (UInt16)4) == 2); featureTest.AssertTrue(Math.Clamp((UInt16)5, (UInt16)2, (UInt16)4) == 4); featureTest.AssertTrue(Math.Clamp((UInt32)3, (UInt32)2, (UInt32)4) == 3); featureTest.AssertTrue(Math.Clamp((UInt32)1, (UInt32)2, (UInt32)4) == 2); featureTest.AssertTrue(Math.Clamp((UInt32)5, (UInt32)2, (UInt32)4) == 4); featureTest.AssertTrue(Math.Clamp((UInt64)3, (UInt64)2, (UInt64)4) == 3); featureTest.AssertTrue(Math.Clamp((UInt64)1, (UInt64)2, (UInt64)4) == 2); featureTest.AssertTrue(Math.Clamp((UInt64)5, (UInt64)2, (UInt64)4) == 4); featureTest.AssertTrue(Math.Cos(-3.1415926535897932), -1.0); featureTest.AssertTrue(Math.Cosh(-3.1415926535897932), 11.591953275521521); Int32 whole; Int32 remainder; whole = Math.DivRem(2147483647, 1073741, out remainder); featureTest.AssertTrue(whole == 2000 && remainder == 1647); Int64 whole2; Int64 remainder2; whole2 = Math.DivRem(9223372036854775807L, 4611686018427387L, out remainder2); featureTest.AssertTrue(whole2 == 2000 && remainder2 == 1807L); featureTest.AssertTrue(Math.Exp(-3.1415926535897932), 0.043213918263772250); featureTest.AssertTrue(Math.Floor(-3.1415926535897932), -4.0); featureTest.AssertTrue(Math.IEEERemainder(3, 2), -1); featureTest.AssertTrue(Math.Log(0.043213918263772250), -3.1415926535897932); featureTest.AssertTrue(Math.Log(14, 3.0), 2.40217350273); featureTest.AssertTrue(Math.Log10(6.1009598002416937), 0.78539816339744831); featureTest.AssertTrue(Math.Max((Byte)5, (Byte)3) == 5); featureTest.AssertTrue(Math.Max((Double)5, (Double)3) == 5); featureTest.AssertTrue(Math.Max((Int16)5, (Int16)3) == 5); featureTest.AssertTrue(Math.Max((Int32)5, (Int32)3) == 5); featureTest.AssertTrue(Math.Max((Int64)5, (Int64)3) == 5); featureTest.AssertTrue(Math.Max((SByte)5, (SByte)3) == 5); featureTest.AssertTrue(Math.Max((Single)5, (Single)3) == 5); featureTest.AssertTrue(Math.Max((UInt16)5, (UInt16)3) == 5); featureTest.AssertTrue(Math.Max((UInt32)5, (UInt32)3) == 5); featureTest.AssertTrue(Math.Max((UInt64)5, (UInt64)3) == 5); featureTest.AssertTrue(Math.Min((Byte)5, (Byte)3) == 3); featureTest.AssertTrue(Math.Min((Double)5, (Double)3) == 3); featureTest.AssertTrue(Math.Min((Int16)5, (Int16)3) == 3); featureTest.AssertTrue(Math.Min((Int32)5, (Int32)3) == 3); featureTest.AssertTrue(Math.Min((Int64)5, (Int64)3) == 3); featureTest.AssertTrue(Math.Min((SByte)5, (SByte)3) == 3); featureTest.AssertTrue(Math.Min((Single)5, (Single)3) == 3); featureTest.AssertTrue(Math.Min((UInt16)5, (UInt16)3) == 3); featureTest.AssertTrue(Math.Min((UInt32)5, (UInt32)3) == 3); featureTest.AssertTrue(Math.Min((UInt64)5, (UInt64)3) == 3); featureTest.AssertTrue(Math.Pow(7.0, 3.0), 343.0); featureTest.AssertTrue(Math.Round(1.4), 1.0); featureTest.AssertTrue(Math.Round(1.5), 2.0); featureTest.AssertTrue(Math.Round(3.42156, 3, MidpointRounding.AwayFromZero), 3.422); featureTest.AssertTrue(Math.Sign(1.4) == 1); featureTest.AssertTrue(Math.Sign(-1.4) == -1); featureTest.AssertTrue(Math.Sign((short)2) == 1); featureTest.AssertTrue(Math.Sign((short)-2) == -1); featureTest.AssertTrue(Math.Sign((int)2) == 1); featureTest.AssertTrue(Math.Sign((int)-2) == -1); featureTest.AssertTrue(Math.Sign((long)2) == 1); featureTest.AssertTrue(Math.Sign((long)-2) == -1); featureTest.AssertTrue(Math.Sign((float)2) == 1); featureTest.AssertTrue(Math.Sign((float)-2) == -1); featureTest.AssertTrue(Math.Sin(1.4426950408889634), 0.99180624439366372); featureTest.AssertTrue(Math.Sinh(-1.5707963267948966), -2.3012989023072949); featureTest.AssertTrue(Math.Sqrt(0.31830988618379067), 0.56418958354775629); featureTest.AssertTrue(Math.Tan(-2.3025850929940457), 1.1134071468135374); featureTest.AssertTrue(Math.Tanh(-3.1415926535897932), -0.99627207622074994); featureTest.AssertTrue(Math.Truncate(3.14159), 3.0); #if V3 featureTest.AssertTrue(Math.BitDecrement(0.63661977236758134), 0.63661977236758127); featureTest.AssertTrue(Double.IsNaN(Math.BitDecrement(Double.NaN))); featureTest.AssertTrue(Math.BitDecrement(0), Double.Epsilon); featureTest.AssertTrue(Double.IsNegativeInfinity(Math.BitDecrement(Double.NegativeInfinity))); featureTest.AssertTrue(Math.BitIncrement(0.63661977236758134), 0.63661977236758149); featureTest.AssertTrue(Double.IsNaN(Math.BitIncrement(Double.NaN))); featureTest.AssertTrue(Math.BitIncrement(0), Double.Epsilon); featureTest.AssertTrue(Math.BitIncrement(Double.NegativeInfinity), Double.MinValue); featureTest.AssertTrue(Math.CopySign(-3.1415926535897932, -3.1415926535897932), -3.1415926535897932); featureTest.AssertTrue(Math.CopySign(-3.1415926535897932, 0.0), 3.1415926535897932); featureTest.AssertTrue(Math.CopySign(-3.1415926535897932, -0.0), -3.1415926535897932); featureTest.AssertTrue(Math.CopySign(-3.1415926535897932, Double.NaN), -3.1415926535897932); featureTest.AssertTrue(Math.FusedMultiplyAdd(5, 4, 3), 23); featureTest.AssertTrue(Math.ILogB(0.11331473229676087), -4.0); featureTest.AssertTrue(Math.ILogB(0.5), -1.0); featureTest.AssertTrue(Math.Log2(0.58019181037172444), -0.78539816339744831); featureTest.AssertTrue(Math.MaxMagnitude(2.0, -3.0), -3); featureTest.AssertTrue(Math.MinMagnitude(2.0, -3.0), 2.0); featureTest.AssertTrue(Math.ScaleB(4.9334096679145963, 2), 19.733638671658387); #endif }
public ExcelValue ACOSH(List <ExcelValue> args, ExpressionScope scope) => Math1(args, scope, v => Math.Acosh(v), v => v <= -1 || v == 0);
public static void Acosh(double value, double expectedResult, double allowedVariance) { AssertEqual(expectedResult, Math.Acosh(value), allowedVariance); }
//Acosh public double Acosh(double Number1) { Result = Math.Acosh(Number1); History.Add(Result); return(Result); }
public double kappa(double lambdaL, double lambdaS, double aL, double time) { //double temp = Math.Sqrt(Math.PI) * (lambdaL - lambdaS) / (2 * aL * Math.Sqrt(time)); //double temp = SpecialFunction.gamma(0.2) * (lambdaL - lambdaS) / (5 * aL * Math.Pow(time,0.2)); //double temp = Math.Sqrt(Math.PI) * (lambdaL - lambdaS) / (2 * aL * Math.Sqrt(time)); double temp = (-2 * Math.Sqrt(Math.PI) * (Math.Sqrt(4 - time) + 2 * time - 8)) / (Math.Acosh(2 / (Math.Sqrt(4 - time)))); return(temp); }
public void HyperbolicArcusSecantTest() { var func = MathContext.Default.GetFunction("asech"); Assert.AreEqual(1 / Math.Acosh(45 * DegreesToRadians), func.Call(new double[] { 45 }), Delta); }
/// <inheritdoc cref="Math.Acosh(double)"/> public static double Acosh(this double value) => Math.Acosh(value);
public static void Initialize() { lock (initializeLock) { if (initialized) { return; } initialized = true; LambdaExpression assign; { var parameters = new ParameterExpression[] { Expression.Parameter(typeof(double), "x"), Expression.Parameter(typeof(double), "y") }; var returnLabel = Expression.Label(typeof(double), "return"); assign = Expression.Lambda(typeof(Func <double, double, double>), Expression.Block( parameters, Expression.Assign(parameters[0], parameters[1]), Expression.Label(returnLabel, parameters[0]) ), parameters); } LambdaExpression increment; { var parameters = new ParameterExpression[] { Expression.Parameter(typeof(double), "x") }; increment = Expression.Lambda(typeof(Func <double, double>), Expression.PostIncrementAssign(parameters[0]), parameters); } LambdaExpression decrement; { var parameters = new ParameterExpression[] { Expression.Parameter(typeof(double), "x") }; decrement = Expression.Lambda(typeof(Func <double, double>), Expression.PostDecrementAssign(parameters[0]), parameters); } LambdaExpression addAssign; { var parameters = new ParameterExpression[] { Expression.Parameter(typeof(double), "x"), Expression.Parameter(typeof(double), "y") }; addAssign = Expression.Lambda(typeof(Func <double, double, double>), Expression.AddAssign(parameters[0], parameters[1]), parameters); } LambdaExpression subtractAssign; { var parameters = new ParameterExpression[] { Expression.Parameter(typeof(double), "x"), Expression.Parameter(typeof(double), "y") }; subtractAssign = Expression.Lambda(typeof(Func <double, double, double>), Expression.SubtractAssign(parameters[0], parameters[1]), parameters); } LambdaExpression multiplyAssign; { var parameters = new ParameterExpression[] { Expression.Parameter(typeof(double), "x"), Expression.Parameter(typeof(double), "y") }; multiplyAssign = Expression.Lambda(typeof(Func <double, double, double>), Expression.MultiplyAssign(parameters[0], parameters[1]), parameters); } LambdaExpression divideAssign; { var parameters = new ParameterExpression[] { Expression.Parameter(typeof(double), "x"), Expression.Parameter(typeof(double), "y") }; divideAssign = Expression.Lambda(typeof(Func <double, double, double>), Expression.DivideAssign(parameters[0], parameters[1]), parameters); } LambdaExpression exponential; { var parameters = new ParameterExpression[] { Expression.Parameter(typeof(double), "x") }; var returnLabel = Expression.Label(typeof(double), "return"); var i = Expression.Variable(typeof(int), "i"); var result = Expression.Variable(typeof(double), "result"); exponential = Expression.Lambda(typeof(Func <double, double>), Expression.Block( new[] { i, result }, Expression.Assign(i, Expression.Convert(parameters[0], typeof(int))), Expression.Assign(result, Expression.Constant(1d, typeof(double))), Expression.Loop( Expression.IfThenElse( Expression.GreaterThan(i, Expression.Constant(1, typeof(int))), Expression.MultiplyAssign(result, Expression.Convert(Expression.PostDecrementAssign(i), typeof(double))), Expression.Return(returnLabel, result) ) ), Expression.Label(returnLabel, result) ), parameters); } methodOperators.Add(new MethodOperator("e", (args) => Math.Exp(args[0]))); methodOperators.Add(new MethodOperator("log", (args) => Math.Log(args[0], args.Length > 1 ? args[1] : 10))); methodOperators.Add(new MethodOperator("ln", (args) => Math.Log(args[0]))); methodOperators.Add(new MethodOperator("sin", (args) => Math.Sin(args[0]))); methodOperators.Add(new MethodOperator("cos", (args) => Math.Cos(args[0]))); methodOperators.Add(new MethodOperator("tan", (args) => Math.Tan(args[0]))); methodOperators.Add(new MethodOperator("asin", (args) => Math.Asin(args[0]))); methodOperators.Add(new MethodOperator("acos", (args) => Math.Acos(args[0]))); methodOperators.Add(new MethodOperator("atan", (args) => Math.Atan(args[0]))); methodOperators.Add(new MethodOperator("sinh", (args) => Math.Sinh(args[0]))); methodOperators.Add(new MethodOperator("cosh", (args) => Math.Cosh(args[0]))); methodOperators.Add(new MethodOperator("tanh", (args) => Math.Tanh(args[0]))); #if !NETSTANDARD2_0 methodOperators.Add(new MethodOperator("asinh", (args) => Math.Asinh(args[0]))); methodOperators.Add(new MethodOperator("acosh", (args) => Math.Acosh(args[0]))); methodOperators.Add(new MethodOperator("atanh", (args) => Math.Atanh(args[0]))); #endif methodOperators.Add(new MethodOperator("abs", (args) => Math.Abs(args[0]))); methodOperators.Add(new MethodOperator("round", (args) => Math.Round(args[0], args.Length > 1 ? (int)args[1] : 0))); methodOperators.Add(new MethodOperator("ceiling", (args) => Math.Ceiling(args[0]))); methodOperators.Add(new MethodOperator("floor", (args) => Math.Floor(args[0]))); methodOperators.Add(new MethodOperator("truncate", (args) => Math.Truncate(args[0]))); methodOperators.Add(new MethodOperator("min", (args) => Math.Min(args[0], args[1]))); methodOperators.Add(new MethodOperator("max", (args) => Math.Max(args[0], args[1]))); methodOperators.Add(new MethodOperator("if", (args) => args[0] > 0 ? args[1] : args[2])); //Last To First unaryOperators.Add(new UnaryOperator("!", true, exponential)); unaryOperators.Add(new UnaryOperator("-", false, (x) => - x)); unaryOperators.Add(new UnaryOperator("++", true, increment)); unaryOperators.Add(new UnaryOperator("--", false, decrement)); binaryOperators.Add(new BinaryOperator("+=", addAssign)); binaryOperators.Add(new BinaryOperator("-=", subtractAssign)); binaryOperators.Add(new BinaryOperator("*=", multiplyAssign)); binaryOperators.Add(new BinaryOperator("/=", divideAssign)); binaryOperators.Add(new BinaryOperator("=", assign)); binaryOperators.Add(new BinaryOperator("&", (x, y) => x > 0 & y > 0 ? 1 : 0)); binaryOperators.Add(new BinaryOperator("&&", (x, y) => x > 0 && y > 0 ? 1 : 0)); binaryOperators.Add(new BinaryOperator("|", (x, y) => x > 0 | y > 0 ? 1 : 0)); binaryOperators.Add(new BinaryOperator("||", (x, y) => x > 0 || y > 0 ? 1 : 0)); binaryOperators.Add(new BinaryOperator("==", (x, y) => x == y ? 1 : 0)); binaryOperators.Add(new BinaryOperator("<", (x, y) => x < y ? 1 : 0)); binaryOperators.Add(new BinaryOperator("<=", (x, y) => x <= y ? 1 : 0)); binaryOperators.Add(new BinaryOperator(">", (x, y) => x > y ? 1 : 0)); binaryOperators.Add(new BinaryOperator(">=", (x, y) => x >= y ? 1 : 0)); binaryOperators.Add(new BinaryOperator("+", (x, y) => x + y)); binaryOperators.Add(new BinaryOperator("-", (x, y) => x - y)); binaryOperators.Add(new BinaryOperator("*", (x, y) => x * y)); binaryOperators.Add(new BinaryOperator("/", (x, y) => x / y)); binaryOperators.Add(new BinaryOperator("^", (x, y) => Math.Pow(x, y))); binaryOperators.Add(new BinaryOperator("%", (x, y) => x % y)); CalculateMaxOperationLength(); } }
internal static FunctionReturnValue ACosh(CallFrame frame, Variant[] args) => (Variant)Math.Acosh((double)args[0].ToNumber());
public static Real ArcCosh(this Real x) { return(new Real(Math.Acosh(x.data))); }
public double Call(ReadOnlySpan <double> args) { Arguments.Count(1, args.Length); return(Math.Acosh(args[0] * Consts.DegreeToRadians)); }
public static double acosh(double x) => Math.Acosh(x);