
(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 9 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}
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.4e+227) (fma (fma (tanh (/ t y_m)) y_m (* (tanh (/ x y_m)) (- y_m))) z x) (fma z (- t x) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.4e+227) {
tmp = fma(fma(tanh((t / y_m)), y_m, (tanh((x / y_m)) * -y_m)), z, x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1.4e+227) tmp = fma(fma(tanh(Float64(t / y_m)), y_m, Float64(tanh(Float64(x / y_m)) * Float64(-y_m))), z, x); else tmp = fma(z, Float64(t - x), x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 1.4e+227], N[(N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] * y$95$m + N[(N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision] * (-y$95$m)), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.4 \cdot 10^{+227}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\tanh \left(\frac{t}{y\_m}\right), y\_m, \tanh \left(\frac{x}{y\_m}\right) \cdot \left(-y\_m\right)\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 1.39999999999999992e227Initial program 92.3%
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6497.2
Applied egg-rr97.2%
*-commutativeN/A
sub-negN/A
distribute-rgt-inN/A
accelerator-lowering-fma.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6497.2
Applied egg-rr97.2%
if 1.39999999999999992e227 < y Initial program 56.7%
Taylor expanded in y around inf
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6491.2
Simplified91.2%
Final simplification96.8%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (* z (- t x)))
(t_2 (+ x (* (- (tanh (/ t y_m)) (tanh (/ x y_m))) (* y_m z)))))
(if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 1e+307) x t_1))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = z * (t - x);
double t_2 = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 1e+307) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double t_1 = z * (t - x);
double t_2 = x + ((Math.tanh((t / y_m)) - Math.tanh((x / y_m))) * (y_m * z));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 1e+307) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): t_1 = z * (t - x) t_2 = x + ((math.tanh((t / y_m)) - math.tanh((x / y_m))) * (y_m * z)) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 1e+307: tmp = x else: tmp = t_1 return tmp
y_m = abs(y) function code(x, y_m, z, t) t_1 = Float64(z * Float64(t - x)) t_2 = Float64(x + Float64(Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))) * Float64(y_m * z))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 1e+307) tmp = x; else tmp = t_1; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) t_1 = z * (t - x); t_2 = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z)); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 1e+307) tmp = x; else tmp = t_1; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, 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$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 1e+307], x, t$95$1]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := z \cdot \left(t - x\right)\\
t_2 := x + \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right) \cdot \left(y\_m \cdot z\right)\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+307}:\\
\;\;\;\;x\\
\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 9.99999999999999986e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 32.2%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6432.5
Simplified32.5%
Taylor expanded in z around inf
remove-double-negN/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
*-lowering-*.f64N/A
mul-1-negN/A
distribute-lft-out--N/A
mul-1-negN/A
remove-double-negN/A
--lowering--.f6494.9
Simplified94.9%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 9.99999999999999986e306Initial program 99.2%
Taylor expanded in x around inf
Simplified66.9%
Final simplification70.9%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (- (* x z)))
(t_2 (+ x (* (- (tanh (/ t y_m)) (tanh (/ x y_m))) (* y_m z)))))
(if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 1e+307) x t_1))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = -(x * z);
double t_2 = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z));
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 1e+307) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double t_1 = -(x * z);
double t_2 = x + ((Math.tanh((t / y_m)) - Math.tanh((x / y_m))) * (y_m * z));
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 1e+307) {
tmp = x;
} else {
tmp = t_1;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): t_1 = -(x * z) t_2 = x + ((math.tanh((t / y_m)) - math.tanh((x / y_m))) * (y_m * z)) tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 1e+307: tmp = x else: tmp = t_1 return tmp
y_m = abs(y) function code(x, y_m, z, t) t_1 = Float64(-Float64(x * z)) t_2 = Float64(x + Float64(Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m))) * Float64(y_m * z))) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 1e+307) tmp = x; else tmp = t_1; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) t_1 = -(x * z); t_2 = x + ((tanh((t / y_m)) - tanh((x / y_m))) * (y_m * z)); tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 1e+307) tmp = x; else tmp = t_1; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = (-N[(x * z), $MachinePrecision])}, Block[{t$95$2 = N[(x + N[(N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * N[(y$95$m * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 1e+307], x, t$95$1]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := -x \cdot z\\
t_2 := x + \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right) \cdot \left(y\_m \cdot z\right)\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 10^{+307}:\\
\;\;\;\;x\\
\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 9.99999999999999986e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 32.2%
Taylor expanded in x around 0
/-lowering-/.f6432.4
Simplified32.4%
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
/-lowering-/.f6474.4
Applied egg-rr74.4%
Taylor expanded in t around 0
mul-1-negN/A
neg-lowering-neg.f64N/A
/-lowering-/.f6459.1
Simplified59.1%
Taylor expanded in z around inf
mul-1-negN/A
distribute-rgt-neg-inN/A
mul-1-negN/A
*-lowering-*.f64N/A
mul-1-negN/A
neg-lowering-neg.f6469.2
Simplified69.2%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 9.99999999999999986e306Initial program 99.2%
Taylor expanded in x around inf
Simplified66.9%
Final simplification67.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 3.3e+226) (fma (* y_m (- (tanh (/ t y_m)) (tanh (/ x y_m)))) z x) (fma z (- t x) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 3.3e+226) {
tmp = fma((y_m * (tanh((t / y_m)) - tanh((x / y_m)))), z, x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 3.3e+226) tmp = fma(Float64(y_m * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))), z, x); else tmp = fma(z, Float64(t - x), x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 3.3e+226], N[(N[(y$95$m * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 3.3 \cdot 10^{+226}:\\
\;\;\;\;\mathsf{fma}\left(y\_m \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right), z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 3.29999999999999978e226Initial program 92.3%
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6497.2
Applied egg-rr97.2%
if 3.29999999999999978e226 < y Initial program 56.7%
Taylor expanded in y around inf
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6491.2
Simplified91.2%
Final simplification96.8%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 3.65e+224) (fma (* z (- (tanh (/ t y_m)) (tanh (/ x y_m)))) y_m x) (fma z (- t x) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 3.65e+224) {
tmp = fma((z * (tanh((t / y_m)) - tanh((x / y_m)))), y_m, x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 3.65e+224) tmp = fma(Float64(z * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))), y_m, x); else tmp = fma(z, Float64(t - x), x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 3.65e+224], N[(N[(z * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y$95$m + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 3.65 \cdot 10^{+224}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right), y\_m, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 3.65000000000000013e224Initial program 92.3%
+-commutativeN/A
associate-*l*N/A
*-commutativeN/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6496.4
Applied egg-rr96.4%
if 3.65000000000000013e224 < y Initial program 56.7%
Taylor expanded in y around inf
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6491.2
Simplified91.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 1.05e-86) x (fma (fma (tanh (/ t y_m)) y_m (- x)) z x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 1.05e-86) {
tmp = x;
} else {
tmp = fma(fma(tanh((t / y_m)), y_m, -x), z, x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 1.05e-86) tmp = x; else tmp = fma(fma(tanh(Float64(t / y_m)), y_m, Float64(-x)), z, x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 1.05e-86], x, N[(N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] * y$95$m + (-x)), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 1.05 \cdot 10^{-86}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(\mathsf{fma}\left(\tanh \left(\frac{t}{y\_m}\right), y\_m, -x\right), z, x\right)\\
\end{array}
\end{array}
if y < 1.05e-86Initial program 92.9%
Taylor expanded in x around inf
Simplified62.6%
if 1.05e-86 < y Initial program 81.5%
+-commutativeN/A
*-commutativeN/A
associate-*r*N/A
accelerator-lowering-fma.f64N/A
*-lowering-*.f64N/A
--lowering--.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6494.7
Applied egg-rr94.7%
*-commutativeN/A
sub-negN/A
distribute-rgt-inN/A
accelerator-lowering-fma.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f64N/A
*-lowering-*.f64N/A
neg-lowering-neg.f64N/A
tanh-lowering-tanh.f64N/A
/-lowering-/.f6494.7
Applied egg-rr94.7%
Taylor expanded in x around 0
mul-1-negN/A
neg-lowering-neg.f6488.4
Simplified88.4%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 85.0) x (fma z (- t x) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 85.0) {
tmp = x;
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 85.0) tmp = x; else tmp = fma(z, Float64(t - x), x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 85.0], x, N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 85:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 85Initial program 93.4%
Taylor expanded in x around inf
Simplified62.2%
if 85 < y Initial program 75.8%
Taylor expanded in y around inf
+-commutativeN/A
accelerator-lowering-fma.f64N/A
--lowering--.f6479.7
Simplified79.7%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 6e-62) x (fma t z x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 6e-62) {
tmp = x;
} else {
tmp = fma(t, z, x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 6e-62) tmp = x; else tmp = fma(t, z, x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 6e-62], x, N[(t * z + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 6 \cdot 10^{-62}:\\
\;\;\;\;x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t, z, x\right)\\
\end{array}
\end{array}
if y < 6.0000000000000002e-62Initial program 93.0%
Taylor expanded in x around inf
Simplified62.9%
if 6.0000000000000002e-62 < y Initial program 80.4%
Taylor expanded in y around inf
/-lowering-/.f64N/A
--lowering--.f6455.5
Simplified55.5%
Taylor expanded in t around inf
/-lowering-/.f6446.9
Simplified46.9%
Taylor expanded in x around 0
+-commutativeN/A
accelerator-lowering-fma.f6452.2
Simplified52.2%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 x)
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
return x;
}
y_m = abs(y)
real(8) function code(x, y_m, z, t)
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8), intent (in) :: t
code = x
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
return x;
}
y_m = math.fabs(y) def code(x, y_m, z, t): return x
y_m = abs(y) function code(x, y_m, z, t) return x end
y_m = abs(y); function tmp = code(x, y_m, z, t) tmp = x; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := x
\begin{array}{l}
y_m = \left|y\right|
\\
x
\end{array}
Initial program 89.5%
Taylor expanded in x around inf
Simplified58.4%
(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 2024199
(FPCore (x y z t)
:name "SynthBasics:moogVCF from YampaSynth-0.2"
:precision binary64
:alt
(! :herbie-platform default (+ x (* y (* z (- (tanh (/ t y)) (tanh (/ x y)))))))
(+ x (* (* y z) (- (tanh (/ t y)) (tanh (/ x y))))))