🛠️ToolsShed

Hyperbolic Functions Calculator

Calculate sinh, cosh, tanh, and inverse hyperbolic functions with identity verification.

Häufig gestellte Fragen

Code-Implementierung

import math

def calculate_hyperbolic(x: float) -> dict:
    """Calculate all hyperbolic functions and their inverses."""
    results = {
        "sinh": math.sinh(x),
        "cosh": math.cosh(x),
        "tanh": math.tanh(x),
        "csch": 1 / math.sinh(x) if x != 0 else float('inf'),
        "sech": 1 / math.cosh(x),
        "coth": 1 / math.tanh(x) if x != 0 else float('inf'),
    }

    # Inverse hyperbolic (valid ranges)
    if abs(x) >= 1:
        results["asinh"] = math.asinh(x)
        results["acosh"] = math.acosh(x) if x >= 1 else None
    else:
        results["asinh"] = math.asinh(x)
        results["acosh"] = None  # Domain: x >= 1

    results["atanh"] = math.atanh(x) if abs(x) < 1 else None

    return {k: round(v, 8) if isinstance(v, float) else v
            for k, v in results.items()}

# Identity verifications
x = 1.5
r = calculate_hyperbolic(x)
print(f"x = {x}")
for name, value in r.items():
    print(f"  {name}({x}) = {value}")

# Verify identity: cosh²(x) - sinh²(x) = 1
print(f"\ncosh²(x) - sinh²(x) = {round(r['cosh']**2 - r['sinh']**2, 10)}")

Comments & Feedback

Comments are powered by Giscus. Sign in with GitHub to leave a comment.