Average Error: 4.8 → 1.5
Time: 13.3s
Precision: binary64
Cost: 19904
\[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 \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, 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 (- (tanh (/ t y)) (tanh (/ x y)))) z 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 * (tanh((t / y)) - tanh((x / y)))), z, x);
}
function code(x, y, z, t)
	return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))
end
function code(x, y, z, t)
	return fma(Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), z, x)
end
code[x_, y_, z_, t_] := N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
code[x_, y_, z_, t_] := N[(N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision]
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 \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, x\right)

Error

Target

Original4.8
Target1.9
Herbie1.5
\[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.8

    \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
  2. Applied egg-rr1.5

    \[\leadsto \color{blue}{\mathsf{fma}\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y, z, x\right)} \]
  3. Final simplification1.5

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

Alternatives

Alternative 1
Error2.3
Cost27332
\[\begin{array}{l} t_1 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\ \mathbf{if}\;t_1 \leq 2 \cdot 10^{+307}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 2
Error10.5
Cost13768
\[\begin{array}{l} \mathbf{if}\;x \leq -9.454695042262318 \cdot 10^{+42}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6937.449788506069:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right), z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error12.6
Cost7496
\[\begin{array}{l} \mathbf{if}\;x \leq -9.454695042262318 \cdot 10^{+42}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 6937.449788506069:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error14.8
Cost712
\[\begin{array}{l} t_1 := x + z \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -9.357091807327638 \cdot 10^{+46}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 8.775224147793738 \cdot 10^{-7}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error17.8
Cost584
\[\begin{array}{l} t_1 := x + t \cdot z\\ \mathbf{if}\;y \leq -2.777167715531232 \cdot 10^{+29}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.1182668919033429 \cdot 10^{-13}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error22.7
Cost64
\[x \]

Error

Reproduce

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