?

Average Accuracy: 92.5% → 98.2%
Time: 19.7s
Precision: binary64
Cost: 20036

?

\[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}\;y \leq 2.1 \cdot 10^{+216}:\\ \;\;\;\;\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\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 (<= y 2.1e+216)
   (fma z (* y (- (tanh (/ t y)) (tanh (/ x y)))) x)
   (+ 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 (y <= 2.1e+216) {
		tmp = fma(z, (y * (tanh((t / y)) - tanh((x / y)))), x);
	} else {
		tmp = x + (z * (t - x));
	}
	return tmp;
}
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)
	tmp = 0.0
	if (y <= 2.1e+216)
		tmp = fma(z, Float64(y * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x);
	else
		tmp = Float64(x + Float64(z * Float64(t - x)));
	end
	return tmp
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_] := If[LessEqual[y, 2.1e+216], N[(z * N[(y * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
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}\;y \leq 2.1 \cdot 10^{+216}:\\
\;\;\;\;\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)\\

\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\


\end{array}

Error?

Target

Original92.5%
Target97.0%
Herbie98.2%
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \]

Derivation?

  1. Split input into 2 regimes
  2. if y < 2.10000000000000001e216

    1. Initial program 94.1%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Simplified98.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]94.1

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

      +-commutative [=>]94.1

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

      *-commutative [=>]94.1

      \[ \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* [=>]98.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 [=>]98.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)} \]

    if 2.10000000000000001e216 < y

    1. Initial program 67.8%

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Simplified86.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)} \]
      Proof

      [Start]67.8

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

      associate-*l* [=>]86.2

      \[ x + \color{blue}{y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)} \]
    3. Taylor expanded in y around inf 95.9%

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

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

Alternatives

Alternative 1
Accuracy88.8%
Cost13769
\[\begin{array}{l} \mathbf{if}\;t \leq -800000 \lor \neg \left(t \leq 3 \cdot 10^{-89}\right):\\ \;\;\;\;\mathsf{fma}\left(z, y \cdot \tanh \left(\frac{t}{y}\right), x\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 2
Accuracy97.6%
Cost13764
\[\begin{array}{l} \mathbf{if}\;y \leq 1.9 \cdot 10^{+216}:\\ \;\;\;\;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} \]
Alternative 3
Accuracy86.6%
Cost13644
\[\begin{array}{l} t_1 := \mathsf{fma}\left(z, y \cdot \tanh \left(\frac{t}{y}\right), x\right)\\ \mathbf{if}\;t \leq -9.8 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.05 \cdot 10^{-235}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;t \leq 1.85 \cdot 10^{-87}:\\ \;\;\;\;x + \left(z \cdot t - \tanh \left(\frac{x}{y}\right) \cdot \left(y \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Accuracy80.9%
Cost7636
\[\begin{array}{l} t_1 := x + z \cdot \left(t - x\right)\\ t_2 := x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\ \mathbf{if}\;t \leq -3.3 \cdot 10^{-147}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;t \leq -7.8 \cdot 10^{-236}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.95 \cdot 10^{-290}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 5 \cdot 10^{-269}:\\ \;\;\;\;x + \frac{z}{\frac{1}{t - x}}\\ \mathbf{elif}\;t \leq 3.3 \cdot 10^{-90}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Accuracy84.1%
Cost7628
\[\begin{array}{l} t_1 := x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\ \mathbf{if}\;t \leq -5.1 \cdot 10^{-148}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -9.5 \cdot 10^{-236}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;t \leq 3.5 \cdot 10^{-93}:\\ \;\;\;\;x + \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Accuracy84.2%
Cost7628
\[\begin{array}{l} t_1 := x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\ \mathbf{if}\;t \leq -6 \cdot 10^{-149}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq -1.25 \cdot 10^{-235}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;t \leq 2.8 \cdot 10^{-87}:\\ \;\;\;\;x + \left(z \cdot t - \tanh \left(\frac{x}{y}\right) \cdot \left(y \cdot z\right)\right)\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Accuracy84.2%
Cost7364
\[\begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right)\\ \mathbf{if}\;y \leq -1.65 \cdot 10^{-43}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(t_1 - \frac{x}{y}\right)\right)\\ \mathbf{elif}\;y \leq 3.3 \cdot 10^{+91}:\\ \;\;\;\;x + t_1 \cdot \left(y \cdot z\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 8
Accuracy74.3%
Cost7244
\[\begin{array}{l} t_1 := x + z \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -1.8 \cdot 10^{-39}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{-47}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.5 \cdot 10^{+20}:\\ \;\;\;\;\tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+93}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Accuracy76.2%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -2.9 \cdot 10^{-39} \lor \neg \left(y \leq 1.86 \cdot 10^{+93}\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy67.9%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -3.35 \cdot 10^{-40} \lor \neg \left(y \leq 1.85 \cdot 10^{+93}\right):\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy70.7%
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -4.6 \cdot 10^{+57}:\\ \;\;\;\;x + z \cdot t\\ \mathbf{elif}\;y \leq 1.6 \cdot 10^{+93}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \end{array} \]
Alternative 12
Accuracy63.2%
Cost520
\[\begin{array}{l} \mathbf{if}\;z \leq 2.6 \cdot 10^{+29}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.7 \cdot 10^{+101}:\\ \;\;\;\;z \cdot \left(-x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Accuracy64.8%
Cost64
\[x \]

Error

Reproduce?

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