?

Average Accuracy: 92.7% → 97.2%
Time: 20.0s
Precision: binary64
Cost: 14028

?

\[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 := \tanh \left(\frac{t}{y}\right) - t_1\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{+177}:\\ \;\;\;\;x + z \cdot \left(t - y \cdot t_1\right)\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{+112}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot t_2\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+155}:\\ \;\;\;\;x + y \cdot \left(z \cdot t_2\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\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 (/ x y))) (t_2 (- (tanh (/ t y)) t_1)))
   (if (<= y -1.25e+177)
     (+ x (* z (- t (* y t_1))))
     (if (<= y -1.45e+112)
       (+ x (* (* y z) t_2))
       (if (<= y 2.6e+155) (+ x (* y (* z t_2))) (+ x (* z (- t x))))))))
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 = tanh((t / y)) - t_1;
	double tmp;
	if (y <= -1.25e+177) {
		tmp = x + (z * (t - (y * t_1)));
	} else if (y <= -1.45e+112) {
		tmp = x + ((y * z) * t_2);
	} else if (y <= 2.6e+155) {
		tmp = x + (y * (z * t_2));
	} else {
		tmp = x + (z * (t - x));
	}
	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) :: t_2
    real(8) :: tmp
    t_1 = tanh((x / y))
    t_2 = tanh((t / y)) - t_1
    if (y <= (-1.25d+177)) then
        tmp = x + (z * (t - (y * t_1)))
    else if (y <= (-1.45d+112)) then
        tmp = x + ((y * z) * t_2)
    else if (y <= 2.6d+155) then
        tmp = x + (y * (z * t_2))
    else
        tmp = x + (z * (t - x))
    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((x / y));
	double t_2 = Math.tanh((t / y)) - t_1;
	double tmp;
	if (y <= -1.25e+177) {
		tmp = x + (z * (t - (y * t_1)));
	} else if (y <= -1.45e+112) {
		tmp = x + ((y * z) * t_2);
	} else if (y <= 2.6e+155) {
		tmp = x + (y * (z * t_2));
	} else {
		tmp = x + (z * (t - x));
	}
	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 = math.tanh((t / y)) - t_1
	tmp = 0
	if y <= -1.25e+177:
		tmp = x + (z * (t - (y * t_1)))
	elif y <= -1.45e+112:
		tmp = x + ((y * z) * t_2)
	elif y <= 2.6e+155:
		tmp = x + (y * (z * t_2))
	else:
		tmp = x + (z * (t - x))
	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(tanh(Float64(t / y)) - t_1)
	tmp = 0.0
	if (y <= -1.25e+177)
		tmp = Float64(x + Float64(z * Float64(t - Float64(y * t_1))));
	elseif (y <= -1.45e+112)
		tmp = Float64(x + Float64(Float64(y * z) * t_2));
	elseif (y <= 2.6e+155)
		tmp = Float64(x + Float64(y * Float64(z * t_2)));
	else
		tmp = Float64(x + Float64(z * Float64(t - x)));
	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 = tanh((t / y)) - t_1;
	tmp = 0.0;
	if (y <= -1.25e+177)
		tmp = x + (z * (t - (y * t_1)));
	elseif (y <= -1.45e+112)
		tmp = x + ((y * z) * t_2);
	elseif (y <= 2.6e+155)
		tmp = x + (y * (z * t_2));
	else
		tmp = x + (z * (t - x));
	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[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - t$95$1), $MachinePrecision]}, If[LessEqual[y, -1.25e+177], N[(x + N[(z * N[(t - N[(y * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.45e+112], N[(x + N[(N[(y * z), $MachinePrecision] * t$95$2), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.6e+155], N[(x + N[(y * N[(z * t$95$2), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $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{x}{y}\right)\\
t_2 := \tanh \left(\frac{t}{y}\right) - t_1\\
\mathbf{if}\;y \leq -1.25 \cdot 10^{+177}:\\
\;\;\;\;x + z \cdot \left(t - y \cdot t_1\right)\\

\mathbf{elif}\;y \leq -1.45 \cdot 10^{+112}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot t_2\\

\mathbf{elif}\;y \leq 2.6 \cdot 10^{+155}:\\
\;\;\;\;x + y \cdot \left(z \cdot t_2\right)\\

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


\end{array}

Error?

Try it out?

Your Program's Arguments

Results

Enter valid numbers for all inputs

Target

Original92.7%
Target97.3%
Herbie97.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 4 regimes
  2. if y < -1.2500000000000001e177

    1. Initial program 69.3%

      \[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 t around 0 64.4%

      \[\leadsto x + \left(y \cdot z\right) \cdot \left(\color{blue}{\frac{t}{y}} - \tanh \left(\frac{x}{y}\right)\right) \]
    3. Taylor expanded in t around -inf 68.1%

      \[\leadsto x + \color{blue}{\left(-1 \cdot \left(y \cdot \left(z \cdot \left(\frac{e^{\frac{x}{y}}}{e^{\frac{x}{y}} + \frac{1}{e^{\frac{x}{y}}}} - \frac{1}{e^{\frac{x}{y}} \cdot \left(e^{\frac{x}{y}} + \frac{1}{e^{\frac{x}{y}}}\right)}\right)\right)\right) + t \cdot z\right)} \]
    4. Simplified91.5%

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

      [Start]68.1

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

      +-commutative [=>]68.1

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

      mul-1-neg [=>]68.1

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

      associate-*r* [=>]53.2

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

      associate-/r* [=>]53.2

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

    if -1.2500000000000001e177 < y < -1.4500000000000001e112

    1. Initial program 85.4%

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

    if -1.4500000000000001e112 < y < 2.6000000000000002e155

    1. Initial program 98.5%

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

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

      [Start]98.5

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

      associate-*l* [=>]99.6

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

    if 2.6000000000000002e155 < y

    1. Initial program 74.6%

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

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

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

      +-commutative [=>]74.6

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

      *-commutative [=>]74.6

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

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

      \[ \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 90.5%

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

    \[\leadsto \begin{array}{l} \mathbf{if}\;y \leq -1.25 \cdot 10^{+177}:\\ \;\;\;\;x + z \cdot \left(t - y \cdot \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{elif}\;y \leq -1.45 \cdot 10^{+112}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{elif}\;y \leq 2.6 \cdot 10^{+155}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]

Alternatives

Alternative 1
Accuracy98.9%
Cost33604
\[\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 10^{+306}:\\ \;\;\;\;\mathsf{fma}\left(z, y \cdot t_1, x\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 2
Accuracy97.4%
Cost13764
\[\begin{array}{l} \mathbf{if}\;y \leq 2.6 \cdot 10^{+155}:\\ \;\;\;\;x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 3
Accuracy74.9%
Cost7903
\[\begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{+97}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -1.52 \cdot 10^{+65} \lor \neg \left(z \leq 3.8 \cdot 10^{+81} \lor \neg \left(z \leq 2.5 \cdot 10^{+98}\right) \land \left(z \leq 5.3 \cdot 10^{+126} \lor \neg \left(z \leq 2.85 \cdot 10^{+166}\right) \land z \leq 5.6 \cdot 10^{+197}\right)\right):\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right)\\ \end{array} \]
Alternative 4
Accuracy83.7%
Cost7504
\[\begin{array}{l} t_1 := x + \left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right)\\ \mathbf{if}\;y \leq -2.95 \cdot 10^{+150}:\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-147}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 2.3 \cdot 10^{-18}:\\ \;\;\;\;x - \left(y \cdot z\right) \cdot \tanh \left(\frac{x}{y}\right)\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{+153}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 5
Accuracy87.4%
Cost7369
\[\begin{array}{l} \mathbf{if}\;t \leq -8.2 \cdot 10^{-77} \lor \neg \left(t \leq 8.5 \cdot 10^{+26}\right):\\ \;\;\;\;x + \left(y \cdot z\right) \cdot \tanh \left(\frac{t}{y}\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - y \cdot \tanh \left(\frac{x}{y}\right)\right)\\ \end{array} \]
Alternative 6
Accuracy76.4%
Cost6852
\[\begin{array}{l} \mathbf{if}\;y \leq -1.6 \cdot 10^{+30}:\\ \;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\ \mathbf{elif}\;y \leq 2.9 \cdot 10^{+58}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 7
Accuracy67.7%
Cost1112
\[\begin{array}{l} t_1 := x + z \cdot t\\ \mathbf{if}\;x \leq -2.35 \cdot 10^{-110}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.5 \cdot 10^{-207}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq -8.2 \cdot 10^{-237}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.12 \cdot 10^{-262}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{elif}\;x \leq 4 \cdot 10^{-140}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;x \leq 6.6 \cdot 10^{-28}:\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 8
Accuracy63.0%
Cost982
\[\begin{array}{l} \mathbf{if}\;z \leq -3.5 \cdot 10^{+97}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq -7 \cdot 10^{+61} \lor \neg \left(z \leq 5.6 \cdot 10^{+81} \lor \neg \left(z \leq 1.32 \cdot 10^{+166}\right) \land z \leq 2.5 \cdot 10^{+196}\right):\\ \;\;\;\;z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 9
Accuracy61.7%
Cost720
\[\begin{array}{l} \mathbf{if}\;z \leq 1.5 \cdot 10^{+82}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 6.2 \cdot 10^{+157}:\\ \;\;\;\;x \cdot \left(-z\right)\\ \mathbf{elif}\;z \leq 8.6 \cdot 10^{+201}:\\ \;\;\;\;x\\ \mathbf{elif}\;z \leq 1.9 \cdot 10^{+288}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Accuracy76.1%
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -4.5 \cdot 10^{+16} \lor \neg \left(y \leq 1.05 \cdot 10^{+64}\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 11
Accuracy67.8%
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -2.25 \cdot 10^{+15} \lor \neg \left(y \leq 6.6 \cdot 10^{+66}\right):\\ \;\;\;\;x \cdot \left(1 - z\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Accuracy64.7%
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -1.85 \cdot 10^{-237}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -1.18 \cdot 10^{-287}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Accuracy64.6%
Cost64
\[x \]

Error

Reproduce?

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