Average Error: 4.5 → 2.0
Time: 9.1s
Precision: binary64
\[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}\;y \leq -3.8397005902903564 \cdot 10^{+130}:\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\ \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}\;y \leq -3.8397005902903564 \cdot 10^{+130}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\

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


\end{array}
(FPCore (x y z t)
 :precision binary64
 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
(FPCore (x y z t)
 :precision binary64
 (if (<= y -3.8397005902903564e+130)
   (fma (- t x) z x)
   (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))))
double code(double x, double y, double z, double t) {
	return x + ((y * z) * (tanh(t / y) - tanh(x / y)));
}
double code(double x, double y, double z, double t) {
	double tmp;
	if (y <= -3.8397005902903564e+130) {
		tmp = fma((t - x), z, x);
	} else {
		tmp = x + (y * (z * (tanh(t / y) - tanh(x / y))));
	}
	return tmp;
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

Original4.5
Target2.0
Herbie2.0
\[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 y < -3.8397005902903564e130

    1. Initial program 14.6

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

      \[\leadsto x + \color{blue}{\left(t - x\right) \cdot z} \]
    3. Applied add-cbrt-cube_binary6428.2

      \[\leadsto x + \color{blue}{\sqrt[3]{\left(\left(\left(t - x\right) \cdot z\right) \cdot \left(\left(t - x\right) \cdot z\right)\right) \cdot \left(\left(t - x\right) \cdot z\right)}} \]
    4. Simplified28.2

      \[\leadsto x + \sqrt[3]{\color{blue}{{\left(z \cdot \left(t - x\right)\right)}^{3}}} \]
    5. Taylor expanded in x around 0 7.0

      \[\leadsto \color{blue}{\left(t \cdot z + x\right) - z \cdot x} \]
    6. Simplified7.0

      \[\leadsto \color{blue}{\mathsf{fma}\left(t - x, z, x\right)} \]

    if -3.8397005902903564e130 < y

    1. Initial program 3.1

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Applied associate-*l*_binary641.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)} \]
  3. Recombined 2 regimes into one program.
  4. Final simplification2.0

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -3.8397005902903564 \cdot 10^{+130}:\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\ \end{array} \]

Reproduce

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

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

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