Average Error: 4.5 → 1.9
Time: 22.6s
Precision: 64
\[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
\[\begin{array}{l} \mathbf{if}\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) = -\infty:\\ \;\;\;\;y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) + x\\ \mathbf{elif}\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \le 2.405759074108095109916766476323447027402 \cdot 10^{304}:\\ \;\;\;\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot z\\ \end{array}\]
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\begin{array}{l}
\mathbf{if}\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) = -\infty:\\
\;\;\;\;y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) + x\\

\mathbf{elif}\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \le 2.405759074108095109916766476323447027402 \cdot 10^{304}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x - x \cdot z\\

\end{array}
double f(double x, double y, double z, double t) {
        double r15399024 = x;
        double r15399025 = y;
        double r15399026 = z;
        double r15399027 = r15399025 * r15399026;
        double r15399028 = t;
        double r15399029 = r15399028 / r15399025;
        double r15399030 = tanh(r15399029);
        double r15399031 = r15399024 / r15399025;
        double r15399032 = tanh(r15399031);
        double r15399033 = r15399030 - r15399032;
        double r15399034 = r15399027 * r15399033;
        double r15399035 = r15399024 + r15399034;
        return r15399035;
}

double f(double x, double y, double z, double t) {
        double r15399036 = x;
        double r15399037 = z;
        double r15399038 = y;
        double r15399039 = r15399037 * r15399038;
        double r15399040 = t;
        double r15399041 = r15399040 / r15399038;
        double r15399042 = tanh(r15399041);
        double r15399043 = r15399036 / r15399038;
        double r15399044 = tanh(r15399043);
        double r15399045 = r15399042 - r15399044;
        double r15399046 = r15399039 * r15399045;
        double r15399047 = r15399036 + r15399046;
        double r15399048 = -inf.0;
        bool r15399049 = r15399047 <= r15399048;
        double r15399050 = r15399037 * r15399045;
        double r15399051 = r15399038 * r15399050;
        double r15399052 = r15399051 + r15399036;
        double r15399053 = 2.405759074108095e+304;
        bool r15399054 = r15399047 <= r15399053;
        double r15399055 = r15399036 * r15399037;
        double r15399056 = r15399036 - r15399055;
        double r15399057 = r15399054 ? r15399047 : r15399056;
        double r15399058 = r15399049 ? r15399052 : r15399057;
        return r15399058;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.5
Target1.9
Herbie1.9
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\]

Derivation

  1. Split input into 3 regimes
  2. if (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))) < -inf.0

    1. Initial program 64.0

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
    2. Using strategy rm
    3. Applied associate-*l*1.1

      \[\leadsto x + \color{blue}{y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)}\]

    if -inf.0 < (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))) < 2.405759074108095e+304

    1. Initial program 0.6

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]

    if 2.405759074108095e+304 < (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y)))))

    1. Initial program 59.0

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
    2. Taylor expanded around 0 32.3

      \[\leadsto \color{blue}{x - x \cdot z}\]
  3. Recombined 3 regimes into one program.
  4. Final simplification1.9

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) = -\infty:\\ \;\;\;\;y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) + x\\ \mathbf{elif}\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \le 2.405759074108095109916766476323447027402 \cdot 10^{304}:\\ \;\;\;\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x - x \cdot z\\ \end{array}\]

Reproduce

herbie shell --seed 2019174 
(FPCore (x y z t)
  :name "SynthBasics:moogVCF from YampaSynth-0.2"

  :herbie-target
  (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))

  (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))