Library contents

C++ std::sinh

In C++, std::sinh returns the hyperbolic sine of x, equal to (eˣ − e⁻ˣ) / 2. At zero the result is 0.

A simple example

std::sinh

  1. Start with 0
  2. Do this Evaluate at the origin
  3. Result 0
At zero the positive and negative exponential terms are equal. Their difference is zero.
lesson.cpp
#include <iostream>
#include <cmath>

int main() {
    std::cout << (std::sinh(0.0)) << '\n';
}
Output
0

Syntax

C++ syntax
std::sinh(offset)
Run these examples in C++

Save one example at a time as lesson.cpp. Use C++17 and a Unix-style shell.

c++ -std=c++17 -Wall -Wextra lesson.cpp -o lesson
./lesson

Estimate the slope of a hanging cable

An engineering class models a freely hanging cable. Evaluate the curve at the sample position so the team can relate the plotted shape or slope to that point on the cable.

From the programconst double offset = 0.5
Result0.521
lesson.cpp
#include <cmath>
#include <cstdio>

int main() {
    const double offset = 0.5;

    std::printf("%.3f\n", std::sinh(offset));
    return 0;
}
Output
0.521

Half a scale length from the centre, the slope is approximately 0.521.

Advertisements

Trace the left half of a cable model

A design student plots the normalized hanging curve y = cosh(x). She needs its slope one scale length to the left of the centre.

Given-1
Worked result-1.175

Using -1 gives -1.175 for this measurement.

Check the model at its centre

The middle of a symmetrical model cable is its lowest point. Its drawing routine evaluates the slope at position zero.

Given0
Worked result0.000

Using 0 gives 0.000 for this measurement.

What to watch for

Measure horizontal displacement in units of the cable model’s scale length.

Documentation for std::sinh