Skip to content

Expression for tanh in tanh.c is incorrect #31

@MBHelectronics

Description

@MBHelectronics
double tanh(double x)
{
  double x0 = exp(x);
  double x1 = 1.0 / x0;

  return ((x0 + x1) / (x0 - x1));
}

Should be: return ((x0 - x1) / (x0 + x1)); see e.g.
https://en.wikipedia.org/wiki/Hyperbolic_function#Definitions

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions