📜  如何在 R 中找到值的反对数?

📅  最后修改于: 2022-05-13 01:54:25.819000             🧑  作者: Mango

如何在 R 中找到值的反对数?

反对数或反对数是求对数或对数的逆过程。如果 q 是 logb p 的值,则 p 是 q 对底 b 的反对数,即q = log b p 然后 p =反对数b q

例子,

  • 反对数2 3 = 8,因为 2 3产生 8
  • 反对数4 2 = 16,因为 4 2产生 16
  • 反对数10 4 = 10000,因为 10 4产生 10000

对数:

一个数的反对数或反对数,以数为底,底数可以计算为,

句法:

返回类型:

一个正整数:数字与底数的反对数

示例 1:

在这个例子中,我们将看到如何计算以下正数的反对数,

  • 对数2 (3)
  • 反对数4 (2)
  • 对数10 (4)
  • 反对数e (4.60517018598809)

由于反对数2 (3) 等于 2 3 = 8,反对数4 (2) 等于 4 2 = 16,反对数10 (4) 等于 10 4 = 10000 我们可以借助求幂运算符计算这些值(^) 在 R 中。我们还可以通过将单个参数传递给 exp() 内置函数来计算以 e 为底数的反对数。

R
# R program to illustrate how we can
# compute antilog
 
# An integer whose antilog to be computed
number = 3
 
# Initializing base
base = 2
 
# Computing antilog value
answer = base ^ number
 
# Print the value of antilog
print(paste("The value of antilog2(3) is equal to", answer))
 
# Initializing base
base = 4
 
# An integer whose antilog to be computed
number = 2
 
# Computing antilog value
answer = base ^ number
 
# Print the value of antilog
print(paste("The value of antilog4(2) is equal to", answer))
 
 
# An integer whose antilog to be computed
number = 4
 
# Initializing base
base = 10
 
# Computing antilog value
answer = base ^ number
 
# Print the value of antilog
print(paste("The value of antilog2(3) is equal to", answer))
 
# An integer whose antilog to be computed
number = 4.60517018598809
 
# Print the value of antilog
print(paste("The value of antiloge(4.60517018598809) is equal to", exp(number)))


R
# R program to illustrate how we can compute antilog
 
# An integer whose antilog to be computed
number = -3
 
# Initializing base
base = 2
 
# Computing antilog value
answer = base ^ number
 
# Print the value of antilog
print(paste("The value of antilog2(-3) is equal to", answer))
 
# Initializing base
base = 4
 
# An integer whose antilog to be computed
number = -2
 
# Computing antilog value
answer = base ^ number
 
# Print the value of antilog
print(paste("The value of antilog4(-2) is equal to", answer))
 
 
# An integer whose antilog to be computed
number = -4
 
# Initializing base
base = 10
 
# Computing antilog value
answer = base ^ number
 
# Print the value of antilog
print(paste("The value of antilog10(-4) is equal to", answer))
 
# An integer whose antilog to be computed
number = -4.60517018598809
 
# Print the value of antilog
print(paste("The value of antiloge(-4.60517018598809) is equal to", exp(number)))


输出:

示例 2:

在这个例子中,我们将看到如何计算以下负数的反对数,

  • 反对数2 (-3)
  • 反对数4 (-2)
  • 反对数10 (-4)
  • 反对数e (-4.60517018598809)

由于反对数2 (-3) 等于 2 -3 = 1 / 8 ,反对数4 (-2) 等于 4 -2 = 1 / 16 并且反对数10 (-4) 等于 10 -4 = 1 / 10000 我们可以借助 R 中的幂运算符(^) 来计算这些值。我们还可以通过将单个参数传递给 exp() 内置函数来计算以 e 为底数的反对数。

R

# R program to illustrate how we can compute antilog
 
# An integer whose antilog to be computed
number = -3
 
# Initializing base
base = 2
 
# Computing antilog value
answer = base ^ number
 
# Print the value of antilog
print(paste("The value of antilog2(-3) is equal to", answer))
 
# Initializing base
base = 4
 
# An integer whose antilog to be computed
number = -2
 
# Computing antilog value
answer = base ^ number
 
# Print the value of antilog
print(paste("The value of antilog4(-2) is equal to", answer))
 
 
# An integer whose antilog to be computed
number = -4
 
# Initializing base
base = 10
 
# Computing antilog value
answer = base ^ number
 
# Print the value of antilog
print(paste("The value of antilog10(-4) is equal to", answer))
 
# An integer whose antilog to be computed
number = -4.60517018598809
 
# Print the value of antilog
print(paste("The value of antiloge(-4.60517018598809) is equal to", exp(number)))

输出: