Average Error: 4.5 → 2.7
Time: 5.8s
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}\;y \le -2.9957314611234766 \cdot 10^{247} \lor \neg \left(y \le 1.3781839898159729 \cdot 10^{137}\right):\\ \;\;\;\;\mathsf{fma}\left(t, z, x - x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\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}\;y \le -2.9957314611234766 \cdot 10^{247} \lor \neg \left(y \le 1.3781839898159729 \cdot 10^{137}\right):\\
\;\;\;\;\mathsf{fma}\left(t, z, x - x \cdot z\right)\\

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

\end{array}
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 VAR;
	if (((y <= -2.9957314611234766e+247) || !(y <= 1.378183989815973e+137))) {
		VAR = fma(t, z, (x - (x * z)));
	} else {
		VAR = (((y * z) * (tanh((t / y)) - tanh((x / y)))) + x);
	}
	return VAR;
}

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
Target2.1
Herbie2.7
\[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 < -2.9957314611234766e+247 or 1.378183989815973e+137 < y

    1. Initial program 16.5

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)}\]
    3. Using strategy rm
    4. Applied sub-neg8.3

      \[\leadsto \mathsf{fma}\left(y, z \cdot \color{blue}{\left(\tanh \left(\frac{t}{y}\right) + \left(-\tanh \left(\frac{x}{y}\right)\right)\right)}, x\right)\]
    5. Applied distribute-lft-in8.3

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{z \cdot \tanh \left(\frac{t}{y}\right) + z \cdot \left(-\tanh \left(\frac{x}{y}\right)\right)}, x\right)\]
    6. Taylor expanded around inf 10.4

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{\frac{t \cdot z}{y}} + z \cdot \left(-\tanh \left(\frac{x}{y}\right)\right), x\right)\]
    7. Taylor expanded around inf 5.5

      \[\leadsto \color{blue}{\left(t \cdot z + x\right) - x \cdot z}\]
    8. Simplified5.5

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

    if -2.9957314611234766e+247 < y < 1.378183989815973e+137

    1. Initial program 2.2

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)}\]
    3. Using strategy rm
    4. Applied sub-neg0.9

      \[\leadsto \mathsf{fma}\left(y, z \cdot \color{blue}{\left(\tanh \left(\frac{t}{y}\right) + \left(-\tanh \left(\frac{x}{y}\right)\right)\right)}, x\right)\]
    5. Applied distribute-lft-in0.9

      \[\leadsto \mathsf{fma}\left(y, \color{blue}{z \cdot \tanh \left(\frac{t}{y}\right) + z \cdot \left(-\tanh \left(\frac{x}{y}\right)\right)}, x\right)\]
    6. Using strategy rm
    7. Applied fma-udef0.9

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

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \le -2.9957314611234766 \cdot 10^{247} \lor \neg \left(y \le 1.3781839898159729 \cdot 10^{137}\right):\\ \;\;\;\;\mathsf{fma}\left(t, z, x - x \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;\left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) + x\\ \end{array}\]

Reproduce

herbie shell --seed 2020078 +o rules:numerics
(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))))))