Java Math log1p () yöntemi, belirtilen değer ve 1 toplamının doğal logaritmasını (e tabanı) döndürür.
log1p()
Yöntemin sözdizimi şöyledir:
Math.log1p(double x)
İşte log1p()
statik bir yöntem. Bu nedenle, yöntemi doğrudan sınıf adını kullanarak çağırıyoruz Math
.
log1p () Parametreler
Log1p () yöntemi tek bir parametre alır.
- x - logaritması hesaplanacak değer
log1p () Dönen Değerler
- x + 1'in doğal logaritmasını döndürür
- x NaN veya -1'den küçükse NaN döndürür
- eğer pozitif sonsuz döner x pozitif sonsuzluk olduğunu
- Eğer döner sıfır x sıfırdır
Örnek1: Java Math.log1p ()
class Main ( public static void main(String() args) ( // log1p() for double value System.out.println(Math.log1p(9.0)); // 2.302585092994046 // log1p() for zero System.out.println(Math.log1p(0.0)); // 0.0 // log1p() for NaN // square root of negative number is NaN double nanValue = Math.sqrt(-5.0); System.out.println(Math.log1p(nanValue)); // NaN // log1p() for infinity double infinity = Double.POSITIVE_INFINITY; System.out.println(Math.log1p(infinity)); // Infinity // log1p() for negative numbers System.out.println(Math.log(-9.0)); // NaN ) )
Yukarıdaki örnekte, ifadeye dikkat edin,
Math.log1p(Math.pow(10, 3))
Burada Math.pow(10, 3)
10 3 döndürür . Daha fazla bilgi edinmek için Java Math.pow () adresini ziyaret edin.
Not : -5'in karekökünü hesaplamak için Math.sqrt () yöntemini kullandık. Negatif rakamın karekökü bir sayı değildir.
Örnek 2: Math.log1p () ve Math.log ()
class Main ( public static void main(String() args) ( double a = 9.0; // log1p() for double value System.out.println(Math.log1p(a)); // 2.302585092994046 // Compute log() for a + 1 a = a + 1; System.out.println(Math.log(a)); // 2.302585092994046 // Here you can see log1p(x) == log(x + 1) ) )
Önerilen Öğreticiler:
- Java Math.log ()
- Java Math.log10 ()