?

Average Error: 4.7 → 2.5
Time: 1.6min
Precision: binary64
Cost: 13896

?

\[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)\\ \mathbf{if}\;y \leq -5.5 \cdot 10^{+125}:\\ \;\;\;\;z \cdot t - x \cdot \left(-1 + z\right)\\ \mathbf{elif}\;y \leq 1.06 \cdot 10^{+99}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(t_1 - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(t_1 \cdot y + \left(-x\right)\right) \cdot z\\ \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))))
   (if (<= y -5.5e+125)
     (- (* z t) (* x (+ -1.0 z)))
     (if (<= y 1.06e+99)
       (+ x (* (* y z) (- t_1 (tanh (/ x y)))))
       (+ x (* (+ (* t_1 y) (- x)) z))))))
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));
	double tmp;
	if (y <= -5.5e+125) {
		tmp = (z * t) - (x * (-1.0 + z));
	} else if (y <= 1.06e+99) {
		tmp = x + ((y * z) * (t_1 - tanh((x / y))));
	} else {
		tmp = x + (((t_1 * y) + -x) * z);
	}
	return tmp;
}
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    code = x + ((y * z) * (tanh((t / y)) - tanh((x / y))))
end function
real(8) function code(x, y, z, t)
    real(8), intent (in) :: x
    real(8), intent (in) :: y
    real(8), intent (in) :: z
    real(8), intent (in) :: t
    real(8) :: t_1
    real(8) :: tmp
    t_1 = tanh((t / y))
    if (y <= (-5.5d+125)) then
        tmp = (z * t) - (x * ((-1.0d0) + z))
    else if (y <= 1.06d+99) then
        tmp = x + ((y * z) * (t_1 - tanh((x / y))))
    else
        tmp = x + (((t_1 * y) + -x) * z)
    end if
    code = tmp
end function
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));
	double tmp;
	if (y <= -5.5e+125) {
		tmp = (z * t) - (x * (-1.0 + z));
	} else if (y <= 1.06e+99) {
		tmp = x + ((y * z) * (t_1 - Math.tanh((x / y))));
	} else {
		tmp = x + (((t_1 * y) + -x) * z);
	}
	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))
	tmp = 0
	if y <= -5.5e+125:
		tmp = (z * t) - (x * (-1.0 + z))
	elif y <= 1.06e+99:
		tmp = x + ((y * z) * (t_1 - math.tanh((x / y))))
	else:
		tmp = x + (((t_1 * y) + -x) * z)
	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(t / y))
	tmp = 0.0
	if (y <= -5.5e+125)
		tmp = Float64(Float64(z * t) - Float64(x * Float64(-1.0 + z)));
	elseif (y <= 1.06e+99)
		tmp = Float64(x + Float64(Float64(y * z) * Float64(t_1 - tanh(Float64(x / y)))));
	else
		tmp = Float64(x + Float64(Float64(Float64(t_1 * y) + Float64(-x)) * z));
	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));
	tmp = 0.0;
	if (y <= -5.5e+125)
		tmp = (z * t) - (x * (-1.0 + z));
	elseif (y <= 1.06e+99)
		tmp = x + ((y * z) * (t_1 - tanh((x / y))));
	else
		tmp = x + (((t_1 * y) + -x) * z);
	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[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -5.5e+125], N[(N[(z * t), $MachinePrecision] - N[(x * N[(-1.0 + z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.06e+99], N[(x + N[(N[(y * z), $MachinePrecision] * N[(t$95$1 - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(N[(t$95$1 * y), $MachinePrecision] + (-x)), $MachinePrecision] * z), $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)\\
\mathbf{if}\;y \leq -5.5 \cdot 10^{+125}:\\
\;\;\;\;z \cdot t - x \cdot \left(-1 + z\right)\\

\mathbf{elif}\;y \leq 1.06 \cdot 10^{+99}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(t_1 - \tanh \left(\frac{x}{y}\right)\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original4.7
Target2.2
Herbie2.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 y < -5.49999999999999996e125

    1. Initial program 15.4

      \[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 7.1

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

      \[\leadsto \color{blue}{\mathsf{fma}\left(z, t - x, x\right)} \]
      Proof
    4. Applied egg-rr7.1

      \[\leadsto \color{blue}{\left(x - z \cdot x\right) - z \cdot \left(-t\right)} \]
    5. Applied egg-rr7.1

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

    if -5.49999999999999996e125 < y < 1.05999999999999999e99

    1. Initial program 0.8

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

    if 1.05999999999999999e99 < y

    1. Initial program 14.5

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

      \[\leadsto x + \color{blue}{\left(\left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot y\right) \cdot z} \]
    3. Applied egg-rr5.5

      \[\leadsto x + \color{blue}{\left(\tanh \left(\frac{t}{y}\right) \cdot y + \left(-\tanh \left(\frac{x}{y}\right) \cdot y\right)\right)} \cdot z \]
    4. Taylor expanded in x around 0 6.9

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

Alternatives

Alternative 1
Error0.8
Cost27524
\[\begin{array}{l} t_1 := \tanh \left(\frac{x}{y}\right)\\ t_2 := \tanh \left(\frac{t}{y}\right)\\ \mathbf{if}\;x + \left(y \cdot z\right) \cdot \left(t_2 - t_1\right) \leq 5 \cdot 10^{+305}:\\ \;\;\;\;x + \left(t_2 \cdot y + \left(-t_1 \cdot y\right)\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(t - x\right) \cdot z\\ \end{array} \]
Alternative 2
Error0.8
Cost27332
\[\begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\\ \mathbf{if}\;x + \left(y \cdot z\right) \cdot t_1 \leq 5 \cdot 10^{+305}:\\ \;\;\;\;x + \left(t_1 \cdot y\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;\left(t - x\right) \cdot z\\ \end{array} \]
Alternative 3
Error1.9
Cost13764
\[\begin{array}{l} \mathbf{if}\;y \leq -5.5 \cdot 10^{+152}:\\ \;\;\;\;z \cdot t - x \cdot \left(-1 + z\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \cdot y\\ \end{array} \]
Alternative 4
Error14.0
Cost7432
\[\begin{array}{l} t_1 := x + \left(t + \left(-\tanh \left(\frac{x}{y}\right) \cdot y\right)\right) \cdot z\\ \mathbf{if}\;y \leq -30000000000000:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.35 \cdot 10^{+34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 5
Error9.7
Cost7432
\[\begin{array}{l} \mathbf{if}\;x \leq -32000000000:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq 1.15 \cdot 10^{+63}:\\ \;\;\;\;x + \left(\tanh \left(\frac{t}{y}\right) \cdot y + \left(-x\right)\right) \cdot z\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 6
Error15.6
Cost840
\[\begin{array}{l} t_1 := z \cdot t - x \cdot \left(-1 + z\right)\\ \mathbf{if}\;y \leq -2.45 \cdot 10^{+117}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{+62}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 7
Error21.3
Cost716
\[\begin{array}{l} t_1 := \left(1 - z\right) \cdot x\\ \mathbf{if}\;y \leq -1.06 \cdot 10^{+145}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7 \cdot 10^{+118}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+152}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 8
Error15.6
Cost712
\[\begin{array}{l} t_1 := x + z \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -3.8 \cdot 10^{+119}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 1.62 \cdot 10^{+62}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 9
Error18.1
Cost584
\[\begin{array}{l} t_1 := t \cdot z + x\\ \mathbf{if}\;y \leq -6.6 \cdot 10^{+47}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 10^{+34}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;t_1\\ \end{array} \]
Alternative 10
Error23.4
Cost456
\[\begin{array}{l} \mathbf{if}\;y \leq 7 \cdot 10^{+118}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 6.6 \cdot 10^{+152}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Error22.9
Cost64
\[x \]

Error

Reproduce?

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