?

Average Error: 4.5 → 2.0
Time: 16.3s
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 -1.16 \cdot 10^{+136}:\\ \;\;\;\;x + \left(z \cdot \left(y \cdot t_1\right) - z \cdot x\right)\\ \mathbf{elif}\;y \leq 8.5 \cdot 10^{+170}:\\ \;\;\;\;x + \left(t_1 - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\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 (/ t y))))
   (if (<= y -1.16e+136)
     (+ x (- (* z (* y t_1)) (* z x)))
     (if (<= y 8.5e+170)
       (+ x (* (- t_1 (tanh (/ x y))) (* z y)))
       (+ 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((t / y));
	double tmp;
	if (y <= -1.16e+136) {
		tmp = x + ((z * (y * t_1)) - (z * x));
	} else if (y <= 8.5e+170) {
		tmp = x + ((t_1 - tanh((x / y))) * (z * y));
	} 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) :: tmp
    t_1 = tanh((t / y))
    if (y <= (-1.16d+136)) then
        tmp = x + ((z * (y * t_1)) - (z * x))
    else if (y <= 8.5d+170) then
        tmp = x + ((t_1 - tanh((x / y))) * (z * y))
    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((t / y));
	double tmp;
	if (y <= -1.16e+136) {
		tmp = x + ((z * (y * t_1)) - (z * x));
	} else if (y <= 8.5e+170) {
		tmp = x + ((t_1 - Math.tanh((x / y))) * (z * y));
	} 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((t / y))
	tmp = 0
	if y <= -1.16e+136:
		tmp = x + ((z * (y * t_1)) - (z * x))
	elif y <= 8.5e+170:
		tmp = x + ((t_1 - math.tanh((x / y))) * (z * y))
	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(t / y))
	tmp = 0.0
	if (y <= -1.16e+136)
		tmp = Float64(x + Float64(Float64(z * Float64(y * t_1)) - Float64(z * x)));
	elseif (y <= 8.5e+170)
		tmp = Float64(x + Float64(Float64(t_1 - tanh(Float64(x / y))) * Float64(z * y)));
	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((t / y));
	tmp = 0.0;
	if (y <= -1.16e+136)
		tmp = x + ((z * (y * t_1)) - (z * x));
	elseif (y <= 8.5e+170)
		tmp = x + ((t_1 - tanh((x / y))) * (z * y));
	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[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, -1.16e+136], N[(x + N[(N[(z * N[(y * t$95$1), $MachinePrecision]), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.5e+170], N[(x + N[(N[(t$95$1 - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(z * y), $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{t}{y}\right)\\
\mathbf{if}\;y \leq -1.16 \cdot 10^{+136}:\\
\;\;\;\;x + \left(z \cdot \left(y \cdot t_1\right) - z \cdot x\right)\\

\mathbf{elif}\;y \leq 8.5 \cdot 10^{+170}:\\
\;\;\;\;x + \left(t_1 - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(z \cdot y\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

Original4.5
Target2.0
Herbie2.0
\[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 < -1.1599999999999999e136

    1. Initial program 14.9

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

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

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

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

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

      [Start]26.9

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

      mul-1-neg [=>]26.9

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

      unsub-neg [=>]26.9

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

    if -1.1599999999999999e136 < y < 8.5000000000000004e170

    1. Initial program 1.3

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

    if 8.5000000000000004e170 < y

    1. Initial program 17.6

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

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

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

      +-commutative [=>]17.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 [=>]17.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* [=>]6.1

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

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

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

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

Alternatives

Alternative 1
Error1.4
Cost19904
\[\mathsf{fma}\left(z, y \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right) \]
Alternative 2
Error2.0
Cost13632
\[x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right) \]
Alternative 3
Error8.4
Cost7760
\[\begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right)\\ t_2 := x + t_1 \cdot \left(z \cdot y\right)\\ t_3 := x + \left(z \cdot \left(y \cdot t_1\right) - z \cdot x\right)\\ \mathbf{if}\;y \leq -3 \cdot 10^{+63}:\\ \;\;\;\;t_3\\ \mathbf{elif}\;y \leq -1.9 \cdot 10^{-243}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq 2.2 \cdot 10^{-147}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.1 \cdot 10^{-22}:\\ \;\;\;\;t_2\\ \mathbf{else}:\\ \;\;\;\;t_3\\ \end{array} \]
Alternative 4
Error9.5
Cost7504
\[\begin{array}{l} t_1 := x + \tanh \left(\frac{t}{y}\right) \cdot \left(z \cdot y\right)\\ t_2 := x + z \cdot \left(t - x\right)\\ \mathbf{if}\;y \leq -1.25 \cdot 10^{+178}:\\ \;\;\;\;t_2\\ \mathbf{elif}\;y \leq -4.1 \cdot 10^{-242}:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 5.6 \cdot 10^{-149}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 9 \cdot 10^{+168}:\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;t_2\\ \end{array} \]
Alternative 5
Error10.5
Cost7372
\[\begin{array}{l} t_1 := \tanh \left(\frac{t}{y}\right)\\ \mathbf{if}\;y \leq -4.1 \cdot 10^{-243}:\\ \;\;\;\;x + y \cdot \left(z \cdot t_1\right)\\ \mathbf{elif}\;y \leq 8 \cdot 10^{-146}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 2.05 \cdot 10^{+169}:\\ \;\;\;\;x + t_1 \cdot \left(z \cdot y\right)\\ \mathbf{else}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 6
Error9.5
Cost7241
\[\begin{array}{l} \mathbf{if}\;x \leq -1.25 \cdot 10^{-29} \lor \neg \left(x \leq 1.4 \cdot 10^{-12}\right):\\ \;\;\;\;x - y \cdot \left(z \cdot \tanh \left(\frac{x}{y}\right)\right)\\ \mathbf{else}:\\ \;\;\;\;x + y \cdot \left(z \cdot \tanh \left(\frac{t}{y}\right)\right)\\ \end{array} \]
Alternative 7
Error18.4
Cost849
\[\begin{array}{l} t_1 := x + z \cdot t\\ \mathbf{if}\;y \leq -0.2:\\ \;\;\;\;t_1\\ \mathbf{elif}\;y \leq 7 \cdot 10^{-9}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.65 \cdot 10^{+233} \lor \neg \left(y \leq 3.7 \cdot 10^{+278}\right):\\ \;\;\;\;t_1\\ \mathbf{else}:\\ \;\;\;\;x - z \cdot x\\ \end{array} \]
Alternative 8
Error15.3
Cost840
\[\begin{array}{l} \mathbf{if}\;y \leq -1.5 \cdot 10^{+63}:\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{elif}\;y \leq 1.15 \cdot 10^{-8}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;x + \left(z \cdot t - z \cdot x\right)\\ \end{array} \]
Alternative 9
Error15.3
Cost713
\[\begin{array}{l} \mathbf{if}\;y \leq -1.36 \cdot 10^{+69} \lor \neg \left(y \leq 1.05 \cdot 10^{-8}\right):\\ \;\;\;\;x + z \cdot \left(t - x\right)\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 10
Error23.7
Cost653
\[\begin{array}{l} \mathbf{if}\;y \leq 5.5 \cdot 10^{+182}:\\ \;\;\;\;x\\ \mathbf{elif}\;y \leq 1.05 \cdot 10^{+236} \lor \neg \left(y \leq 4.2 \cdot 10^{+277}\right):\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x \cdot \left(-z\right)\\ \end{array} \]
Alternative 11
Error18.2
Cost585
\[\begin{array}{l} \mathbf{if}\;y \leq -240 \lor \neg \left(y \leq 1.22 \cdot 10^{-8}\right):\\ \;\;\;\;x + z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 12
Error24.4
Cost456
\[\begin{array}{l} \mathbf{if}\;x \leq -2.05 \cdot 10^{-91}:\\ \;\;\;\;x\\ \mathbf{elif}\;x \leq -2.4 \cdot 10^{-255}:\\ \;\;\;\;z \cdot t\\ \mathbf{else}:\\ \;\;\;\;x\\ \end{array} \]
Alternative 13
Error22.5
Cost452
\[\begin{array}{l} \mathbf{if}\;y \leq 6.2 \cdot 10^{+181}:\\ \;\;\;\;x\\ \mathbf{else}:\\ \;\;\;\;z \cdot \left(t - x\right)\\ \end{array} \]
Alternative 14
Error22.8
Cost64
\[x \]

Error

Reproduce?

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