
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
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
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); 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]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 14 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z t) :precision binary64 (+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))
double code(double x, double y, double z, double t) {
return x + ((y * z) * (tanh((t / y)) - tanh((x / y))));
}
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
public static double code(double x, double y, double z, double t) {
return x + ((y * z) * (Math.tanh((t / y)) - Math.tanh((x / y))));
}
def code(x, y, z, t): return x + ((y * z) * (math.tanh((t / y)) - math.tanh((x / y))))
function code(x, y, z, t) return Float64(x + Float64(Float64(y * z) * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))))) end
function tmp = code(x, y, z, t) tmp = x + ((y * z) * (tanh((t / y)) - tanh((x / y)))); 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]
\begin{array}{l}
\\
x + \left(y \cdot z\right) \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)
\end{array}
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* y z)))))
(if (or (<= t_1 (- INFINITY)) (not (<= t_1 2e+286)))
(+ x (* z (- t x)))
t_1)))
double code(double x, double y, double z, double t) {
double t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z));
double tmp;
if ((t_1 <= -((double) INFINITY)) || !(t_1 <= 2e+286)) {
tmp = x + (z * (t - x));
} else {
tmp = t_1;
}
return tmp;
}
public static double code(double x, double y, double z, double t) {
double t_1 = x + ((Math.tanh((t / y)) - Math.tanh((x / y))) * (y * z));
double tmp;
if ((t_1 <= -Double.POSITIVE_INFINITY) || !(t_1 <= 2e+286)) {
tmp = x + (z * (t - x));
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z, t): t_1 = x + ((math.tanh((t / y)) - math.tanh((x / y))) * (y * z)) tmp = 0 if (t_1 <= -math.inf) or not (t_1 <= 2e+286): tmp = x + (z * (t - x)) else: tmp = t_1 return tmp
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(y * z))) tmp = 0.0 if ((t_1 <= Float64(-Inf)) || !(t_1 <= 2e+286)) tmp = Float64(x + Float64(z * Float64(t - x))); else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (y * z)); tmp = 0.0; if ((t_1 <= -Inf) || ~((t_1 <= 2e+286))) tmp = x + (z * (t - x)); else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = 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[Or[LessEqual[t$95$1, (-Infinity)], N[Not[LessEqual[t$95$1, 2e+286]], $MachinePrecision]], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$1]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := x + \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right) \cdot \left(y \cdot z\right)\\
\mathbf{if}\;t\_1 \leq -\infty \lor \neg \left(t\_1 \leq 2 \cdot 10^{+286}\right):\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0 or 2.00000000000000007e286 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 54.4%
Taylor expanded in y around inf 100.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.00000000000000007e286Initial program 98.8%
Final simplification98.9%
(FPCore (x y z t) :precision binary64 (fma y (* z (- (tanh (/ t y)) (tanh (/ x y)))) x))
double code(double x, double y, double z, double t) {
return fma(y, (z * (tanh((t / y)) - tanh((x / y)))), x);
}
function code(x, y, z, t) return fma(y, Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), x) end
code[x_, y_, z_, t_] := N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(y, z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), x\right)
\end{array}
Initial program 93.8%
+-commutative93.8%
associate-*l*98.4%
fma-define98.4%
Simplified98.4%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= t -3.8e-109)
(fma y (* z t_1) x)
(if (<= t 4e-86)
(fma y (* z (- (/ t y) (tanh (/ x y)))) x)
(+ x (* t_1 (* y z)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (t <= -3.8e-109) {
tmp = fma(y, (z * t_1), x);
} else if (t <= 4e-86) {
tmp = fma(y, (z * ((t / y) - tanh((x / y)))), x);
} else {
tmp = x + (t_1 * (y * z));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (t <= -3.8e-109) tmp = fma(y, Float64(z * t_1), x); elseif (t <= 4e-86) tmp = fma(y, Float64(z * Float64(Float64(t / y) - tanh(Float64(x / y)))), x); else tmp = Float64(x + Float64(t_1 * Float64(y * z))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -3.8e-109], N[(y * N[(z * t$95$1), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 4e-86], N[(y * N[(z * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;t \leq -3.8 \cdot 10^{-109}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot t\_1, x\right)\\
\mathbf{elif}\;t \leq 4 \cdot 10^{-86}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), x\right)\\
\mathbf{else}:\\
\;\;\;\;x + t\_1 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if t < -3.80000000000000002e-109Initial program 92.5%
+-commutative92.5%
associate-*l*98.6%
fma-define98.6%
Simplified98.6%
Taylor expanded in x around 0 10.0%
associate-/r*10.0%
div-sub10.0%
rec-exp10.0%
rec-exp10.0%
tanh-def-a83.5%
Simplified83.5%
if -3.80000000000000002e-109 < t < 4.00000000000000034e-86Initial program 90.4%
+-commutative90.4%
associate-*l*98.7%
fma-define98.7%
Simplified98.7%
Taylor expanded in t around 0 92.6%
if 4.00000000000000034e-86 < t Initial program 98.2%
Taylor expanded in x around 0 18.1%
associate-*r*18.0%
associate-/r*18.0%
div-sub18.1%
rec-exp18.1%
rec-exp18.1%
tanh-def-a93.5%
Simplified93.5%
Final simplification90.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= t -6.6e-109)
(fma y (* z t_1) x)
(if (<= t 4.8e-86)
(+ x (* y (* z (- (/ t y) (tanh (/ x y))))))
(+ x (* t_1 (* y z)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (t <= -6.6e-109) {
tmp = fma(y, (z * t_1), x);
} else if (t <= 4.8e-86) {
tmp = x + (y * (z * ((t / y) - tanh((x / y)))));
} else {
tmp = x + (t_1 * (y * z));
}
return tmp;
}
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (t <= -6.6e-109) tmp = fma(y, Float64(z * t_1), x); elseif (t <= 4.8e-86) tmp = Float64(x + Float64(y * Float64(z * Float64(Float64(t / y) - tanh(Float64(x / y)))))); else tmp = Float64(x + Float64(t_1 * Float64(y * z))); end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -6.6e-109], N[(y * N[(z * t$95$1), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[t, 4.8e-86], N[(x + N[(y * N[(z * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;t \leq -6.6 \cdot 10^{-109}:\\
\;\;\;\;\mathsf{fma}\left(y, z \cdot t\_1, x\right)\\
\mathbf{elif}\;t \leq 4.8 \cdot 10^{-86}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + t\_1 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if t < -6.59999999999999981e-109Initial program 92.5%
+-commutative92.5%
associate-*l*98.6%
fma-define98.6%
Simplified98.6%
Taylor expanded in x around 0 10.0%
associate-/r*10.0%
div-sub10.0%
rec-exp10.0%
rec-exp10.0%
tanh-def-a83.5%
Simplified83.5%
if -6.59999999999999981e-109 < t < 4.80000000000000026e-86Initial program 90.4%
+-commutative90.4%
associate-*l*98.7%
fma-define98.7%
Simplified98.7%
Taylor expanded in t around 0 92.6%
fma-undefine92.6%
Applied egg-rr92.6%
if 4.80000000000000026e-86 < t Initial program 98.2%
Taylor expanded in x around 0 18.1%
associate-*r*18.0%
associate-/r*18.0%
div-sub18.1%
rec-exp18.1%
rec-exp18.1%
tanh-def-a93.5%
Simplified93.5%
Final simplification90.3%
(FPCore (x y z t) :precision binary64 (if (or (<= t -2.1e-90) (not (<= t 1.1e-85))) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* y (* z (- (/ t y) (tanh (/ x y))))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.1e-90) || !(t <= 1.1e-85)) {
tmp = x + (tanh((t / y)) * (y * z));
} else {
tmp = x + (y * (z * ((t / y) - tanh((x / y)))));
}
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
real(8) :: tmp
if ((t <= (-2.1d-90)) .or. (.not. (t <= 1.1d-85))) then
tmp = x + (tanh((t / y)) * (y * z))
else
tmp = x + (y * (z * ((t / y) - tanh((x / y)))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -2.1e-90) || !(t <= 1.1e-85)) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = x + (y * (z * ((t / y) - Math.tanh((x / y)))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -2.1e-90) or not (t <= 1.1e-85): tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = x + (y * (z * ((t / y) - math.tanh((x / y))))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -2.1e-90) || !(t <= 1.1e-85)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = Float64(x + Float64(y * Float64(z * Float64(Float64(t / y) - tanh(Float64(x / y)))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -2.1e-90) || ~((t <= 1.1e-85))) tmp = x + (tanh((t / y)) * (y * z)); else tmp = x + (y * (z * ((t / y) - tanh((x / y))))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -2.1e-90], N[Not[LessEqual[t, 1.1e-85]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(y * N[(z * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -2.1 \cdot 10^{-90} \lor \neg \left(t \leq 1.1 \cdot 10^{-85}\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\end{array}
\end{array}
if t < -2.0999999999999999e-90 or 1.1e-85 < t Initial program 96.1%
Taylor expanded in x around 0 14.7%
associate-*r*14.5%
associate-/r*14.5%
div-sub14.5%
rec-exp14.5%
rec-exp14.5%
tanh-def-a87.5%
Simplified87.5%
if -2.0999999999999999e-90 < t < 1.1e-85Initial program 89.7%
+-commutative89.7%
associate-*l*98.7%
fma-define98.7%
Simplified98.7%
Taylor expanded in t around 0 91.8%
fma-undefine91.8%
Applied egg-rr91.8%
Final simplification89.1%
(FPCore (x y z t) :precision binary64 (if (or (<= t -1.35e-109) (not (<= t 2.15e-87))) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* (* y z) (- (/ t y) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.35e-109) || !(t <= 2.15e-87)) {
tmp = x + (tanh((t / y)) * (y * z));
} else {
tmp = x + ((y * z) * ((t / y) - tanh((x / y))));
}
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
real(8) :: tmp
if ((t <= (-1.35d-109)) .or. (.not. (t <= 2.15d-87))) then
tmp = x + (tanh((t / y)) * (y * z))
else
tmp = x + ((y * z) * ((t / y) - tanh((x / y))))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if ((t <= -1.35e-109) || !(t <= 2.15e-87)) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = x + ((y * z) * ((t / y) - Math.tanh((x / y))));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if (t <= -1.35e-109) or not (t <= 2.15e-87): tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = x + ((y * z) * ((t / y) - math.tanh((x / y)))) return tmp
function code(x, y, z, t) tmp = 0.0 if ((t <= -1.35e-109) || !(t <= 2.15e-87)) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = Float64(x + Float64(Float64(y * z) * Float64(Float64(t / y) - tanh(Float64(x / y))))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if ((t <= -1.35e-109) || ~((t <= 2.15e-87))) tmp = x + (tanh((t / y)) * (y * z)); else tmp = x + ((y * z) * ((t / y) - tanh((x / y)))); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[Or[LessEqual[t, -1.35e-109], N[Not[LessEqual[t, 2.15e-87]], $MachinePrecision]], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(N[(y * z), $MachinePrecision] * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;t \leq -1.35 \cdot 10^{-109} \lor \neg \left(t \leq 2.15 \cdot 10^{-87}\right):\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\\
\end{array}
\end{array}
if t < -1.35e-109 or 2.14999999999999998e-87 < t Initial program 95.0%
Taylor expanded in x around 0 14.4%
associate-*r*14.2%
associate-/r*14.2%
div-sub14.2%
rec-exp14.2%
rec-exp14.2%
tanh-def-a86.6%
Simplified86.6%
if -1.35e-109 < t < 2.14999999999999998e-87Initial program 91.4%
Taylor expanded in t around 0 85.2%
Final simplification86.1%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= t -6.5e-109)
(* x (+ 1.0 (/ 1.0 (/ x (* y (* z t_1))))))
(if (<= t 4.3e-86)
(+ x (* y (* z (- (/ t y) (tanh (/ x y))))))
(+ x (* t_1 (* y z)))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (t <= -6.5e-109) {
tmp = x * (1.0 + (1.0 / (x / (y * (z * t_1)))));
} else if (t <= 4.3e-86) {
tmp = x + (y * (z * ((t / y) - tanh((x / y)))));
} else {
tmp = x + (t_1 * (y * 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
real(8) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (t <= (-6.5d-109)) then
tmp = x * (1.0d0 + (1.0d0 / (x / (y * (z * t_1)))))
else if (t <= 4.3d-86) then
tmp = x + (y * (z * ((t / y) - tanh((x / y)))))
else
tmp = x + (t_1 * (y * z))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (t <= -6.5e-109) {
tmp = x * (1.0 + (1.0 / (x / (y * (z * t_1)))));
} else if (t <= 4.3e-86) {
tmp = x + (y * (z * ((t / y) - Math.tanh((x / y)))));
} else {
tmp = x + (t_1 * (y * z));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if t <= -6.5e-109: tmp = x * (1.0 + (1.0 / (x / (y * (z * t_1))))) elif t <= 4.3e-86: tmp = x + (y * (z * ((t / y) - math.tanh((x / y))))) else: tmp = x + (t_1 * (y * z)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (t <= -6.5e-109) tmp = Float64(x * Float64(1.0 + Float64(1.0 / Float64(x / Float64(y * Float64(z * t_1)))))); elseif (t <= 4.3e-86) tmp = Float64(x + Float64(y * Float64(z * Float64(Float64(t / y) - tanh(Float64(x / y)))))); else tmp = Float64(x + Float64(t_1 * Float64(y * z))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (t <= -6.5e-109) tmp = x * (1.0 + (1.0 / (x / (y * (z * t_1))))); elseif (t <= 4.3e-86) tmp = x + (y * (z * ((t / y) - tanh((x / y))))); else tmp = x + (t_1 * (y * z)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[t, -6.5e-109], N[(x * N[(1.0 + N[(1.0 / N[(x / N[(y * N[(z * t$95$1), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t, 4.3e-86], N[(x + N[(y * N[(z * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;t \leq -6.5 \cdot 10^{-109}:\\
\;\;\;\;x \cdot \left(1 + \frac{1}{\frac{x}{y \cdot \left(z \cdot t\_1\right)}}\right)\\
\mathbf{elif}\;t \leq 4.3 \cdot 10^{-86}:\\
\;\;\;\;x + y \cdot \left(z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right)\right)\\
\mathbf{else}:\\
\;\;\;\;x + t\_1 \cdot \left(y \cdot z\right)\\
\end{array}
\end{array}
if t < -6.49999999999999959e-109Initial program 92.5%
+-commutative92.5%
associate-*l*98.6%
fma-define98.6%
Simplified98.6%
Taylor expanded in x around 0 10.0%
associate-/r*10.0%
div-sub10.0%
rec-exp10.0%
rec-exp10.0%
tanh-def-a83.5%
Simplified83.5%
Taylor expanded in x around inf 10.0%
times-frac8.3%
associate-/l*8.3%
rec-exp8.3%
rec-exp8.3%
tanh-def-a73.2%
Simplified73.2%
associate-*l/81.0%
clear-num80.9%
Applied egg-rr80.9%
if -6.49999999999999959e-109 < t < 4.30000000000000013e-86Initial program 90.4%
+-commutative90.4%
associate-*l*98.7%
fma-define98.7%
Simplified98.7%
Taylor expanded in t around 0 92.6%
fma-undefine92.6%
Applied egg-rr92.6%
if 4.30000000000000013e-86 < t Initial program 98.2%
Taylor expanded in x around 0 18.1%
associate-*r*18.0%
associate-/r*18.0%
div-sub18.1%
rec-exp18.1%
rec-exp18.1%
tanh-def-a93.5%
Simplified93.5%
Final simplification89.5%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (tanh (/ t y))))
(if (<= y 4.5e+56)
(+ x (* t_1 (* y z)))
(if (<= y 5.6e+180)
(+ x (* (* y z) (- t_1 (/ x y))))
(if (<= y 2.25e+193) (+ x (* z t)) (+ x (* z (- t x))))))))
double code(double x, double y, double z, double t) {
double t_1 = tanh((t / y));
double tmp;
if (y <= 4.5e+56) {
tmp = x + (t_1 * (y * z));
} else if (y <= 5.6e+180) {
tmp = x + ((y * z) * (t_1 - (x / y)));
} else if (y <= 2.25e+193) {
tmp = x + (z * t);
} 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
real(8) :: t_1
real(8) :: tmp
t_1 = tanh((t / y))
if (y <= 4.5d+56) then
tmp = x + (t_1 * (y * z))
else if (y <= 5.6d+180) then
tmp = x + ((y * z) * (t_1 - (x / y)))
else if (y <= 2.25d+193) then
tmp = x + (z * t)
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double t_1 = Math.tanh((t / y));
double tmp;
if (y <= 4.5e+56) {
tmp = x + (t_1 * (y * z));
} else if (y <= 5.6e+180) {
tmp = x + ((y * z) * (t_1 - (x / y)));
} else if (y <= 2.25e+193) {
tmp = x + (z * t);
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): t_1 = math.tanh((t / y)) tmp = 0 if y <= 4.5e+56: tmp = x + (t_1 * (y * z)) elif y <= 5.6e+180: tmp = x + ((y * z) * (t_1 - (x / y))) elif y <= 2.25e+193: tmp = x + (z * t) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) t_1 = tanh(Float64(t / y)) tmp = 0.0 if (y <= 4.5e+56) tmp = Float64(x + Float64(t_1 * Float64(y * z))); elseif (y <= 5.6e+180) tmp = Float64(x + Float64(Float64(y * z) * Float64(t_1 - Float64(x / y)))); elseif (y <= 2.25e+193) tmp = Float64(x + Float64(z * t)); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) t_1 = tanh((t / y)); tmp = 0.0; if (y <= 4.5e+56) tmp = x + (t_1 * (y * z)); elseif (y <= 5.6e+180) tmp = x + ((y * z) * (t_1 - (x / y))); elseif (y <= 2.25e+193) tmp = x + (z * t); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]}, If[LessEqual[y, 4.5e+56], N[(x + N[(t$95$1 * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.6e+180], N[(x + N[(N[(y * z), $MachinePrecision] * N[(t$95$1 - N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.25e+193], N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \tanh \left(\frac{t}{y}\right)\\
\mathbf{if}\;y \leq 4.5 \cdot 10^{+56}:\\
\;\;\;\;x + t\_1 \cdot \left(y \cdot z\right)\\
\mathbf{elif}\;y \leq 5.6 \cdot 10^{+180}:\\
\;\;\;\;x + \left(y \cdot z\right) \cdot \left(t\_1 - \frac{x}{y}\right)\\
\mathbf{elif}\;y \leq 2.25 \cdot 10^{+193}:\\
\;\;\;\;x + z \cdot t\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 4.5000000000000003e56Initial program 94.6%
Taylor expanded in x around 0 20.3%
associate-*r*20.1%
associate-/r*20.1%
div-sub20.1%
rec-exp20.1%
rec-exp20.1%
tanh-def-a79.5%
Simplified79.5%
if 4.5000000000000003e56 < y < 5.60000000000000024e180Initial program 94.7%
Taylor expanded in x around 0 79.7%
if 5.60000000000000024e180 < y < 2.25e193Initial program 85.7%
+-commutative85.7%
associate-*l*86.0%
fma-define86.0%
Simplified86.0%
Taylor expanded in x around 0 57.6%
associate-/r*57.6%
div-sub57.6%
rec-exp57.6%
rec-exp57.6%
tanh-def-a86.0%
Simplified86.0%
Taylor expanded in y around inf 86.5%
+-commutative86.5%
*-commutative86.5%
Simplified86.5%
if 2.25e193 < y Initial program 87.3%
Taylor expanded in y around inf 91.3%
Final simplification80.7%
(FPCore (x y z t) :precision binary64 (if (<= y 1.3e+110) (+ x (* (tanh (/ t y)) (* y z))) (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.3e+110) {
tmp = x + (tanh((t / y)) * (y * z));
} 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
real(8) :: tmp
if (y <= 1.3d+110) then
tmp = x + (tanh((t / y)) * (y * z))
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 1.3e+110) {
tmp = x + (Math.tanh((t / y)) * (y * z));
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 1.3e+110: tmp = x + (math.tanh((t / y)) * (y * z)) else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 1.3e+110) tmp = Float64(x + Float64(tanh(Float64(t / y)) * Float64(y * z))); else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 1.3e+110) tmp = x + (tanh((t / y)) * (y * z)); else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 1.3e+110], N[(x + N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] * N[(y * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.3 \cdot 10^{+110}:\\
\;\;\;\;x + \tanh \left(\frac{t}{y}\right) \cdot \left(y \cdot z\right)\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 1.3e110Initial program 94.8%
Taylor expanded in x around 0 20.2%
associate-*r*20.0%
associate-/r*20.0%
div-sub20.0%
rec-exp20.0%
rec-exp20.0%
tanh-def-a79.7%
Simplified79.7%
if 1.3e110 < y Initial program 88.6%
Taylor expanded in y around inf 82.6%
Final simplification80.1%
(FPCore (x y z t) :precision binary64 (if (<= y 3.7e+57) x (+ x (* z (- t x)))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.7e+57) {
tmp = x;
} 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
real(8) :: tmp
if (y <= 3.7d+57) then
tmp = x
else
tmp = x + (z * (t - x))
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.7e+57) {
tmp = x;
} else {
tmp = x + (z * (t - x));
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.7e+57: tmp = x else: tmp = x + (z * (t - x)) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.7e+57) tmp = x; else tmp = Float64(x + Float64(z * Float64(t - x))); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.7e+57) tmp = x; else tmp = x + (z * (t - x)); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.7e+57], x, N[(x + N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.7 \cdot 10^{+57}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot \left(t - x\right)\\
\end{array}
\end{array}
if y < 3.70000000000000006e57Initial program 94.6%
Taylor expanded in x around inf 62.1%
if 3.70000000000000006e57 < y Initial program 90.0%
Taylor expanded in y around inf 75.1%
(FPCore (x y z t) :precision binary64 (if (<= y 3.3e+55) x (+ x (* z t))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.3e+55) {
tmp = x;
} else {
tmp = x + (z * t);
}
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
real(8) :: tmp
if (y <= 3.3d+55) then
tmp = x
else
tmp = x + (z * t)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3.3e+55) {
tmp = x;
} else {
tmp = x + (z * t);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 3.3e+55: tmp = x else: tmp = x + (z * t) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 3.3e+55) tmp = x; else tmp = Float64(x + Float64(z * t)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 3.3e+55) tmp = x; else tmp = x + (z * t); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 3.3e+55], x, N[(x + N[(z * t), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.3 \cdot 10^{+55}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x + z \cdot t\\
\end{array}
\end{array}
if y < 3.3e55Initial program 94.6%
Taylor expanded in x around inf 62.1%
if 3.3e55 < y Initial program 90.0%
+-commutative90.0%
associate-*l*97.8%
fma-define97.8%
Simplified97.8%
Taylor expanded in x around 0 42.6%
associate-/r*42.6%
div-sub42.6%
rec-exp42.6%
rec-exp42.6%
tanh-def-a80.1%
Simplified80.1%
Taylor expanded in y around inf 66.2%
+-commutative66.2%
*-commutative66.2%
Simplified66.2%
Final simplification62.9%
(FPCore (x y z t) :precision binary64 (if (<= y 2.3e+55) x (* x (- 1.0 z))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.3e+55) {
tmp = x;
} else {
tmp = x * (1.0 - 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
real(8) :: tmp
if (y <= 2.3d+55) then
tmp = x
else
tmp = x * (1.0d0 - z)
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.3e+55) {
tmp = x;
} else {
tmp = x * (1.0 - z);
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if y <= 2.3e+55: tmp = x else: tmp = x * (1.0 - z) return tmp
function code(x, y, z, t) tmp = 0.0 if (y <= 2.3e+55) tmp = x; else tmp = Float64(x * Float64(1.0 - z)); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (y <= 2.3e+55) tmp = x; else tmp = x * (1.0 - z); end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.3e+55], x, N[(x * N[(1.0 - z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.3 \cdot 10^{+55}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(1 - z\right)\\
\end{array}
\end{array}
if y < 2.29999999999999987e55Initial program 94.6%
Taylor expanded in x around inf 62.1%
if 2.29999999999999987e55 < y Initial program 90.0%
Taylor expanded in y around inf 65.1%
Taylor expanded in x around inf 58.3%
mul-1-neg58.3%
unsub-neg58.3%
Simplified58.3%
(FPCore (x y z t) :precision binary64 (if (<= z -4.6e+204) (* z (- x)) x))
double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.6e+204) {
tmp = z * -x;
} else {
tmp = 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
real(8) :: tmp
if (z <= (-4.6d+204)) then
tmp = z * -x
else
tmp = x
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (z <= -4.6e+204) {
tmp = z * -x;
} else {
tmp = x;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if z <= -4.6e+204: tmp = z * -x else: tmp = x return tmp
function code(x, y, z, t) tmp = 0.0 if (z <= -4.6e+204) tmp = Float64(z * Float64(-x)); else tmp = x; end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (z <= -4.6e+204) tmp = z * -x; else tmp = x; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[z, -4.6e+204], N[(z * (-x)), $MachinePrecision], x]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.6 \cdot 10^{+204}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;x\\
\end{array}
\end{array}
if z < -4.59999999999999981e204Initial program 81.2%
Taylor expanded in y around inf 50.7%
Taylor expanded in x around inf 50.0%
mul-1-neg50.0%
unsub-neg50.0%
Simplified50.0%
Taylor expanded in z around inf 50.0%
associate-*r*50.0%
mul-1-neg50.0%
Simplified50.0%
if -4.59999999999999981e204 < z Initial program 95.1%
Taylor expanded in x around inf 63.7%
Final simplification62.4%
(FPCore (x y z t) :precision binary64 x)
double code(double x, double y, double z, double t) {
return x;
}
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
end function
public static double code(double x, double y, double z, double t) {
return x;
}
def code(x, y, z, t): return x
function code(x, y, z, t) return x end
function tmp = code(x, y, z, t) tmp = x; end
code[x_, y_, z_, t_] := x
\begin{array}{l}
\\
x
\end{array}
Initial program 93.8%
Taylor expanded in x around inf 60.1%
(FPCore (x y z t) :precision binary64 (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
double code(double x, double y, double z, double t) {
return x + (y * (z * (tanh((t / y)) - tanh((x / y)))));
}
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
public static double code(double x, double y, double z, double t) {
return x + (y * (z * (Math.tanh((t / y)) - Math.tanh((x / y)))));
}
def code(x, y, z, t): return x + (y * (z * (math.tanh((t / y)) - math.tanh((x / y)))))
function code(x, y, z, t) return Float64(x + Float64(y * Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))))) end
function tmp = code(x, y, z, t) tmp = x + (y * (z * (tanh((t / y)) - tanh((x / y))))); end
code[x_, y_, z_, t_] := N[(x + N[(y * N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
x + y \cdot \left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right)\right)
\end{array}
herbie shell --seed 2024110
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))