The C++ Standard Library provides a set of functions in the <cmath> header that operate on double values. Here are some commonly used functions:

Example Usage

Here’s a simple example illustrating some of these functions:

#include <iostream>
#include <cmath>

int main() {
    double a = -3.7;
    double b = 4.2;

    std::cout << "Absolute value of a: " << std::abs(a) << std::endl;
    std::cout << "Square root of b: " << std::sqrt(b) << std::endl;
    std::cout << "a raised to the power of b: " << std::pow(a, b) << std::endl;
    std::cout << "Natural log of b: " << std::log(b) << std::endl;
    std::cout << "Sine of 45 degrees: " << std::sin(45.0 * M_PI / 180.0) << std::endl;

    return 0;
}

This code snippet demonstrates the use of std::abs, std::sqrt, std::pow, std::log, and std::sin functions with double values.