Average Error: 4.1 → 4.1
Time: 4.0s
Precision: binary64
\[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
\[\mathsf{fma}\left(y \cdot z, \mathsf{log1p}\left(\mathsf{expm1}\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right), x\right) \]
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\mathsf{fma}\left(y \cdot z, \mathsf{log1p}\left(\mathsf{expm1}\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right), x\right)
(FPCore (x y z t)
 :precision binary64
 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
(FPCore (x y z t)
 :precision binary64
 (fma (* y z) (log1p (expm1 (- (tanh (/ t y)) (tanh (/ x y))))) x))
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) {
	return fma((y * z), log1p(expm1(tanh(t / y) - tanh(x / y))), x);
}

Error

Bits error versus x

Bits error versus y

Bits error versus z

Bits error versus t

Target

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

Derivation

  1. Initial program 4.1

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

    \[\leadsto \color{blue}{\mathsf{fma}\left(y \cdot z, \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right), x\right)} \]
  3. Applied log1p-expm1-u_binary644.1

    \[\leadsto \mathsf{fma}\left(y \cdot z, \color{blue}{\mathsf{log1p}\left(\mathsf{expm1}\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)}, x\right) \]
  4. Final simplification4.1

    \[\leadsto \mathsf{fma}\left(y \cdot z, \mathsf{log1p}\left(\mathsf{expm1}\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right), x\right) \]

Reproduce

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