ืืืชืช ืืชืืืืงื ืืืืื ืฉืืืืช ืืขืืืื ืขื ืคืื ืงืฆืืืช ืืชืืืืืช. ืืืืืจ ืื, ืื ื ืืืืืื ืืืืจ ืขื ืฉืืืช Math.exp() ื-Java. ืืื ืืืืืจ ืืช ืืืกืคืจ e ืฉืืืขืื ืืืืงืช ืขืจื ืืคืื.
ืืื ืคืื ืงืฆืื ืืงืกืคืื ื ืฆืืืืืช: ืืืื ืืชืืื ืงืฆืจ ืืืื
ืืขืจื: ืกืขืืฃ ืื ืืกืืืจ ืืช ืืืชืืืืงื ืืืืืจื ืฉืืืช Math.exp() . ืื ืืชื ืืืจ ืืืืขืื ืืืช, ืื ืกืชื ืจืืฆืื ืืืฉืชืืฉ ืืฉืืื ืืืื ืืืืื ืืช ืืืืืช, ืืชื ืืืืื ืื ืืขืืืจ ืื ืงืืื ืืืื. ืืืขืจืื ืืื ืืคืื ืงืฆืื y = e x , ืืืฉืจ e ืืื ืืกืคืจ ืืชืืื ืืกืืื ืฉืืื ืืขืจื 2.718281828459045. ืืกืคืจ ืื ืืฉืื ืื ืคืืืช ืืืกืคืจ ื-pi ืืืคืืจืกื, ืื ืืื ืืืืจ ืืขืืงืจ ืขื ืืื ืืชืืืืงืืื, ืืชืื ืชืื ืืื ืฉืื ืืขืืืืื ืขื ืกืืืืกืืืงื. ืืื, ืืฉ ืืื ืฉื: ืืกืคืจ ืืืืืจ. ืื e ืืื ืืืกืืก ืฉื ืืืืืจืืชื ืืืืขื. ืืืื ืืจืฃ ืืคืื ืงืฆืืืช ืืืงืกืคืื ื ืฆืืืืืืช: ืืชืืืืืื ืืืฆืืืชืื ืืืืง ืืืงืกืคืื ื ืฆืืืื ืืฉ ืืืคืืื ืืฉืืชืฃ ืืื: ืืืฉื ืืืชื ืืจืืื ืืื, ืืคืจืืืจืื ืฉืืื ืืฉืชื ืื ืืืชื ืืกืคืจ ืคืขืืื. ืืืฉื, ืงืืจืืจ ืฉื ื ืืื: ืืื ืฉืืคืจืฉ ืืืืคืจืืืจื ืืื ืืืืืจ ืื ืืื ืืืื ืืืชืจ, ืื ืืื ืืชืงืจืจ ืืืจ ืืืชืจ. ืืื ืฉืืืืจ ืืฉืื ืืืชืืืื ืืืืจื ืืืจ ืืืคื ืืืื ืืืชืจ, ืื ืืื ืืชืืืื ืืืจ ืืืชืจ.ืฉืืืช Math.exp() ื-Java
ืขืืฉืื ืืืื ื ืืืืจ ืื'ืืืื. ืฉืืืช double exp(double x) ืฉื ืืืืืงื Math ืืืฉืืช ืืช ืืขืจื ืฉื ืคืื ืงืฆืืืช ืืืขืจืื ืื ืงืืื x , ืืืืืื ืืืจืืช, ืืื ืืืืืจื ืืช ืืืกืคืจ e ืืืืงืช x . ืืืชืจ ืืืืง, ืืื ืืืืืจ ืขืจื ืืฉืืขืจ ืืืืืง ืืกืืื. ืืืืืจื ืืช ืืืกืคืจ e ืฉื ืืืืืจ ืืืจื ืืืืงืช ืขืจื ืืคืื. ืืืืืจ, Math.exp(2.0) = e 2.0 (ืื ืืขืจื 7.34) ืื ื ืืฆืืจื ืขื ืืฉืืื:double exp(double x)
ืืืฉืจ x ืืื ืืชืืืจ ืืืขืืืช ืืช ืืืกืคืจ e . ืืืื ื ืืชื ืืืืื.
public class ExpExample {
public static void main(String[] args) {
int x1 = 2;
double x2 = 0.5;
double x3 = 1;
System.out.println("exponential function in " + x1 + " = " + Math.exp(x1));
System.out.println("exponential function in " + x2 + " = " + Math.exp(x2));
System.out.println("exponential function in " + x3 + " = " + Math.exp(x3));
}
}
ืืคืื ืืื:
ืคืื ืงืฆืื ืืงืกืคืื ื ืฆืืืืืช ื-2 = 7.38905609893065 ืคืื ืงืฆืื ืืขืจืืืืช ื-0.5 = 1.6487212707001282 ืคืื ืงืฆืื ืืขืจืืืืช ื-1.0 = 2.718281828459045
ืืื ืืงืจืื ืืืืืืื
ืืืชืืืืงื ืืฉ ืืืฉืืื ืฉื ืฆืืจื ืืืชื ืืืืืจืช, ืืื ืื ืืื ืกืืฃ ืืืืื ืืฉืืืื. ืืกืคืจ ืืืืื ืืืงื 0.0 ื ืืชื ืืื ืกืืฃ ืืืืื, ืืืกืคืจ ืฉืืืื ื ืืชื ืืื ืกืืฃ ืฉืืืื. ืืชื ืืืื ืืงืื ืฆืืจื ืืืชื ืืืืืจืช ืืืจืืื ืฉืื ืืช. ืืืืืื, ืื ืชื ืกื ืืืืง ืืคืก ืืืคืก ืื ืืื ืกืืฃ ืืืื ืกืืฃ. ื-Java ืืฉื ื ืงืืืขืื ืืืืืืื ืืืืชื Double ืืืื Double.NaN (ืฆืืจื ืืขื ืืืชื ืืืืืจืช), Double.POSITIVE_INFINITY ื- Double.NEGATIVE_INFINITY . ืฉืืืช Math.exp() ืืชื ืืืช ืืฆืืจื ืกืคืฆืืคืืช ืืืฉืจ ืืื ืืชืืืืืช ืขื ืฉืืืฉืช ืืืืฉืืื ืืืืื:- ืื ืืืจืืืื ื ืืื NaN, ืืชืืฆืื ืืื ืื NaN.
- ืื ืืืืขืื ืืื ืืื ืกืืฃ ืืืืื, ืื ืืชืืฆืื ืืื ืื ืืื ืกืืฃ ืืืืื.
- ืื ืืืจืืืื ื ืืื ืืื ืกืืฃ ืฉืืืื, ืื ืืชืืฆืื ืืื ืืคืก ืืืืื.
public class ExpSpecialCases {
public static void main(String[] args) {
double positiveInfinity = Double.POSITIVE_INFINITY;
double negativeInfinity = Double.NEGATIVE_INFINITY;
double nan = Double.NaN;
//The argument is positive infinity, the output is positive infinity
System.out.println(Math.exp(positiveInfinity));
//The argument is negative infinity, the output is zero
System.out.println(Math.exp(negativeInfinity));
//The argument is NaN, the output is NaN
System.out.println(Math.exp(nan));
}
}
ืืคืื ืืื:
ืืื ืกืืฃ 0.0 NaN
ืงืจืืื ื ืืกืคืช: |
---|
GO TO FULL VERSION