Average Error: 4.4 → 0.7
Time: 14.2s
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(y \cdot z\right)\\ \mathbf{if}\;t_2 \leq -\infty:\\ \;\;\;\;t_1\\ \mathbf{elif}\;t_2 \leq 2 \cdot 10^{+307}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;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))) (* y z)))))
   (if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 2e+307) t_2 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))) * (y * z));
	double tmp;
	if (t_2 <= -((double) INFINITY)) {
		tmp = t_1;
	} else if (t_2 <= 2e+307) {
		tmp = t_2;
	} else {
		tmp = 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))) * (y * z));
	double tmp;
	if (t_2 <= -Double.POSITIVE_INFINITY) {
		tmp = t_1;
	} else if (t_2 <= 2e+307) {
		tmp = t_2;
	} else {
		tmp = 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))) * (y * z))
	tmp = 0
	if t_2 <= -math.inf:
		tmp = t_1
	elif t_2 <= 2e+307:
		tmp = t_2
	else:
		tmp = 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(y * z)))
	tmp = 0.0
	if (t_2 <= Float64(-Inf))
		tmp = t_1;
	elseif (t_2 <= 2e+307)
		tmp = t_2;
	else
		tmp = 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))) * (y * z));
	tmp = 0.0;
	if (t_2 <= -Inf)
		tmp = t_1;
	elseif (t_2 <= 2e+307)
		tmp = t_2;
	else
		tmp = 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[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+307], t$95$2, t$95$1]]]]
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(y \cdot z\right)\\
\mathbf{if}\;t_2 \leq -\infty:\\
\;\;\;\;t_1\\

\mathbf{elif}\;t_2 \leq 2 \cdot 10^{+307}:\\
\;\;\;\;t_2\\

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


\end{array}

Error

Try it out

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.4
Target1.9
Herbie0.7
\[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 1.99999999999999997e307 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y)))))

    1. Initial program 63.2

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

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
      Proof
      (fma.f64 z (-.f64 t x) x): 0 points increase in error, 0 points decrease in error
      (Rewrite<= fma-def_binary64 (+.f64 (*.f64 z (-.f64 t x)) x)): 1 points increase in error, 0 points decrease in error
      (Rewrite<= +-commutative_binary64 (+.f64 x (*.f64 z (-.f64 t x)))): 0 points increase in error, 0 points decrease in error
    4. Taylor expanded in z around inf 4.1

      \[\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))))) < 1.99999999999999997e307

    1. Initial program 0.5

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

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

Alternatives

Alternative 1
Error1.3
Cost19904
\[\mathsf{fma}\left(y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), z, x\right) \]
Alternative 2
Error14.1
Cost14032
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2462922869921212 \cdot 10^{-18}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.394427818558781 \cdot 10^{-99}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)\\ \mathbf{elif}\;x \leq 3.08157187829623 \cdot 10^{+124}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{+201}:\\ \;\;\;\;\mathsf{fma}\left(y \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), z, x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 3
Error14.2
Cost7760
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2462922869921212 \cdot 10^{-18}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.394427818558781 \cdot 10^{-99}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)\\ \mathbf{elif}\;x \leq 3.08157187829623 \cdot 10^{+124}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 7.2 \cdot 10^{+201}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 4
Error13.5
Cost7496
\[\begin{array}{l} \mathbf{if}\;x \leq -3.2462922869921212 \cdot 10^{-18}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 3.394427818558781 \cdot 10^{-99}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \frac{x}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 5
Error16.2
Cost712
\[\begin{array}{l} t_1 := x + z \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -1.9014828040752715 \cdot 10^{+49}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+152}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 6
Error16.2
Cost712
\[\begin{array}{l} \mathbf{if}\;y \leq -1.9014828040752715 \cdot 10^{+49}:\\ \;\;\;\;x + \left(t \cdot z - x \cdot z\right)\\ \mathbf{elif}\;y \leq 1.3 \cdot 10^{+152}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 7
Error22.2
Cost584
\[\begin{array}{l} \mathbf{if}\;x \leq -3.80067266479522 \cdot 10^{-198}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.513726612687245 \cdot 10^{-216}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Error18.6
Cost584
\[\begin{array}{l} t_1 := x + t \cdot z\\ \mathbf{if}\;y \leq -2.6321891418350098 \cdot 10^{-27}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 3.2 \cdot 10^{+122}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error22.5
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -3.80067266479522 \cdot 10^{-198}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 4.513726612687245 \cdot 10^{-216}:\\ \;\;\;\;t \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error22.9
Cost64
\[x \]

Error

Reproduce

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