Get the App
SLTechnology News&Howtos  ›  Development  › 

How to realize logarithmic Operation in python

Shulou Source: shulou.com Published: 2022-06-01 13:03:44 10月04日 Update

This article mainly introduces the python how to achieve logarithmic operation related knowledge, the content is detailed and easy to understand, the operation is simple and fast, has a certain reference value, I believe that everyone after reading this python how to achieve logarithmic operation article will have a harvest, let's take a look at it.

1. Only take the logarithm of a single number import mathmath.log (2) # default to e as base math.log (4) # base 2, logarithm of 4

That is, math.log (c) # calculates the logarithm of c with b as the base.

2. Find the logarithm as a whole

A numpy package is required to logarithm a sequence of numbers

Import numpynumpy.log ([2pr 4p8]) # takes logarithm numpy.log2 ([2pr 4p8]) # with e as the base, and takes logarithm for 2p4p8 with 2 as the base.

That is, numpy.loga (b) # takes the logarithm of the number in the logarithm sequence b with an as the base.

Or adopt a circular body:

Import mtahl = [] for i in [2jin4pr 8]: l.append (math.log (iPower2)) # find the base 2 logarithm of every number in list

Add: python how to find the exponent and logarithm of the array

Index:

Math.exp () can only calculate the index of one number, but not the array in batches.

Numpy.exp () can calculate the index not only for a number, but also for an array in batches.

Logarithm:

Math.log ()

Numpy.log ()

The function is the same as above

This is the end of the article on "how to implement logarithmic operations in python". Thank you for reading! I believe you all have a certain understanding of the knowledge of "how to achieve logarithmic operation in python". If you want to learn more, you are welcome to follow the industry information channel.

Tags: Logarithm index operation number sequence array knowledge content number article value function loop easy to operate whole article easy to understand more look industry Apple Docker Huawei Linux macOS MariaDB Microsoft MySQL NVidia OPPO Reno Apple Linux Shulou Information NVidia macOS