?

Average Error: 4.8 → 0.9
Time: 13.0s
Precision: binary64
Cost: 41352

?

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

\mathbf{elif}\;t_4 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;x + \left(\left(y \cdot z\right) \cdot t_3 + y \cdot \left(t_1 \cdot \left(-z\right)\right)\right)\\

\mathbf{else}:\\
\;\;\;\;t_2\\


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.8
Target2.1
Herbie0.9
\[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 (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 2.00000000000000003e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 62.7

      \[x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \]
    2. Taylor expanded in y around inf 3.5

      \[\leadsto x + \color{blue}{z \cdot \left(t - x\right)} \]
    3. Taylor expanded in z around inf 4.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))))) < 2.00000000000000003e306

    1. Initial program 0.7

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

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

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

      [Start]0.7

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

      rational_best_oopsla_all_46_json_45_simplify-7 [=>]0.7

      \[ x + \left(\left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right) + \color{blue}{y \cdot \left(\tanh \left(\frac{x}{y}\right) \cdot \left(-z\right)\right)}\right) \]
  3. Recombined 2 regimes into one program.
  4. Final simplification0.9

    \[\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:\\ \;\;\;\;\left(t - x\right) \cdot z\\ \mathbf{elif}\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \leq 2 \cdot 10^{+306}:\\ \;\;\;\;x + \left(\left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right) + y \cdot \left(\tanh \left(\frac{x}{y}\right) \cdot \left(-z\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;\left(t - x\right) \cdot z\\ \end{array} \]

Alternatives

Alternative 1
Error0.9
Cost41032
\[\begin{array}{l} t_1 := \left(t - x\right) \cdot z\\ t_2 := x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+306}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 2
Error11.3
Cost7496
\[\begin{array}{l} \mathbf{if}\;x \leq -1.82 \cdot 10^{+31}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.8 \cdot 10^{+69}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error14.3
Cost7368
\[\begin{array}{l} t_1 := x + z \cdot \left(t - y \cdot \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{if}\;y \leq -1.55 \cdot 10^{-131}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.55 \cdot 10^{-14}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 4
Error24.1
Cost848
\[\begin{array}{l} t_1 := \left(t - x\right) \cdot z\\ \mathbf{if}\;t \leq -1.65 \cdot 10^{+52}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq -1.1 \cdot 10^{+21}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t \leq 2.25 \cdot 10^{-184}:\\ \;\;\;\;x\\ \mathbf{elif}\;t \leq 2.2 \cdot 10^{-150}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error15.3
Cost712
\[\begin{array}{l} t_1 := x + z \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -5.2 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.22 \cdot 10^{-17}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error18.3
Cost584
\[\begin{array}{l} t_1 := t \cdot z + x\\ \mathbf{if}\;y \leq -5.2 \cdot 10^{+100}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.5 \cdot 10^{+63}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error22.8
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3 \cdot 10^{-235}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.45 \cdot 10^{-187}:\\ \;\;\;\;t \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error22.9
Cost64
\[x \]

Error

Reproduce?

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