Average Error: 4.6 → 1.5
Time: 7.7s
Precision: binary64
Cost: 27521
\[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(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \leq 2.0153449175156312 \cdot 10^{+300}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\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}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \leq 2.0153449175156312 \cdot 10^{+300}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\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 (<=
      (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y)))))
      2.0153449175156312e+300)
   (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
   (+ x (* z (- t 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) {
	double tmp;
	if ((x + ((y * z) * (tanh(t / y) - tanh(x / y)))) <= 2.0153449175156312e+300) {
		tmp = x + (y * (z * (tanh(t / y) - tanh(x / y))));
	} else {
		tmp = x + (z * (t - x));
	}
	return tmp;
}

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.6
Target2.1
Herbie1.5
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\]

Alternatives

Alternative 1
Error10.4
Cost8260
\[\begin{array}{l} \mathbf{if}\;y \leq -5.42800294655821 \cdot 10^{+74}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq -1.1313193967781163 \cdot 10^{-209}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right)\\ \mathbf{elif}\;y \leq 7.054004603276514 \cdot 10^{-289}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 7.797560520079821 \cdot 10^{+107}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array}\]
Alternative 2
Error15.2
Cost776
\[\begin{array}{l} \mathbf{if}\;y \leq -3.4039960225235837 \cdot 10^{-07} \lor \neg \left(y \leq 1.2271289958229 \cdot 10^{+41}\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 3
Error21.0
Cost648
\[\begin{array}{l} \mathbf{if}\;y \leq -2.1529229305819905 \cdot 10^{-07} \lor \neg \left(y \leq 2.628905711122354 \cdot 10^{+125}\right):\\ \;\;\;\;x - x \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 4
Error22.9
Cost834
\[\begin{array}{l} \mathbf{if}\;x \leq -7.08475183784244 \cdot 10^{-179}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 5.442066255850792 \cdot 10^{-231}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array}\]
Alternative 5
Error23.2
Cost64
\[x\]
Alternative 6
Error61.7
Cost64
\[-1\]
Alternative 7
Error61.8
Cost64
\[1\]

Error

Derivation

  1. Split input into 2 regimes
  2. if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.0153449175156312e300

    1. Initial program 2.3

      \[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*_binary64_112721.2

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

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

    if 2.0153449175156312e300 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 52.4

      \[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 inf 8.1

      \[\leadsto x + \color{blue}{\left(t - x\right) \cdot z}\]
    3. Simplified8.1

      \[\leadsto x + \color{blue}{z \cdot \left(t - x\right)}\]
    4. Simplified8.1

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

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

Reproduce

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