?

Average Error: 4.9 → 1.6
Time: 15.5s
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(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\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 z (* y (- (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(z, (y * (tanh((t / y)) - tanh((x / y)))), 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(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), 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[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 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(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)

Error?

Target

Original4.9
Target2.1
Herbie1.6
\[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.9

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

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

    [Start]4.9

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

    +-commutative [=>]4.9

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

    *-commutative [=>]4.9

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

    associate-*l* [=>]1.6

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

    fma-def [=>]1.6

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

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

Alternatives

Alternative 1
Error2.1
Cost13632
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \]
Alternative 2
Error22.8
Cost7638
\[\begin{array}{l} \mathbf{if}\;z \leq -4.4 \cdot 10^{+252}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.48 \cdot 10^{+91} \lor \neg \left(z \leq 2.3 \cdot 10^{+26}\right) \land \left(z \leq 1.15 \cdot 10^{+88} \lor \neg \left(z \leq 1.6 \cdot 10^{+194}\right)\right):\\ \;\;\;\;z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right) - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error9.9
Cost7497
\[\begin{array}{l} \mathbf{if}\;t \leq -9.5 \cdot 10^{-65} \lor \neg \left(t \leq 3.7 \cdot 10^{-134}\right):\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\right)\\ \end{array} \]
Alternative 4
Error21.6
Cost7376
\[\begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{if}\;x \leq -3.3 \cdot 10^{-258}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.6 \cdot 10^{-215}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 7.4 \cdot 10^{-98}:\\ \;\;\;\;x + \frac{z}{\frac{-y}{y \cdot x}}\\ \mathbf{elif}\;x \leq 9.8 \cdot 10^{-64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 1.05 \cdot 10^{+48}:\\ \;\;\;\;x - z \cdot x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error11.4
Cost7241
\[\begin{array}{l} \mathbf{if}\;t \leq -4.3 \cdot 10^{-144} \lor \neg \left(t \leq 1.3 \cdot 10^{-128}\right):\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x - \tanh \left(\frac{x}{y}\right) \cdot \left(z \cdot y\right)\\ \end{array} \]
Alternative 6
Error13.9
Cost7240
\[\begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right)\\ \mathbf{if}\;z \leq -3.8 \cdot 10^{+252}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -4.3 \cdot 10^{+154}:\\ \;\;\;\;z \cdot \left(y \cdot t_1 - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\ \end{array} \]
Alternative 7
Error15.7
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{+105}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-44}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + \left(z \cdot t - z \cdot x\right)\\ \end{array} \]
Alternative 8
Error15.7
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{+105} \lor \neg \left(y \leq 1.15 \cdot 10^{-43}\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error23.0
Cost584
\[\begin{array}{l} \mathbf{if}\;t \leq -2.16 \cdot 10^{-305}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 5 \cdot 10^{-96}:\\ \;\;\;\;x - z \cdot x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error23.1
Cost64
\[x \]

Error

Reproduce?

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