?

Average Error: 7.5% → 2.34%
Time: 17.8s
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

Original7.5%
Target3.27%
Herbie2.34%
\[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 7.5

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

    \[\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]7.5

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

    +-commutative [=>]7.5

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

    *-commutative [=>]7.5

    \[ \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* [=>]2.35

    \[ \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 [=>]2.34

    \[ \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 simplification2.34

    \[\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
Error3.5%
Cost27332
\[\begin{array}{l} t_1 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right)\\ \mathbf{if}\;t_1 \leq 10^{+307}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 2
Error11.59%
Cost13769
\[\begin{array}{l} \mathbf{if}\;t \leq -1.15 \cdot 10^{-48} \lor \neg \left(t \leq 88000000000000\right):\\ \;\;\;\;x + z \cdot \frac{1}{\frac{1}{y \cdot \tanh \left(\frac{t}{y}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, y \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), x\right)\\ \end{array} \]
Alternative 3
Error13.74%
Cost13576
\[\begin{array}{l} t_1 := \tanh \left(\frac{x}{y}\right)\\ \mathbf{if}\;x \leq -100:\\ \;\;\;\;x - z \cdot \left(y \cdot t_1\right)\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-67}:\\ \;\;\;\;x + z \cdot \frac{1}{\frac{1}{y \cdot \tanh \left(\frac{t}{y}\right)}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(y, z \cdot \left(-t_1\right), x\right)\\ \end{array} \]
Alternative 4
Error13.74%
Cost7497
\[\begin{array}{l} \mathbf{if}\;x \leq -18 \lor \neg \left(x \leq 6.5 \cdot 10^{-68}\right):\\ \;\;\;\;x - z \cdot \left(y \cdot \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \frac{1}{\frac{1}{y \cdot \tanh \left(\frac{t}{y}\right)}}\\ \end{array} \]
Alternative 5
Error15.68%
Cost7369
\[\begin{array}{l} \mathbf{if}\;x \leq -29 \lor \neg \left(x \leq 4.2 \cdot 10^{-67}\right):\\ \;\;\;\;x - z \cdot \left(y \cdot \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{z \cdot y}{\frac{1}{\tanh \left(\frac{t}{y}\right)}}\\ \end{array} \]
Alternative 6
Error15.58%
Cost7241
\[\begin{array}{l} \mathbf{if}\;x \leq -32 \lor \neg \left(x \leq 6.2 \cdot 10^{-67}\right):\\ \;\;\;\;x - z \cdot \left(y \cdot \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \end{array} \]
Alternative 7
Error21.83%
Cost7112
\[\begin{array}{l} \mathbf{if}\;y \leq -2.3 \cdot 10^{+97}:\\ \;\;\;\;x + \frac{t + x}{\frac{\frac{t + x}{z}}{t - x}}\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{+124}:\\ \;\;\;\;x + \frac{z \cdot y}{\frac{t}{y} \cdot 0.3333333333333333 + \frac{y}{t}}\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t, z, x - z \cdot x\right)\\ \end{array} \]
Alternative 8
Error18.09%
Cost7108
\[\begin{array}{l} \mathbf{if}\;y \leq -7.5 \cdot 10^{+98}:\\ \;\;\;\;x + \frac{t + x}{\frac{\frac{t + x}{z}}{t - x}}\\ \mathbf{else}:\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \end{array} \]
Alternative 9
Error20.93%
Cost1224
\[\begin{array}{l} \mathbf{if}\;y \leq -1.42 \cdot 10^{+97}:\\ \;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\ \mathbf{elif}\;y \leq 4.8 \cdot 10^{+127}:\\ \;\;\;\;x + \frac{z \cdot y}{\frac{t}{y} \cdot 0.3333333333333333 + \frac{y}{t}}\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 10
Error21.84%
Cost1224
\[\begin{array}{l} \mathbf{if}\;y \leq -6.2 \cdot 10^{+97}:\\ \;\;\;\;x + \frac{t + x}{\frac{\frac{t + x}{z}}{t - x}}\\ \mathbf{elif}\;y \leq 7.9 \cdot 10^{+121}:\\ \;\;\;\;x + \frac{z \cdot y}{\frac{t}{y} \cdot 0.3333333333333333 + \frac{y}{t}}\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 11
Error22.46%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -7.6 \cdot 10^{+62} \lor \neg \left(y \leq 220\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error22.41%
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.3 \cdot 10^{+56}:\\ \;\;\;\;x \cdot \left(1 - z\right) + z \cdot t\\ \mathbf{elif}\;y \leq 85:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 13
Error27.32%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -2.3 \cdot 10^{+64} \lor \neg \left(y \leq 82\right):\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 14
Error34.43%
Cost64
\[x \]

Error

Reproduce?

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