?

Average Error: 4.8 → 1.2
Time: 12.5s
Precision: binary64
Cost: 41032

?

\[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
\[\begin{array}{l} t_1 := z \cdot \left(t - x\right)\\ t_2 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right)\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 4 \cdot 10^{+296}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x + t_1\\ \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
 (let* ((t_1 (* z (- t x)))
        (t_2 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* z y)))))
   (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 4e+296) t_2 (+ x t_1)))))
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 t_1 = z * (t - x);
	double t_2 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 4e+296) {
		tmp = t_2;
	} else {
		tmp = x + t_1;
	}
	return tmp;
}
public static double code(double x, double y, double z, double t) {
	return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
public static double code(double x, double y, double z, double t) {
	double t_1 = z * (t - x);
	double t_2 = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (z * y));
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_2 <= 4e+296) {
		tmp = t_2;
	} else {
		tmp = x + t_1;
	}
	return tmp;
}
def code(x, y, z, t):
	return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
def code(x, y, z, t):
	t_1 = z * (t - x)
	t_2 = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (z * y))
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_1
	elif t_2 <= 4e+296:
		tmp = t_2
	else:
		tmp = x + t_1
	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)
	t_1 = Float64(z * Float64(t - x))
	t_2 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(z * y)))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 4e+296)
		tmp = t_2;
	else
		tmp = Float64(x + t_1);
	end
	return tmp
end
function tmp = code(x, y, z, t)
	tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
end
function tmp_2 = code(x, y, z, t)
	t_1 = z * (t - x);
	t_2 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y));
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_1;
	elseif (t_2 <= 4e+296)
		tmp = t_2;
	else
		tmp = x + t_1;
	end
	tmp_2 = 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_] := Block[{t$95$1 = N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 4e+296], t$95$2, N[(x + t$95$1), $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}
t_1 := z \cdot \left(t - x\right)\\
t_2 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right)\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 4 \cdot 10^{+296}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;x + t_1\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.8
Target2.0
Herbie1.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 3 regimes
  2. if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0

    1. Initial program 64.0

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

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

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

      +-commutative [=>]64.0

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

      *-commutative [=>]64.0

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

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

      \[ \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. Taylor expanded in y around inf 0.0

      \[\leadsto \color{blue}{\left(t - x\right) \cdot z + x} \]
    4. Taylor expanded in z around inf 0.0

      \[\leadsto \color{blue}{\left(t - x\right) \cdot z} \]

    if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 3.99999999999999993e296

    1. Initial program 0.6

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

    if 3.99999999999999993e296 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 51.1

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

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

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

      +-commutative [=>]51.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 [=>]51.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* [=>]17.7

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

      \[ \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. Taylor expanded in y around inf 11.1

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right) \leq -\infty:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{elif}\;x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right) \leq 4 \cdot 10^{+296}:\\ \;\;\;\;x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]

Alternatives

Alternative 1
Error1.5
Cost19904
\[\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right) \]
Alternative 2
Error1.5
Cost13632
\[x + z \cdot \left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \]
Alternative 3
Error10.4
Cost13577
\[\begin{array}{l} \mathbf{if}\;t \leq -2.4 \cdot 10^{-185} \lor \neg \left(t \leq 4.8 \cdot 10^{-104}\right):\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;\mathsf{fma}\left(z, y \cdot \left(-\tanh \left(\frac{x}{y}\right)\right), x\right)\\ \end{array} \]
Alternative 4
Error10.1
Cost7241
\[\begin{array}{l} \mathbf{if}\;y \leq -8.5 \cdot 10^{+62} \lor \neg \left(y \leq 3.15 \cdot 10^{+112}\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \end{array} \]
Alternative 5
Error10.4
Cost7241
\[\begin{array}{l} \mathbf{if}\;t \leq -1.85 \cdot 10^{-183} \lor \neg \left(t \leq 1.1 \cdot 10^{-103}\right):\\ \;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot \left(y \cdot \tanh \left(\frac{x}{y}\right)\right)\\ \end{array} \]
Alternative 6
Error23.7
Cost850
\[\begin{array}{l} \mathbf{if}\;y \leq -2.85 \cdot 10^{+59} \lor \neg \left(y \leq 4.3 \cdot 10^{+146} \lor \neg \left(y \leq 3.4 \cdot 10^{+159}\right) \land y \leq 1.1 \cdot 10^{+201}\right):\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error15.6
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -3.8 \cdot 10^{+15} \lor \neg \left(y \leq 1.9 \cdot 10^{-46}\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error23.5
Cost588
\[\begin{array}{l} \mathbf{if}\;y \leq 2.5 \cdot 10^{+147}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 3.4 \cdot 10^{+159}:\\ \;\;\;\;z \cdot t\\ \mathbf{elif}\;y \leq 4.9 \cdot 10^{+222}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot t\\ \end{array} \]
Alternative 9
Error21.6
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{+64}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 2 \cdot 10^{+118}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot t\\ \end{array} \]
Alternative 10
Error19.8
Cost584
\[\begin{array}{l} \mathbf{if}\;y \leq -5200000000:\\ \;\;\;\;x - z \cdot x\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+118}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot t\\ \end{array} \]
Alternative 11
Error22.9
Cost64
\[x \]

Error

Reproduce?

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