C++ logarithmic function log() operation

First of all, we must know the exp() function

exp(n) value is e^n power;

In addition, the log function includes two functions, a log() function with e as low

The other is the log 10() function with base 10 as the base;

For specific usage, see this small program below

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	double a=9,b=10;
	cout<<log(a)<<endl;
	cout<<log(exp(a))<<endl;
	cout<<log10(b)<<endl;
	return 0;
}

In addition, if you customize to base m, find the value of log n

Need double a=log(n)/log(m);

Examples are as follows:

#include<iostream>
#include<cmath>
using namespace std;
int main()
{
	double a=2,b=2;//Logarithmic function with base 2 
	for(b=2;b<=16;b=b+2)
	{
	        When cout<<"b="<<b<<", the base 2 logarithmic function="<<log(b)/log(a)<<endl;
	}
	return 0;
}

Intelligent Recommendation

Logarithmic function summary

Logarithmic function summary The logarithmic function is a very important type of function in the calculation of complexity. I made a basic summary of its basic properties. When comparing the order of...

Polynomial logarithmic function

A known f ( x ) f(x) f(x),begging g ( x ) = ln ⁡ f ( x ) ( m o d x n ) g(x) = \ln f(x) \pmod {x^n} g(x)=lnf(x)(modxn) Ensure that the constant term is 1 1 1 g ( x ) ′ = f ( x ) ′ f ( x ) g...

Logarithmic function image enhancement

Logarithmic function image enhancement In the previous article, the linear enhancement of the image we talked about is a linear enhancement for the case where the overall pixel value of the black and ...

python plot logarithmic function

python plot logarithmic function a>1 Complete code Effect picture a>1 Complete code Effect picture Logarithmic function vs exponential function Complete code Effect picture references In the las...

More Recommendation

# Log logarithmic mapping optimization Hash

Hash log logarithmic mapping optimization Using a mathematical technique: $ \ forall k \ in [0,35], 2 ^ {k} mod 37 equal to each other, an integer of 1-36 and just take over $ Applications: within the...

Logarithmic mathematics knowledge recall (log)

Purely personal interest, so I want to review the mathematics knowledge, the following is the knowledge point of log In mathematics, logarithm is the inverse of exponentiation, just as division is the...

Image enhancement-logarithmic Log transformation

The logarithmic transformation of the image:  Since the logarithmic curve has a large slope in areas with lower pixel values ​​and a smaller slope in areas with higher pixel values, the contrast ...

Polynomial logarithmic function study notes

I have been learning some polynomial boards recently... Pre-skills:Polynomial inversion The problem is for f ( x ) = ln ⁡ g ( x ) f(x)=\ln g(x) f(x)=lng(x),A known g ( x ) g(x) g(x),begging f ( x ) f(...

Copyright  DMCA © 2018-2026 - All Rights Reserved - www.programmersought.com  User Notice

Top