Exp Method

public static double Exp(double d)

Summary

Returns E raised to the specified power, where E is Euler's number (approximately 2.71828).

Parameters

  • d: The exponent to raise E to.

Returns

double: The number E raised to the power of d. If d is equal to NaN or positive infinity, positive infinity is returned. If d is equal to negative infinity, 0 is returned.

Remarks

The exponential function is the inverse of the natural logarithm function. That is, Exp(Log(x)) = x, and Log(Exp(x)) = x.

The value of E is approximately 2.7182818284590452354. This value is the base of the natural logarithm.

The Exp method is commonly used in scientific and financial calculations, particularly when dealing with growth rates or decay processes.

Examples

The following example demonstrates the use of the Exp method:

using System;

public class Example
{
    public static void Main()
    {
        double exponent1 = 1.0;
        double result1 = Math.Exp(exponent1);
        Console.WriteLine($"E raised to the power of {exponent1} is: {result1}"); // Output: E raised to the power of 1 is: 2.718281828459045

        double exponent2 = 2.5;
        double result2 = Math.Exp(exponent2);
        Console.WriteLine($"E raised to the power of {exponent2} is: {result2}"); // Output: E raised to the power of 2.5 is: 12.182493960703474

        double exponent3 = -1.0;
        double result3 = Math.Exp(exponent3);
        Console.WriteLine($"E raised to the power of {exponent3} is: {result3}"); // Output: E raised to the power of -1 is: 0.36787944117144233

        double nanValue = double.NaN;
        double result4 = Math.Exp(nanValue);
        Console.WriteLine($"E raised to the power of NaN is: {result4}"); // Output: E raised to the power of NaN is: NaN

        double infinityValue = double.PositiveInfinity;
        double result5 = Math.Exp(infinityValue);
        Console.WriteLine($"E raised to the power of Positive Infinity is: {result5}"); // Output: E raised to the power of Positive Infinity is: Infinity

        double negInfinityValue = double.NegativeInfinity;
        double result6 = Math.Exp(negInfinityValue);
        Console.WriteLine($"E raised to the power of Negative Infinity is: {result6}"); // Output: E raised to the power of Negative Infinity is: 0
    }
}
                        

Requirements

Namespace: System

Assembly: mscorlib.dll (in .NET Framework)

Assembly: System.Runtime.dll (in .NET Core and .NET 5+)