Write a NumPy program to compute natural, base 10, and base 2 logarithms for all elements in a given array.
import numpy as np x = np.array([1, np.e, np.e**2]) print("Original array: ") print(x) print("\nNatural log =", np.log(x)) print("Common log =", np.log10(x)) print("Base 2 log =", np.log2(x))
Sample Output:
Original array: [1. 2.71828183 7.3890561 ] Natural log = [0. 1. 2.] Common log = [0. 0.43429448 0.86858896] Base 2 log = [0. 1.44269504 2.88539008]
total answers (1)
start bookmarking useful questions and collections and save it into your own study-lists, login now to start creating your own collections.
Sample Output:
need an explanation for this answer? contact us directly to get an explanation for this answer