?

Average Error: 4.8 → 1.3
Time: 14.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(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.8
Target1.9
Herbie1.3
\[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. Simplified1.3

    \[\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.8

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

    +-commutative [=>]4.8

    \[ \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.8

    \[ \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.3

    \[ \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.3

    \[ \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.3

    \[\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.7
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 4 \cdot 10^{+302}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 2
Error9.1
Cost7497
\[\begin{array}{l} \mathbf{if}\;t \leq -1.2 \cdot 10^{+26} \lor \neg \left(t \leq 2.2 \cdot 10^{-163}\right):\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(z \cdot t - z \cdot \left(y \cdot \tanh \left(\frac{x}{y}\right)\right)\right)\\ \end{array} \]
Alternative 3
Error8.4
Cost7497
\[\begin{array}{l} \mathbf{if}\;t \leq -1.2 \cdot 10^{+26} \lor \neg \left(t \leq 1.75 \cdot 10^{-163}\right):\\ \;\;\;\;\frac{1}{\frac{1}{x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)}}\\ \mathbf{else}:\\ \;\;\;\;x + \left(z \cdot t - z \cdot \left(y \cdot \tanh \left(\frac{x}{y}\right)\right)\right)\\ \end{array} \]
Alternative 4
Error16.2
Cost7248
\[\begin{array}{l} \mathbf{if}\;y \leq -1.95 \cdot 10^{+114}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq -1 \cdot 10^{-133}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq -2.1 \cdot 10^{-145}:\\ \;\;\;\;\tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{+18}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \end{array} \]
Alternative 5
Error10.6
Cost7241
\[\begin{array}{l} \mathbf{if}\;t \leq -2.35 \cdot 10^{-168} \lor \neg \left(t \leq 3.4 \cdot 10^{-167}\right):\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x - y \cdot \left(z \cdot \tanh \left(\frac{x}{y}\right)\right)\\ \end{array} \]
Alternative 6
Error11.6
Cost7240
\[\begin{array}{l} \mathbf{if}\;y \leq -1.75 \cdot 10^{+214}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 2.7 \cdot 10^{+53}:\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + \frac{t + x}{\frac{\left(-t\right) - x}{z}} \cdot \left(x - t\right)\\ \end{array} \]
Alternative 7
Error15.8
Cost6984
\[\begin{array}{l} \mathbf{if}\;y \leq -1.05 \cdot 10^{+114}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 4.25 \cdot 10^{+18}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \end{array} \]
Alternative 8
Error22.8
Cost717
\[\begin{array}{l} \mathbf{if}\;y \leq -8 \cdot 10^{+215} \lor \neg \left(y \leq 9.5 \cdot 10^{+150}\right) \land y \leq 1.15 \cdot 10^{+239}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Error15.8
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{+113} \lor \neg \left(y \leq 2.25 \cdot 10^{+18}\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error18.6
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{+113} \lor \neg \left(y \leq 1.6 \cdot 10^{+19}\right):\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error23.9
Cost520
\[\begin{array}{l} \mathbf{if}\;t \leq -4.3 \cdot 10^{-193}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -7.2 \cdot 10^{-225}:\\ \;\;\;\;-z \cdot x\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error23.1
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -9 \cdot 10^{-187}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 2.7 \cdot 10^{-299}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Error23.2
Cost64
\[x \]

Error

Reproduce?

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