Export (0) Print
Expand All

Math.Exp Method

Returns e raised to the specified power.

Namespace: System
Assembly: mscorlib (in mscorlib.dll)

public static double Exp (
	double d
)
public static double Exp (
	double d
)
public static function Exp (
	d : double
) : double
Not applicable.

Parameters

d

A number specifying a power.

Return Value

The number e raised to the power d. If d equals NaN or PositiveInfinity, that value is returned. If d equals NegativeInfinity, 0 is returned.

Use the Pow method to calculate powers of other bases.

Exp is the inverse of Log.

The following example uses Exp to evaluate certain exponential and logarithmic identities for selected values.

// Example for the Math.Exp( double ) method.
using System;

class ExpDemo 
{
    public static void Main() 
    {
        Console.WriteLine( 
            "This example of Math.Exp( double ) " +
            "generates the following output.\n" );
        Console.WriteLine( 
            "Evaluate [e ^ ln(X) == ln(e ^ X) == X] " +
            "with selected values for X:" );

        UseLnExp(0.1);
        UseLnExp(1.2);
        UseLnExp(4.9);
        UseLnExp(9.9);

        Console.WriteLine( 
            "\nEvaluate these identities with " +
            "selected values for X and Y:" );
        Console.WriteLine( "   (e ^ X) * (e ^ Y) == e ^ (X + Y)" );
        Console.WriteLine( "   (e ^ X) ^ Y == e ^ (X * Y)" );
        Console.WriteLine( "   X ^ Y == e ^ (Y * ln(X))" );

        UseTwoArgs(0.1, 1.2);
        UseTwoArgs(1.2, 4.9);
        UseTwoArgs(4.9, 9.9);
    }

    // Evaluate logarithmic/exponential identity with a given argument.
    static void UseLnExp(double arg)
    {
        // Evaluate e ^ ln(X) == ln(e ^ X) == X.
        Console.WriteLine( 
            "\n      Math.Exp(Math.Log({0})) == {1:E16}\n" +
            "      Math.Log(Math.Exp({0})) == {2:E16}",
            arg, Math.Exp(Math.Log(arg)), Math.Log(Math.Exp(arg)) );
    }

    // Evaluate exponential identities that are functions of two arguments.
    static void UseTwoArgs(double argX, double argY)
    {
        // Evaluate (e ^ X) * (e ^ Y) == e ^ (X + Y).
        Console.WriteLine( 
            "\nMath.Exp({0}) * Math.Exp({1}) == {2:E16}" + 
            "\n          Math.Exp({0} + {1}) == {3:E16}", 
            argX, argY, Math.Exp(argX) * Math.Exp(argY),
            Math.Exp(argX + argY) );

        // Evaluate (e ^ X) ^ Y == e ^ (X * Y).
        Console.WriteLine( 
            " Math.Pow(Math.Exp({0}), {1}) == {2:E16}" +
            "\n          Math.Exp({0} * {1}) == {3:E16}",
            argX, argY, Math.Pow(Math.Exp(argX), argY),
            Math.Exp(argX * argY) );

        // Evaluate X ^ Y == e ^ (Y * ln(X)).
        Console.WriteLine( 
            "           Math.Pow({0}, {1}) == {2:E16}" + 
            "\nMath.Exp({1} * Math.Log({0})) == {3:E16}", 
            argX, argY, Math.Pow(argX, argY), 
            Math.Exp(argY * Math.Log(argX)) );
    }
}

/*
This example of Math.Exp( double ) generates the following output.

Evaluate [e ^ ln(X) == ln(e ^ X) == X] with selected values for X:

      Math.Exp(Math.Log(0.1)) == 1.0000000000000001E-001
      Math.Log(Math.Exp(0.1)) == 1.0000000000000008E-001

      Math.Exp(Math.Log(1.2)) == 1.2000000000000000E+000
      Math.Log(Math.Exp(1.2)) == 1.2000000000000000E+000

      Math.Exp(Math.Log(4.9)) == 4.9000000000000012E+000
      Math.Log(Math.Exp(4.9)) == 4.9000000000000004E+000

      Math.Exp(Math.Log(9.9)) == 9.9000000000000004E+000
      Math.Log(Math.Exp(9.9)) == 9.9000000000000004E+000

Evaluate these identities with selected values for X and Y:
   (e ^ X) * (e ^ Y) == e ^ (X + Y)
   (e ^ X) ^ Y == e ^ (X * Y)
   X ^ Y == e ^ (Y * ln(X))

Math.Exp(0.1) * Math.Exp(1.2) == 3.6692966676192444E+000
          Math.Exp(0.1 + 1.2) == 3.6692966676192444E+000
 Math.Pow(Math.Exp(0.1), 1.2) == 1.1274968515793757E+000
          Math.Exp(0.1 * 1.2) == 1.1274968515793757E+000
           Math.Pow(0.1, 1.2) == 6.3095734448019331E-002
Math.Exp(1.2 * Math.Log(0.1)) == 6.3095734448019344E-002

Math.Exp(1.2) * Math.Exp(4.9) == 4.4585777008251705E+002
          Math.Exp(1.2 + 4.9) == 4.4585777008251716E+002
 Math.Pow(Math.Exp(1.2), 4.9) == 3.5780924170885260E+002
          Math.Exp(1.2 * 4.9) == 3.5780924170885277E+002
           Math.Pow(1.2, 4.9) == 2.4433636334442981E+000
Math.Exp(4.9 * Math.Log(1.2)) == 2.4433636334442981E+000

Math.Exp(4.9) * Math.Exp(9.9) == 2.6764450551890982E+006
          Math.Exp(4.9 + 9.9) == 2.6764450551891015E+006
 Math.Pow(Math.Exp(4.9), 9.9) == 1.1684908531676833E+021
          Math.Exp(4.9 * 9.9) == 1.1684908531676829E+021
           Math.Pow(4.9, 9.9) == 6.8067718210957060E+006
Math.Exp(9.9 * Math.Log(4.9)) == 6.8067718210956985E+006
*/

// Example for the Math.Exp( double ) method.
import System.*;

class ExpDemo
{
     public static void main(String[] args)
    {
        Console.WriteLine(("This example of Math.Exp( double ) " 
            + "generates the following output.\n"));
        Console.WriteLine(("Evaluate [e ^ ln(X) == ln(e ^ X) == X] " 
            + "with selected values for X:"));
        UseLnExp(0.1);
        UseLnExp(1.2);
        UseLnExp(4.9);
        UseLnExp(9.9);
        Console.WriteLine(("\nEvaluate these identities with " 
            + "selected values for X and Y:"));
        Console.WriteLine("   (e ^ X) * (e ^ Y) == e ^ (X + Y)");
        Console.WriteLine("   (e ^ X) ^ Y == e ^ (X * Y)");
        Console.WriteLine("   X ^ Y == e ^ (Y * ln(X))");
        UseTwoArgs(0.1, 1.2);
        UseTwoArgs(1.2, 4.9);
        UseTwoArgs(4.9, 9.9);
    } //main
   
    // Evaluate logarithmic/exponential identity with a given argument.
    static void UseLnExp(double arg) 
    {
        // Evaluate e ^ ln(X) == ln(e ^ X) == X.
        Console.WriteLine("\n     Math.Exp(Math.Log({0})) == {1}\n"
            + "     Math.Log(Math.Exp({0})) == {2}", 
            System.Convert.ToString(arg),
            ((System.Double)System.Math.Exp(
            System.Math.Log(arg))).ToString("E16"),
            ((System.Double)System.Math.Log(
            System.Math.Exp(arg))).ToString("E16"));
    } //UseLnExp
   
    // Evaluate exponential identities that are functions of two arguments.
    static void UseTwoArgs(double argX, double argY) 
    {
        // Evaluate (e ^ X) * (e ^ Y) == e ^ (X + Y).
        Console.WriteLine("\nMath.Exp({0}) * Math.Exp({1}) == {2}" 
            + "\n          Math.Exp({0} + {1}) == {3}",
            new Object[] {System.Convert.ToString(argX),
            System.Convert.ToString(argY),((System.Double )
            (System.Math.Exp(argX) * System.Math.Exp(argY))).ToString("E16"),
            ((System.Double )System.Math.Exp((argX + argY))).ToString("E16")});

        // Evaluate (e ^ X) ^ Y == e ^ (X * Y).
        Console.WriteLine(" Math.Pow(Math.Exp({0}), {1}) == {2}" 
            + "\n          Math.Exp({0} * {1}) == {3}",
            new Object[] { System.Convert.ToString(argX),
            System.Convert.ToString(argY),((System.Double)System.Math.Pow
            (System.Math.Exp(argX),argY)).ToString("E16"),
            ((System.Double)System.Math.Exp((argX * argY))).ToString("E16")});

        // Evaluate X ^ Y == e ^ (Y * ln(X)).
        Console.WriteLine("           Math.Pow({0}, {1}) == {2}" 
            + "\nMath.Exp({1} * Math.Log({0})) == {3}", 
            new Object[] { System.Convert.ToString(argX), 
            System.Convert.ToString(argY), 
            ((System.Double)System.Math.Pow(argX, argY)).ToString("E16"),
            ((System.Double)System.Math.Exp(
            (argY * System.Math.Log(argX)))).ToString("E16") });
    } //UseTwoArgs
} //ExpDemo

/*
This example of Math.Exp( double ) generates the following output.

Evaluate [e ^ ln(X) == ln(e ^ X) == X] with selected values for X:

      Math.Exp(Math.Log(0.1)) == 1.0000000000000001E-001
      Math.Log(Math.Exp(0.1)) == 1.0000000000000008E-001

      Math.Exp(Math.Log(1.2)) == 1.2000000000000000E+000
      Math.Log(Math.Exp(1.2)) == 1.2000000000000000E+000

      Math.Exp(Math.Log(4.9)) == 4.9000000000000012E+000
      Math.Log(Math.Exp(4.9)) == 4.9000000000000004E+000

      Math.Exp(Math.Log(9.9)) == 9.9000000000000004E+000
      Math.Log(Math.Exp(9.9)) == 9.9000000000000004E+000

Evaluate these identities with selected values for X and Y:
   (e ^ X) * (e ^ Y) == e ^ (X + Y)
   (e ^ X) ^ Y == e ^ (X * Y)
   X ^ Y == e ^ (Y * ln(X))

Math.Exp(0.1) * Math.Exp(1.2) == 3.6692966676192444E+000
          Math.Exp(0.1 + 1.2) == 3.6692966676192444E+000
 Math.Pow(Math.Exp(0.1), 1.2) == 1.1274968515793757E+000
          Math.Exp(0.1 * 1.2) == 1.1274968515793757E+000
           Math.Pow(0.1, 1.2) == 6.3095734448019331E-002
Math.Exp(1.2 * Math.Log(0.1)) == 6.3095734448019344E-002

Math.Exp(1.2) * Math.Exp(4.9) == 4.4585777008251705E+002
          Math.Exp(1.2 + 4.9) == 4.4585777008251716E+002
 Math.Pow(Math.Exp(1.2), 4.9) == 3.5780924170885260E+002
          Math.Exp(1.2 * 4.9) == 3.5780924170885277E+002
           Math.Pow(1.2, 4.9) == 2.4433636334442981E+000
Math.Exp(4.9 * Math.Log(1.2)) == 2.4433636334442981E+000

Math.Exp(4.9) * Math.Exp(9.9) == 2.6764450551890982E+006
          Math.Exp(4.9 + 9.9) == 2.6764450551891015E+006
 Math.Pow(Math.Exp(4.9), 9.9) == 1.1684908531676833E+021
          Math.Exp(4.9 * 9.9) == 1.1684908531676829E+021
           Math.Pow(4.9, 9.9) == 6.8067718210957060E+006
Math.Exp(9.9 * Math.Log(4.9)) == 6.8067718210956985E+006
*/

Windows 98, Windows Server 2000 SP4, Windows CE, Windows Millennium Edition, Windows Mobile for Pocket PC, Windows Mobile for Smartphone, Windows Server 2003, Windows XP Media Center Edition, Windows XP Professional x64 Edition, Windows XP SP2, Windows XP Starter Edition

The Microsoft .NET Framework 3.0 is supported on Windows Vista, Microsoft Windows XP SP2, and Windows Server 2003 SP1.

.NET Framework

Supported in: 3.0, 2.0, 1.1, 1.0

.NET Compact Framework

Supported in: 2.0, 1.0

XNA Framework

Supported in: 1.0

Community Additions

ADD
Show:
© 2014 Microsoft