logo

Matematične funkcije v Pythonu | 2. sklop (logaritemske in potenčne funkcije)

Številske funkcije so obravnavane v nizu 1 spodaj Matematične funkcije v Pythonu | 1. niz (številske funkcije) V tem sklopu so obravnavane logaritemske in potenčne funkcije. 1. exp(a) :- Ta funkcija vrne vrednost e dvignjen na potenco a (e**a) . 2. dnevnik (a b) :- Ta funkcija vrne logaritem vrednost a z osnovo b . Če osnova ni omenjena, je izračunana vrednost naravnega logaritma. 

Python
# Python code to demonstrate the working of  # exp() and log()  # importing 'math' for mathematical operations  import math # returning the exp of 4  print ('The e**4 value is : ' end='') print (math.exp(4)) # returning the log of 23  print ('The value of log 2 with base 3 is : ' end='') print (math.log(23)) 

Izhod:



The e**4 value is : 54.598150033144236 The value of log 2 with base 3 is : 0.6309297535714574

Časovna zapletenost: O(1)

Pomožni prostor: O(1)

sklad v javi


3. log2(a) :- Ta funkcija izračuna vrednost log a z osnovo 2 . Ta vrednost je natančnejši kot vrednost zgoraj obravnavane funkcije. 4. log10(a) :- Ta funkcija izračuna vrednost log a z osnovo 10 . Ta vrednost je natančnejši kot vrednost zgoraj obravnavane funkcije. 



Python
# Python code to demonstrate the working of  # log2() and log10()  # importing 'math' for mathematical operations  import math # returning the log2 of 16  print ('The value of log2 of 16 is : ' end='') print (math.log2(16)) # returning the log10 of 10000  print ('The value of log10 of 10000 is : ' end='') print (math.log10(10000)) 

Izhod:

The value of log2 of 16 is : 4.0 The value of log10 of 10000 is : 4.0

Časovna zapletenost: O(1)

javascript onload skript

Pomožni prostor: O(1)




5. pow(a b) :- Ta funkcija se uporablja za izračun vrednosti a dvignjen na potenco b (a**b) . 6. sqrt() :- Ta funkcija vrne kvadratni koren števila. 

.naslednja java
Python
# Python code to demonstrate the working of  # pow() and sqrt()  # importing 'math' for mathematical operations  import math # returning the value of 3**2  print ('The value of 3 to the power 2 is : ' end='') print (math.pow(32)) # returning the square root of 25  print ('The value of square root of 25 : ' end='') print (math.sqrt(25)) 

Izhod:

The value of 3 to the power 2 is : 9.0 The value of square root of 25 : 5.0

Časovna zapletenost: O(1)

Pomožni prostor: O(1)