
(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 3.9e+248) (fma (* z (- (tanh (/ t y_m)) (tanh (/ x y_m)))) y_m x) (fma (- t x) z x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 3.9e+248) {
tmp = fma((z * (tanh((t / y_m)) - tanh((x / y_m)))), y_m, x);
} else {
tmp = fma((t - x), z, x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 3.9e+248) tmp = fma(Float64(z * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))), y_m, x); else tmp = fma(Float64(t - 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, 3.9e+248], 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[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 3.9 \cdot 10^{+248}:\\
\;\;\;\;\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(t - x, z, x\right)\\
\end{array}
\end{array}
if y < 3.8999999999999999e248Initial program 94.3%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
*-commutativeN/A
lower-*.f6496.1
Applied rewrites96.1%
if 3.8999999999999999e248 < y Initial program 83.3%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Final simplification96.2%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (* (- t x) z))
(t_2 (+ (* (* z y_m) (- (tanh (/ t y_m)) (tanh (/ x y_m)))) x)))
(if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 2e+306) (* 1.0 x) t_1))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = (t - x) * z;
double t_2 = ((z * y_m) * (tanh((t / y_m)) - tanh((x / y_m)))) + x;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 2e+306) {
tmp = 1.0 * 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 = (t - x) * z;
double t_2 = ((z * y_m) * (Math.tanh((t / y_m)) - Math.tanh((x / y_m)))) + x;
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 2e+306) {
tmp = 1.0 * x;
} else {
tmp = t_1;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): t_1 = (t - x) * z t_2 = ((z * y_m) * (math.tanh((t / y_m)) - math.tanh((x / y_m)))) + x tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 2e+306: tmp = 1.0 * x else: tmp = t_1 return tmp
y_m = abs(y) function code(x, y_m, z, t) t_1 = Float64(Float64(t - x) * z) t_2 = Float64(Float64(Float64(z * y_m) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))) + x) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 2e+306) tmp = Float64(1.0 * x); else tmp = t_1; end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) t_1 = (t - x) * z; t_2 = ((z * y_m) * (tanh((t / y_m)) - tanh((x / y_m)))) + x; tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 2e+306) tmp = 1.0 * 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[(N[(t - x), $MachinePrecision] * z), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(z * y$95$m), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+306], N[(1.0 * x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := \left(t - x\right) \cdot z\\
t_2 := \left(z \cdot y\_m\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right) + x\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;1 \cdot 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 2.00000000000000003e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 61.9%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.0
Applied rewrites97.0%
Taylor expanded in z around inf
Applied rewrites97.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.00000000000000003e306Initial program 98.3%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6455.8
Applied rewrites55.8%
Applied rewrites37.2%
Taylor expanded in t around 0
Applied rewrites50.8%
Taylor expanded in z around 0
Applied rewrites68.2%
Final simplification71.5%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(let* ((t_1 (* (- z) x))
(t_2 (+ (* (* z y_m) (- (tanh (/ t y_m)) (tanh (/ x y_m)))) x)))
(if (<= t_2 (- INFINITY)) t_1 (if (<= t_2 2e+306) (* 1.0 x) t_1))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = -z * x;
double t_2 = ((z * y_m) * (tanh((t / y_m)) - tanh((x / y_m)))) + x;
double tmp;
if (t_2 <= -((double) INFINITY)) {
tmp = t_1;
} else if (t_2 <= 2e+306) {
tmp = 1.0 * 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 * x;
double t_2 = ((z * y_m) * (Math.tanh((t / y_m)) - Math.tanh((x / y_m)))) + x;
double tmp;
if (t_2 <= -Double.POSITIVE_INFINITY) {
tmp = t_1;
} else if (t_2 <= 2e+306) {
tmp = 1.0 * x;
} else {
tmp = t_1;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): t_1 = -z * x t_2 = ((z * y_m) * (math.tanh((t / y_m)) - math.tanh((x / y_m)))) + x tmp = 0 if t_2 <= -math.inf: tmp = t_1 elif t_2 <= 2e+306: tmp = 1.0 * x else: tmp = t_1 return tmp
y_m = abs(y) function code(x, y_m, z, t) t_1 = Float64(Float64(-z) * x) t_2 = Float64(Float64(Float64(z * y_m) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))) + x) tmp = 0.0 if (t_2 <= Float64(-Inf)) tmp = t_1; elseif (t_2 <= 2e+306) tmp = Float64(1.0 * 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 * x; t_2 = ((z * y_m) * (tanh((t / y_m)) - tanh((x / y_m)))) + x; tmp = 0.0; if (t_2 <= -Inf) tmp = t_1; elseif (t_2 <= 2e+306) tmp = 1.0 * 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) * x), $MachinePrecision]}, Block[{t$95$2 = N[(N[(N[(z * y$95$m), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$2, (-Infinity)], t$95$1, If[LessEqual[t$95$2, 2e+306], N[(1.0 * x), $MachinePrecision], t$95$1]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := \left(-z\right) \cdot x\\
t_2 := \left(z \cdot y\_m\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right) + x\\
\mathbf{if}\;t\_2 \leq -\infty:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t\_2 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;1 \cdot 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 2.00000000000000003e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 61.9%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.0
Applied rewrites97.0%
Applied rewrites87.3%
Taylor expanded in t around 0
Applied rewrites61.4%
Taylor expanded in z around inf
Applied rewrites61.4%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.00000000000000003e306Initial program 98.3%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6455.8
Applied rewrites55.8%
Applied rewrites37.2%
Taylor expanded in t around 0
Applied rewrites50.8%
Taylor expanded in z around 0
Applied rewrites68.2%
Final simplification67.4%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (let* ((t_1 (+ (* (* z y_m) (- (tanh (/ t y_m)) (tanh (/ x y_m)))) x))) (if (<= t_1 (- INFINITY)) (* z t) (if (<= t_1 2e+306) (* 1.0 x) (* z t)))))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double t_1 = ((z * y_m) * (tanh((t / y_m)) - tanh((x / y_m)))) + x;
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = z * t;
} else if (t_1 <= 2e+306) {
tmp = 1.0 * x;
} else {
tmp = z * t;
}
return tmp;
}
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double t_1 = ((z * y_m) * (Math.tanh((t / y_m)) - Math.tanh((x / y_m)))) + x;
double tmp;
if (t_1 <= -Double.POSITIVE_INFINITY) {
tmp = z * t;
} else if (t_1 <= 2e+306) {
tmp = 1.0 * x;
} else {
tmp = z * t;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): t_1 = ((z * y_m) * (math.tanh((t / y_m)) - math.tanh((x / y_m)))) + x tmp = 0 if t_1 <= -math.inf: tmp = z * t elif t_1 <= 2e+306: tmp = 1.0 * x else: tmp = z * t return tmp
y_m = abs(y) function code(x, y_m, z, t) t_1 = Float64(Float64(Float64(z * y_m) * Float64(tanh(Float64(t / y_m)) - tanh(Float64(x / y_m)))) + x) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(z * t); elseif (t_1 <= 2e+306) tmp = Float64(1.0 * x); else tmp = Float64(z * t); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) t_1 = ((z * y_m) * (tanh((t / y_m)) - tanh((x / y_m)))) + x; tmp = 0.0; if (t_1 <= -Inf) tmp = z * t; elseif (t_1 <= 2e+306) tmp = 1.0 * x; else tmp = z * t; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision]
code[x_, y$95$m_, z_, t_] := Block[{t$95$1 = N[(N[(N[(z * y$95$m), $MachinePrecision] * N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(z * t), $MachinePrecision], If[LessEqual[t$95$1, 2e+306], N[(1.0 * x), $MachinePrecision], N[(z * t), $MachinePrecision]]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
t_1 := \left(z \cdot y\_m\right) \cdot \left(\tanh \left(\frac{t}{y\_m}\right) - \tanh \left(\frac{x}{y\_m}\right)\right) + x\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;z \cdot t\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+306}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\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.00000000000000003e306 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 61.9%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6497.0
Applied rewrites97.0%
Taylor expanded in t around inf
Applied rewrites41.4%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.00000000000000003e306Initial program 98.3%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6455.8
Applied rewrites55.8%
Applied rewrites37.2%
Taylor expanded in t around 0
Applied rewrites50.8%
Taylor expanded in z around 0
Applied rewrites68.2%
Final simplification65.0%
y_m = (fabs.f64 y)
(FPCore (x y_m z t)
:precision binary64
(if (<= y_m 4.8e-72)
(* 1.0 x)
(if (<= y_m 1.3e+67)
(- (fma (tanh (/ t y_m)) (* z y_m) x) (* z x))
(fma (- t x) z x))))y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 4.8e-72) {
tmp = 1.0 * x;
} else if (y_m <= 1.3e+67) {
tmp = fma(tanh((t / y_m)), (z * y_m), x) - (z * x);
} else {
tmp = fma((t - x), z, x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 4.8e-72) tmp = Float64(1.0 * x); elseif (y_m <= 1.3e+67) tmp = Float64(fma(tanh(Float64(t / y_m)), Float64(z * y_m), x) - Float64(z * x)); else tmp = fma(Float64(t - 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, 4.8e-72], N[(1.0 * x), $MachinePrecision], If[LessEqual[y$95$m, 1.3e+67], N[(N[(N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision] * N[(z * y$95$m), $MachinePrecision] + x), $MachinePrecision] - N[(z * x), $MachinePrecision]), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 4.8 \cdot 10^{-72}:\\
\;\;\;\;1 \cdot x\\
\mathbf{elif}\;y\_m \leq 1.3 \cdot 10^{+67}:\\
\;\;\;\;\mathsf{fma}\left(\tanh \left(\frac{t}{y\_m}\right), z \cdot y\_m, x\right) - z \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\end{array}
\end{array}
if y < 4.8e-72Initial program 94.7%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6454.9
Applied rewrites54.9%
Applied rewrites39.5%
Taylor expanded in t around 0
Applied rewrites50.1%
Taylor expanded in z around 0
Applied rewrites68.2%
if 4.8e-72 < y < 1.3e67Initial program 97.8%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt-neg-outN/A
lower-neg.f64N/A
lower-*.f6497.5
lift-*.f64N/A
*-commutativeN/A
lower-*.f6497.5
Applied rewrites97.5%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6481.6
Applied rewrites81.6%
lift-+.f64N/A
lift-fma.f64N/A
associate-+r+N/A
lift-neg.f64N/A
unsub-negN/A
lower--.f64N/A
+-commutativeN/A
*-commutativeN/A
lower-fma.f6481.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6481.6
Applied rewrites81.6%
if 1.3e67 < y Initial program 88.9%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6479.7
Applied rewrites79.7%
Final simplification72.5%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 4.8e-72) (* 1.0 x) (+ (fma (* z (tanh (/ t y_m))) y_m (- (* z x))) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 4.8e-72) {
tmp = 1.0 * x;
} else {
tmp = fma((z * tanh((t / y_m))), y_m, -(z * x)) + x;
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 4.8e-72) tmp = Float64(1.0 * x); else tmp = Float64(fma(Float64(z * tanh(Float64(t / y_m))), y_m, Float64(-Float64(z * x))) + x); end return tmp end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 4.8e-72], N[(1.0 * x), $MachinePrecision], N[(N[(N[(z * N[Tanh[N[(t / y$95$m), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * y$95$m + (-N[(z * x), $MachinePrecision])), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 4.8 \cdot 10^{-72}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \tanh \left(\frac{t}{y\_m}\right), y\_m, -z \cdot x\right) + x\\
\end{array}
\end{array}
if y < 4.8e-72Initial program 94.7%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6454.9
Applied rewrites54.9%
Applied rewrites39.5%
Taylor expanded in t around 0
Applied rewrites50.1%
Taylor expanded in z around 0
Applied rewrites68.2%
if 4.8e-72 < y Initial program 92.8%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
lower-fma.f64N/A
lift-*.f64N/A
*-commutativeN/A
lower-*.f64N/A
distribute-rgt-neg-outN/A
lower-neg.f64N/A
lower-*.f6483.6
lift-*.f64N/A
*-commutativeN/A
lower-*.f6483.6
Applied rewrites83.6%
Taylor expanded in y around inf
*-commutativeN/A
lower-*.f6477.9
Applied rewrites77.9%
lift-fma.f64N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f6486.6
Applied rewrites86.6%
Final simplification74.7%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 9e-30) (* 1.0 x) (fma (- t x) z x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 9e-30) {
tmp = 1.0 * x;
} else {
tmp = fma((t - x), z, x);
}
return tmp;
}
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 9e-30) tmp = Float64(1.0 * x); else tmp = fma(Float64(t - 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, 9e-30], N[(1.0 * x), $MachinePrecision], N[(N[(t - x), $MachinePrecision] * z + x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 9 \cdot 10^{-30}:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(t - x, z, x\right)\\
\end{array}
\end{array}
if y < 8.99999999999999935e-30Initial program 95.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6454.8
Applied rewrites54.8%
Applied rewrites38.7%
Taylor expanded in t around 0
Applied rewrites50.3%
Taylor expanded in z around 0
Applied rewrites68.3%
if 8.99999999999999935e-30 < y Initial program 92.0%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6473.5
Applied rewrites73.5%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (if (<= y_m 7.9) (* 1.0 x) (* (- 1.0 z) x)))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 7.9) {
tmp = 1.0 * x;
} else {
tmp = (1.0 - z) * x;
}
return tmp;
}
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
real(8) :: tmp
if (y_m <= 7.9d0) then
tmp = 1.0d0 * x
else
tmp = (1.0d0 - z) * x
end if
code = tmp
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
double tmp;
if (y_m <= 7.9) {
tmp = 1.0 * x;
} else {
tmp = (1.0 - z) * x;
}
return tmp;
}
y_m = math.fabs(y) def code(x, y_m, z, t): tmp = 0 if y_m <= 7.9: tmp = 1.0 * x else: tmp = (1.0 - z) * x return tmp
y_m = abs(y) function code(x, y_m, z, t) tmp = 0.0 if (y_m <= 7.9) tmp = Float64(1.0 * x); else tmp = Float64(Float64(1.0 - z) * x); end return tmp end
y_m = abs(y); function tmp_2 = code(x, y_m, z, t) tmp = 0.0; if (y_m <= 7.9) tmp = 1.0 * x; else tmp = (1.0 - z) * x; end tmp_2 = tmp; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := If[LessEqual[y$95$m, 7.9], N[(1.0 * x), $MachinePrecision], N[(N[(1.0 - z), $MachinePrecision] * x), $MachinePrecision]]
\begin{array}{l}
y_m = \left|y\right|
\\
\begin{array}{l}
\mathbf{if}\;y\_m \leq 7.9:\\
\;\;\;\;1 \cdot x\\
\mathbf{else}:\\
\;\;\;\;\left(1 - z\right) \cdot x\\
\end{array}
\end{array}
if y < 7.9000000000000004Initial program 95.3%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6455.6
Applied rewrites55.6%
Applied rewrites38.1%
Taylor expanded in t around 0
Applied rewrites50.1%
Taylor expanded in z around 0
Applied rewrites67.7%
if 7.9000000000000004 < y Initial program 90.9%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6473.8
Applied rewrites73.8%
Taylor expanded in t around 0
Applied rewrites57.0%
y_m = (fabs.f64 y) (FPCore (x y_m z t) :precision binary64 (* z t))
y_m = fabs(y);
double code(double x, double y_m, double z, double t) {
return z * t;
}
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 = z * t
end function
y_m = Math.abs(y);
public static double code(double x, double y_m, double z, double t) {
return z * t;
}
y_m = math.fabs(y) def code(x, y_m, z, t): return z * t
y_m = abs(y) function code(x, y_m, z, t) return Float64(z * t) end
y_m = abs(y); function tmp = code(x, y_m, z, t) tmp = z * t; end
y_m = N[Abs[y], $MachinePrecision] code[x_, y$95$m_, z_, t_] := N[(z * t), $MachinePrecision]
\begin{array}{l}
y_m = \left|y\right|
\\
z \cdot t
\end{array}
Initial program 94.1%
Taylor expanded in y around inf
+-commutativeN/A
*-commutativeN/A
lower-fma.f64N/A
lower--.f6460.7
Applied rewrites60.7%
Taylor expanded in t around inf
Applied rewrites16.2%
Final simplification16.2%
(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 2024277
(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))))))