Average Error: 4.1 → 1.4
Time: 1.3m
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 8.124775333408145 \cdot 10^{-45}:\\ \;\;\;\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) + x\\ \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 8.124775333408145 \cdot 10^{-45}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\

\mathbf{else}:\\
\;\;\;\;y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) + x\\

\end{array}
double f(double x, double y, double z, double t) {
        double r20146946 = x;
        double r20146947 = y;
        double r20146948 = z;
        double r20146949 = r20146947 * r20146948;
        double r20146950 = t;
        double r20146951 = r20146950 / r20146947;
        double r20146952 = tanh(r20146951);
        double r20146953 = r20146946 / r20146947;
        double r20146954 = tanh(r20146953);
        double r20146955 = r20146952 - r20146954;
        double r20146956 = r20146949 * r20146955;
        double r20146957 = r20146946 + r20146956;
        return r20146957;
}

double f(double x, double y, double z, double t) {
        double r20146958 = x;
        double r20146959 = z;
        double r20146960 = y;
        double r20146961 = r20146959 * r20146960;
        double r20146962 = t;
        double r20146963 = r20146962 / r20146960;
        double r20146964 = tanh(r20146963);
        double r20146965 = r20146958 / r20146960;
        double r20146966 = tanh(r20146965);
        double r20146967 = r20146964 - r20146966;
        double r20146968 = r20146961 * r20146967;
        double r20146969 = r20146958 + r20146968;
        double r20146970 = -inf.0;
        bool r20146971 = r20146969 <= r20146970;
        double r20146972 = r20146959 * r20146967;
        double r20146973 = r20146960 * r20146972;
        double r20146974 = r20146973 + r20146958;
        double r20146975 = 8.124775333408145e-45;
        bool r20146976 = r20146969 <= r20146975;
        double r20146977 = r20146976 ? r20146969 : r20146974;
        double r20146978 = r20146971 ? r20146974 : r20146977;
        return r20146978;
}

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.1
Target1.9
Herbie1.4
\[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 2 regimes
  2. if (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))) < -inf.0 or 8.124775333408145e-45 < (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y)))))

    1. Initial program 9.4

      \[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*2.3

      \[\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))))) < 8.124775333408145e-45

    1. Initial program 0.8

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\]
  3. Recombined 2 regimes into one program.
  4. Final simplification1.4

    \[\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 8.124775333408145 \cdot 10^{-45}:\\ \;\;\;\;x + \left(z \cdot y\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) + x\\ \end{array}\]

Reproduce

herbie shell --seed 2019162 
(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))))))