
(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 12 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 (fma (* z (- (tanh (/ t y)) (tanh (/ x y)))) y x))
double code(double x, double y, double z, double t) {
return fma((z * (tanh((t / y)) - tanh((x / y)))), y, x);
}
function code(x, y, z, t) return fma(Float64(z * Float64(tanh(Float64(t / y)) - tanh(Float64(x / y)))), y, x) end
code[x_, y_, z_, t_] := N[(N[(z * N[(N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(z \cdot \left(\tanh \left(\frac{t}{y}\right) - \tanh \left(\frac{x}{y}\right)\right), y, x\right)
\end{array}
Initial program 92.1%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6497.3
Applied rewrites97.3%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (+ x (* (- (tanh (/ t y)) (tanh (/ x y))) (* z y))))
(t_2 (+ x (* (* z y) (/ 1.0 (/ (+ y (/ (/ (* y (* x x)) t) t)) t))))))
(if (<= t_1 (- INFINITY))
(* z (- t x))
(if (<= t_1 -10000000.0)
t_2
(if (<= t_1 5e+30)
(+ x (* (* z y) (/ 1.0 (/ (fma t (/ y x) y) (- x)))))
(if (<= t_1 2e+281) t_2 (fma z (- t x) x)))))))
double code(double x, double y, double z, double t) {
double t_1 = x + ((tanh((t / y)) - tanh((x / y))) * (z * y));
double t_2 = x + ((z * y) * (1.0 / ((y + (((y * (x * x)) / t) / t)) / t)));
double tmp;
if (t_1 <= -((double) INFINITY)) {
tmp = z * (t - x);
} else if (t_1 <= -10000000.0) {
tmp = t_2;
} else if (t_1 <= 5e+30) {
tmp = x + ((z * y) * (1.0 / (fma(t, (y / x), y) / -x)));
} else if (t_1 <= 2e+281) {
tmp = t_2;
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(x + Float64(Float64(tanh(Float64(t / y)) - tanh(Float64(x / y))) * Float64(z * y))) t_2 = Float64(x + Float64(Float64(z * y) * Float64(1.0 / Float64(Float64(y + Float64(Float64(Float64(y * Float64(x * x)) / t) / t)) / t)))) tmp = 0.0 if (t_1 <= Float64(-Inf)) tmp = Float64(z * Float64(t - x)); elseif (t_1 <= -10000000.0) tmp = t_2; elseif (t_1 <= 5e+30) tmp = Float64(x + Float64(Float64(z * y) * Float64(1.0 / Float64(fma(t, Float64(y / x), y) / Float64(-x))))); elseif (t_1 <= 2e+281) tmp = t_2; else tmp = fma(z, Float64(t - x), x); end return 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[(z * y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$2 = N[(x + N[(N[(z * y), $MachinePrecision] * N[(1.0 / N[(N[(y + N[(N[(N[(y * N[(x * x), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t$95$1, (-Infinity)], N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, -10000000.0], t$95$2, If[LessEqual[t$95$1, 5e+30], N[(x + N[(N[(z * y), $MachinePrecision] * N[(1.0 / N[(N[(t * N[(y / x), $MachinePrecision] + y), $MachinePrecision] / (-x)), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[t$95$1, 2e+281], t$95$2, N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]]]]]
\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(z \cdot y\right)\\
t_2 := x + \left(z \cdot y\right) \cdot \frac{1}{\frac{y + \frac{\frac{y \cdot \left(x \cdot x\right)}{t}}{t}}{t}}\\
\mathbf{if}\;t\_1 \leq -\infty:\\
\;\;\;\;z \cdot \left(t - x\right)\\
\mathbf{elif}\;t\_1 \leq -10000000:\\
\;\;\;\;t\_2\\
\mathbf{elif}\;t\_1 \leq 5 \cdot 10^{+30}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \frac{1}{\frac{\mathsf{fma}\left(t, \frac{y}{x}, y\right)}{-x}}\\
\mathbf{elif}\;t\_1 \leq 2 \cdot 10^{+281}:\\
\;\;\;\;t\_2\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -inf.0Initial program 52.8%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f64100.0
Applied rewrites100.0%
Taylor expanded in z around inf
Applied rewrites100.0%
if -inf.0 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < -1e7 or 4.9999999999999998e30 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 2.0000000000000001e281Initial program 99.9%
Taylor expanded in y around inf
lower-/.f64N/A
lower--.f6446.1
Applied rewrites46.1%
Applied rewrites46.1%
Taylor expanded in t around -inf
Applied rewrites62.3%
Taylor expanded in x around inf
Applied rewrites74.4%
if -1e7 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) < 4.9999999999999998e30Initial program 97.6%
Taylor expanded in y around inf
lower-/.f64N/A
lower--.f6455.3
Applied rewrites55.3%
Applied rewrites55.4%
Taylor expanded in x around inf
Applied rewrites70.0%
if 2.0000000000000001e281 < (+.f64 x (*.f64 (*.f64 y z) (-.f64 (tanh.f64 (/.f64 t y)) (tanh.f64 (/.f64 x y))))) Initial program 52.4%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6490.5
Applied rewrites90.5%
Final simplification75.7%
(FPCore (x y z t)
:precision binary64
(let* ((t_1 (fma (* y (tanh (/ t y))) z (fma x (- z) x))))
(if (<= t -1.8e+33)
t_1
(if (<= t 2.05e-231) (fma (* z (- (/ t y) (tanh (/ x y)))) y x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = fma((y * tanh((t / y))), z, fma(x, -z, x));
double tmp;
if (t <= -1.8e+33) {
tmp = t_1;
} else if (t <= 2.05e-231) {
tmp = fma((z * ((t / y) - tanh((x / y)))), y, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = fma(Float64(y * tanh(Float64(t / y))), z, fma(x, Float64(-z), x)) tmp = 0.0 if (t <= -1.8e+33) tmp = t_1; elseif (t <= 2.05e-231) tmp = fma(Float64(z * Float64(Float64(t / y) - tanh(Float64(x / y)))), y, x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z + N[(x * (-z) + x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[t, -1.8e+33], t$95$1, If[LessEqual[t, 2.05e-231], N[(N[(z * N[(N[(t / y), $MachinePrecision] - N[Tanh[N[(x / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * y + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := \mathsf{fma}\left(y \cdot \tanh \left(\frac{t}{y}\right), z, \mathsf{fma}\left(x, -z, x\right)\right)\\
\mathbf{if}\;t \leq -1.8 \cdot 10^{+33}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;t \leq 2.05 \cdot 10^{-231}:\\
\;\;\;\;\mathsf{fma}\left(z \cdot \left(\frac{t}{y} - \tanh \left(\frac{x}{y}\right)\right), y, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if t < -1.8000000000000001e33 or 2.0500000000000001e-231 < t Initial program 93.3%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
lower-fma.f64N/A
distribute-rgt-neg-outN/A
lower-neg.f64N/A
lower-*.f6488.4
Applied rewrites88.4%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
associate-+l+N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
Applied rewrites89.0%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6483.1
Applied rewrites83.1%
if -1.8000000000000001e33 < t < 2.0500000000000001e-231Initial program 89.8%
lift-+.f64N/A
+-commutativeN/A
lift-*.f64N/A
lift-*.f64N/A
associate-*l*N/A
*-commutativeN/A
lower-fma.f64N/A
lower-*.f6495.4
Applied rewrites95.4%
Taylor expanded in t around 0
lower-/.f6491.6
Applied rewrites91.6%
Final simplification85.9%
(FPCore (x y z t) :precision binary64 (if (<= x -2.7e+119) (fma (* y (/ 1.0 (/ (+ y (/ (* x (fma y (/ x t) y)) t)) t))) z x) (fma (* y (tanh (/ t y))) z (fma x (- z) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -2.7e+119) {
tmp = fma((y * (1.0 / ((y + ((x * fma(y, (x / t), y)) / t)) / t))), z, x);
} else {
tmp = fma((y * tanh((t / y))), z, fma(x, -z, x));
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (x <= -2.7e+119) tmp = fma(Float64(y * Float64(1.0 / Float64(Float64(y + Float64(Float64(x * fma(y, Float64(x / t), y)) / t)) / t))), z, x); else tmp = fma(Float64(y * tanh(Float64(t / y))), z, fma(x, Float64(-z), x)); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[x, -2.7e+119], N[(N[(y * N[(1.0 / N[(N[(y + N[(N[(x * N[(y * N[(x / t), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] * z + x), $MachinePrecision], N[(N[(y * N[Tanh[N[(t / y), $MachinePrecision]], $MachinePrecision]), $MachinePrecision] * z + N[(x * (-z) + x), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.7 \cdot 10^{+119}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \frac{1}{\frac{y + \frac{x \cdot \mathsf{fma}\left(y, \frac{x}{t}, y\right)}{t}}{t}}, z, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(y \cdot \tanh \left(\frac{t}{y}\right), z, \mathsf{fma}\left(x, -z, x\right)\right)\\
\end{array}
\end{array}
if x < -2.6999999999999998e119Initial program 95.8%
Taylor expanded in y around inf
lower-/.f64N/A
lower--.f6448.4
Applied rewrites48.4%
Applied rewrites48.4%
Taylor expanded in t around -inf
Applied rewrites69.0%
Applied rewrites83.3%
if -2.6999999999999998e119 < x Initial program 91.3%
lift-*.f64N/A
lift--.f64N/A
sub-negN/A
distribute-lft-inN/A
lower-fma.f64N/A
distribute-rgt-neg-outN/A
lower-neg.f64N/A
lower-*.f6488.2
Applied rewrites88.2%
lift-+.f64N/A
+-commutativeN/A
lift-fma.f64N/A
associate-+l+N/A
*-commutativeN/A
lift-*.f64N/A
associate-*r*N/A
lower-fma.f64N/A
lower-*.f64N/A
lift-neg.f64N/A
lift-*.f64N/A
*-commutativeN/A
distribute-rgt-neg-inN/A
lower-fma.f64N/A
Applied rewrites88.3%
Taylor expanded in x around 0
+-commutativeN/A
distribute-lft-inN/A
*-rgt-identityN/A
lower-fma.f64N/A
mul-1-negN/A
lower-neg.f6483.9
Applied rewrites83.9%
Final simplification83.8%
(FPCore (x y z t)
:precision binary64
(if (<= y 3e-224)
(fma z (/ (* x (- x)) (+ t x)) x)
(if (<= y 2.2e-104)
(+ x (* (* z y) (/ 1.0 (/ (fma x (/ y t) y) t))))
(fma z (- t x) x))))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 3e-224) {
tmp = fma(z, ((x * -x) / (t + x)), x);
} else if (y <= 2.2e-104) {
tmp = x + ((z * y) * (1.0 / (fma(x, (y / t), y) / t)));
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 3e-224) tmp = fma(z, Float64(Float64(x * Float64(-x)) / Float64(t + x)), x); elseif (y <= 2.2e-104) tmp = Float64(x + Float64(Float64(z * y) * Float64(1.0 / Float64(fma(x, Float64(y / t), y) / t)))); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 3e-224], N[(z * N[(N[(x * (-x)), $MachinePrecision] / N[(t + x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], If[LessEqual[y, 2.2e-104], N[(x + N[(N[(z * y), $MachinePrecision] * N[(1.0 / N[(N[(x * N[(y / t), $MachinePrecision] + y), $MachinePrecision] / t), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3 \cdot 10^{-224}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{x \cdot \left(-x\right)}{t + x}, x\right)\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-104}:\\
\;\;\;\;x + \left(z \cdot y\right) \cdot \frac{1}{\frac{\mathsf{fma}\left(x, \frac{y}{t}, y\right)}{t}}\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 2.99999999999999982e-224Initial program 90.9%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6464.5
Applied rewrites64.5%
Applied rewrites46.0%
Taylor expanded in t around 0
Applied rewrites47.2%
if 2.99999999999999982e-224 < y < 2.20000000000000012e-104Initial program 100.0%
Taylor expanded in y around inf
lower-/.f64N/A
lower--.f6430.5
Applied rewrites30.5%
Applied rewrites30.5%
Taylor expanded in t around inf
Applied rewrites54.6%
if 2.20000000000000012e-104 < y Initial program 91.6%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6471.1
Applied rewrites71.1%
Final simplification55.6%
(FPCore (x y z t) :precision binary64 (if (<= y 6.6e-128) (fma z (/ (* x (- x)) (+ t x)) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 6.6e-128) {
tmp = fma(z, ((x * -x) / (t + x)), x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 6.6e-128) tmp = fma(z, Float64(Float64(x * Float64(-x)) / Float64(t + x)), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 6.6e-128], N[(z * N[(N[(x * (-x)), $MachinePrecision] / N[(t + x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.6 \cdot 10^{-128}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{x \cdot \left(-x\right)}{t + x}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 6.6e-128Initial program 92.1%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6462.9
Applied rewrites62.9%
Applied rewrites43.9%
Taylor expanded in t around 0
Applied rewrites47.9%
if 6.6e-128 < y Initial program 92.2%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6469.7
Applied rewrites69.7%
(FPCore (x y z t) :precision binary64 (if (<= y 5.5e-124) (fma z (/ (* t t) (+ t x)) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 5.5e-124) {
tmp = fma(z, ((t * t) / (t + x)), x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 5.5e-124) tmp = fma(z, Float64(Float64(t * t) / Float64(t + x)), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 5.5e-124], N[(z * N[(N[(t * t), $MachinePrecision] / N[(t + x), $MachinePrecision]), $MachinePrecision] + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 5.5 \cdot 10^{-124}:\\
\;\;\;\;\mathsf{fma}\left(z, \frac{t \cdot t}{t + x}, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 5.50000000000000016e-124Initial program 92.1%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6462.2
Applied rewrites62.2%
Applied rewrites43.4%
Taylor expanded in t around inf
Applied rewrites56.2%
if 5.50000000000000016e-124 < y Initial program 92.0%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6471.3
Applied rewrites71.3%
(FPCore (x y z t) :precision binary64 (let* ((t_1 (* z (- t x)))) (if (<= z -5500000000000.0) t_1 (if (<= z 2.9e-6) (fma z (- x) x) t_1))))
double code(double x, double y, double z, double t) {
double t_1 = z * (t - x);
double tmp;
if (z <= -5500000000000.0) {
tmp = t_1;
} else if (z <= 2.9e-6) {
tmp = fma(z, -x, x);
} else {
tmp = t_1;
}
return tmp;
}
function code(x, y, z, t) t_1 = Float64(z * Float64(t - x)) tmp = 0.0 if (z <= -5500000000000.0) tmp = t_1; elseif (z <= 2.9e-6) tmp = fma(z, Float64(-x), x); else tmp = t_1; end return tmp end
code[x_, y_, z_, t_] := Block[{t$95$1 = N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -5500000000000.0], t$95$1, If[LessEqual[z, 2.9e-6], N[(z * (-x) + x), $MachinePrecision], t$95$1]]]
\begin{array}{l}
\\
\begin{array}{l}
t_1 := z \cdot \left(t - x\right)\\
\mathbf{if}\;z \leq -5500000000000:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-6}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -5.5e12 or 2.9000000000000002e-6 < z Initial program 82.8%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6446.5
Applied rewrites46.5%
Taylor expanded in z around inf
Applied rewrites45.6%
if -5.5e12 < z < 2.9000000000000002e-6Initial program 99.3%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6479.5
Applied rewrites79.5%
Taylor expanded in t around 0
Applied rewrites83.1%
(FPCore (x y z t) :precision binary64 (if (<= y 2.45e-102) (fma z (- x) x) (fma z (- t x) x)))
double code(double x, double y, double z, double t) {
double tmp;
if (y <= 2.45e-102) {
tmp = fma(z, -x, x);
} else {
tmp = fma(z, (t - x), x);
}
return tmp;
}
function code(x, y, z, t) tmp = 0.0 if (y <= 2.45e-102) tmp = fma(z, Float64(-x), x); else tmp = fma(z, Float64(t - x), x); end return tmp end
code[x_, y_, z_, t_] := If[LessEqual[y, 2.45e-102], N[(z * (-x) + x), $MachinePrecision], N[(z * N[(t - x), $MachinePrecision] + x), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.45 \cdot 10^{-102}:\\
\;\;\;\;\mathsf{fma}\left(z, -x, x\right)\\
\mathbf{else}:\\
\;\;\;\;\mathsf{fma}\left(z, t - x, x\right)\\
\end{array}
\end{array}
if y < 2.4499999999999999e-102Initial program 92.3%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6462.5
Applied rewrites62.5%
Taylor expanded in t around 0
Applied rewrites55.6%
if 2.4499999999999999e-102 < y Initial program 91.6%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6471.1
Applied rewrites71.1%
(FPCore (x y z t) :precision binary64 (if (<= x -6.2e-155) (* z (- x)) (* z t)))
double code(double x, double y, double z, double t) {
double tmp;
if (x <= -6.2e-155) {
tmp = z * -x;
} else {
tmp = 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 (x <= (-6.2d-155)) then
tmp = z * -x
else
tmp = z * t
end if
code = tmp
end function
public static double code(double x, double y, double z, double t) {
double tmp;
if (x <= -6.2e-155) {
tmp = z * -x;
} else {
tmp = z * t;
}
return tmp;
}
def code(x, y, z, t): tmp = 0 if x <= -6.2e-155: tmp = z * -x else: tmp = z * t return tmp
function code(x, y, z, t) tmp = 0.0 if (x <= -6.2e-155) tmp = Float64(z * Float64(-x)); else tmp = Float64(z * t); end return tmp end
function tmp_2 = code(x, y, z, t) tmp = 0.0; if (x <= -6.2e-155) tmp = z * -x; else tmp = z * t; end tmp_2 = tmp; end
code[x_, y_, z_, t_] := If[LessEqual[x, -6.2e-155], N[(z * (-x)), $MachinePrecision], N[(z * t), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -6.2 \cdot 10^{-155}:\\
\;\;\;\;z \cdot \left(-x\right)\\
\mathbf{else}:\\
\;\;\;\;z \cdot t\\
\end{array}
\end{array}
if x < -6.2e-155Initial program 90.4%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6468.0
Applied rewrites68.0%
Taylor expanded in z around inf
Applied rewrites22.3%
Taylor expanded in t around 0
Applied rewrites15.9%
if -6.2e-155 < x Initial program 93.4%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6463.1
Applied rewrites63.1%
Taylor expanded in t around inf
Applied rewrites24.9%
(FPCore (x y z t) :precision binary64 (* z (- t x)))
double code(double x, double y, double z, double t) {
return z * (t - 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 = z * (t - x)
end function
public static double code(double x, double y, double z, double t) {
return z * (t - x);
}
def code(x, y, z, t): return z * (t - x)
function code(x, y, z, t) return Float64(z * Float64(t - x)) end
function tmp = code(x, y, z, t) tmp = z * (t - x); end
code[x_, y_, z_, t_] := N[(z * N[(t - x), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
z \cdot \left(t - x\right)
\end{array}
Initial program 92.1%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6465.2
Applied rewrites65.2%
Taylor expanded in z around inf
Applied rewrites26.4%
(FPCore (x y z t) :precision binary64 (* z t))
double code(double x, double y, double z, double t) {
return z * t;
}
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 = z * t
end function
public static double code(double x, double y, double z, double t) {
return z * t;
}
def code(x, y, z, t): return z * t
function code(x, y, z, t) return Float64(z * t) end
function tmp = code(x, y, z, t) tmp = z * t; end
code[x_, y_, z_, t_] := N[(z * t), $MachinePrecision]
\begin{array}{l}
\\
z \cdot t
\end{array}
Initial program 92.1%
Taylor expanded in y around inf
+-commutativeN/A
lower-fma.f64N/A
lower--.f6465.2
Applied rewrites65.2%
Taylor expanded in t around inf
Applied rewrites18.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 2024221
(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))))))