Average Error: 4.4 → 1.5
Time: 10.9s
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 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\ t_2 := x + \left(y \cdot z\right) \cdot t_1\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;t_2 \leq 5 \cdot 10^{-72}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(z \cdot t_1\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
 (let* ((t_1 (- (tanh (/ t y)) (tanh (/ x y)))) (t_2 (+ x (* (* y z) t_1))))
   (if (<= t_2 (- INFINITY))
     (+ x (* z (- t x)))
     (if (<= t_2 5e-72) t_2 (+ x (* y (* z 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 = tanh((t / y)) - tanh((x / y));
	double t_2 = x + ((y * z) * t_1);
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = x + (z * (t - x));
	} else if (t_2 <= 5e-72) {
		tmp = t_2;
	} else {
		tmp = x + (y * (z * 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 = Math.tanh((t / y)) - Math.tanh((x / y));
	double t_2 = x + ((y * z) * t_1);
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = x + (z * (t - x));
	} else if (t_2 <= 5e-72) {
		tmp = t_2;
	} else {
		tmp = x + (y * (z * 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 = math.tanh((t / y)) - math.tanh((x / y))
	t_2 = x + ((y * z) * t_1)
	tmp = 0
	if t_2 <= -math.inf:
		tmp = x + (z * (t - x))
	elif t_2 <= 5e-72:
		tmp = t_2
	else:
		tmp = x + (y * (z * 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(tanh(Float64(t / y)) - tanh(Float64(x / y)))
	t_2 = Float64(x + Float64(Float64(y * z) * t_1))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = Float64(x + Float64(z * Float64(t - x)));
	elseif (t_2 <= 5e-72)
		tmp = t_2;
	else
		tmp = Float64(x + Float64(y * Float64(z * 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 = tanh((t / y)) - tanh((x / y));
	t_2 = x + ((y * z) * t_1);
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = x + (z * (t - x));
	elseif (t_2 <= 5e-72)
		tmp = t_2;
	else
		tmp = x + (y * (z * 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[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(y * z), $MachinePrecision] * t$95$1), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$2, 5e-72], t$95$2, N[(x + N[(y * N[(z * t$95$1), $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}
t_1 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\
t_2 := x + \left(y \cdot z\right) \cdot t_1\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\

\mathbf{elif}\;t_2 \leq 5 \cdot 10^{-72}:\\
\;\;\;\;t_2\\

\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.4
Target2.1
Herbie1.5
\[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. Simplified1.5

      \[\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
      (+.f64 x (*.f64 y (*.f64 z (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 17 points increase in error, 9 points decrease in error
    3. Taylor expanded in y around inf 0.0

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

    if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.9999999999999996e-72

    1. Initial program 1.0

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

    if 4.9999999999999996e-72 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 6.2

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

      \[\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
      (+.f64 x (*.f64 y (*.f64 z (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 0 points increase in error, 0 points decrease in error
      (+.f64 x (Rewrite<= associate-*l*_binary64 (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))): 17 points increase in error, 9 points decrease in error
  3. Recombined 3 regimes into one program.
  4. Final simplification1.5

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

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
Error10.6
Cost7368
\[\begin{array}{l} \mathbf{if}\;x \leq -8.6 \cdot 10^{+27}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.85 \cdot 10^{-56}:\\ \;\;\;\;x + z \cdot \left(y \cdot \tanh \left(\frac{t}{y}\right) - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error11.3
Cost7108
\[\begin{array}{l} \mathbf{if}\;y \leq 4.9 \cdot 10^{+162}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 4
Error15.7
Cost712
\[\begin{array}{l} t_1 := x + z \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -8.5 \cdot 10^{+37}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 4 \cdot 10^{+69}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error18.6
Cost584
\[\begin{array}{l} t_1 := x + z \cdot t\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{+64}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.8 \cdot 10^{+127}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error23.6
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -8.2 \cdot 10^{-144}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -3.5 \cdot 10^{-199}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 7
Error23.1
Cost64
\[x \]

Error

Reproduce

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