
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
x_m = (fabs.f64 x) (FPCore (x_m y z) :precision binary64 (* 0.5 (+ y (* (+ z x_m) (/ (- x_m z) y)))))
x_m = fabs(x);
double code(double x_m, double y, double z) {
return 0.5 * (y + ((z + x_m) * ((x_m - z) / y)));
}
x_m = abs(x)
real(8) function code(x_m, y, z)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * (y + ((z + x_m) * ((x_m - z) / y)))
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z) {
return 0.5 * (y + ((z + x_m) * ((x_m - z) / y)));
}
x_m = math.fabs(x) def code(x_m, y, z): return 0.5 * (y + ((z + x_m) * ((x_m - z) / y)))
x_m = abs(x) function code(x_m, y, z) return Float64(0.5 * Float64(y + Float64(Float64(z + x_m) * Float64(Float64(x_m - z) / y)))) end
x_m = abs(x); function tmp = code(x_m, y, z) tmp = 0.5 * (y + ((z + x_m) * ((x_m - z) / y))); end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_] := N[(0.5 * N[(y + N[(N[(z + x$95$m), $MachinePrecision] * N[(N[(x$95$m - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
0.5 \cdot \left(y + \left(z + x\_m\right) \cdot \frac{x\_m - z}{y}\right)
\end{array}
Initial program 66.3%
remove-double-neg66.3%
distribute-lft-neg-out66.3%
distribute-frac-neg266.3%
distribute-frac-neg66.3%
neg-mul-166.3%
distribute-lft-neg-out66.3%
*-commutative66.3%
distribute-lft-neg-in66.3%
times-frac66.3%
metadata-eval66.3%
metadata-eval66.3%
associate--l+66.3%
fma-define69.1%
Simplified69.1%
Taylor expanded in x around 0 80.6%
associate--l+80.6%
div-sub84.9%
Simplified84.9%
pow284.9%
pow284.9%
difference-of-squares90.8%
Applied egg-rr90.8%
associate-/l*99.9%
Applied egg-rr99.9%
+-commutative99.9%
Simplified99.9%
x_m = (fabs.f64 x)
(FPCore (x_m y z)
:precision binary64
(let* ((t_0 (/ (- x_m z) y)))
(if (<= x_m 5.4e+59)
(* 0.5 (+ y (* z t_0)))
(if (<= x_m 4.1e+192)
(* 0.5 (+ y (* (* x_m (- x_m z)) (/ 1.0 y))))
(* 0.5 (* (+ z x_m) t_0))))))x_m = fabs(x);
double code(double x_m, double y, double z) {
double t_0 = (x_m - z) / y;
double tmp;
if (x_m <= 5.4e+59) {
tmp = 0.5 * (y + (z * t_0));
} else if (x_m <= 4.1e+192) {
tmp = 0.5 * (y + ((x_m * (x_m - z)) * (1.0 / y)));
} else {
tmp = 0.5 * ((z + x_m) * t_0);
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x_m - z) / y
if (x_m <= 5.4d+59) then
tmp = 0.5d0 * (y + (z * t_0))
else if (x_m <= 4.1d+192) then
tmp = 0.5d0 * (y + ((x_m * (x_m - z)) * (1.0d0 / y)))
else
tmp = 0.5d0 * ((z + x_m) * t_0)
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z) {
double t_0 = (x_m - z) / y;
double tmp;
if (x_m <= 5.4e+59) {
tmp = 0.5 * (y + (z * t_0));
} else if (x_m <= 4.1e+192) {
tmp = 0.5 * (y + ((x_m * (x_m - z)) * (1.0 / y)));
} else {
tmp = 0.5 * ((z + x_m) * t_0);
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z): t_0 = (x_m - z) / y tmp = 0 if x_m <= 5.4e+59: tmp = 0.5 * (y + (z * t_0)) elif x_m <= 4.1e+192: tmp = 0.5 * (y + ((x_m * (x_m - z)) * (1.0 / y))) else: tmp = 0.5 * ((z + x_m) * t_0) return tmp
x_m = abs(x) function code(x_m, y, z) t_0 = Float64(Float64(x_m - z) / y) tmp = 0.0 if (x_m <= 5.4e+59) tmp = Float64(0.5 * Float64(y + Float64(z * t_0))); elseif (x_m <= 4.1e+192) tmp = Float64(0.5 * Float64(y + Float64(Float64(x_m * Float64(x_m - z)) * Float64(1.0 / y)))); else tmp = Float64(0.5 * Float64(Float64(z + x_m) * t_0)); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z) t_0 = (x_m - z) / y; tmp = 0.0; if (x_m <= 5.4e+59) tmp = 0.5 * (y + (z * t_0)); elseif (x_m <= 4.1e+192) tmp = 0.5 * (y + ((x_m * (x_m - z)) * (1.0 / y))); else tmp = 0.5 * ((z + x_m) * t_0); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_] := Block[{t$95$0 = N[(N[(x$95$m - z), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x$95$m, 5.4e+59], N[(0.5 * N[(y + N[(z * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$95$m, 4.1e+192], N[(0.5 * N[(y + N[(N[(x$95$m * N[(x$95$m - z), $MachinePrecision]), $MachinePrecision] * N[(1.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(z + x$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := \frac{x\_m - z}{y}\\
\mathbf{if}\;x\_m \leq 5.4 \cdot 10^{+59}:\\
\;\;\;\;0.5 \cdot \left(y + z \cdot t\_0\right)\\
\mathbf{elif}\;x\_m \leq 4.1 \cdot 10^{+192}:\\
\;\;\;\;0.5 \cdot \left(y + \left(x\_m \cdot \left(x\_m - z\right)\right) \cdot \frac{1}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(z + x\_m\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if x < 5.4000000000000002e59Initial program 69.4%
remove-double-neg69.4%
distribute-lft-neg-out69.4%
distribute-frac-neg269.4%
distribute-frac-neg69.4%
neg-mul-169.4%
distribute-lft-neg-out69.4%
*-commutative69.4%
distribute-lft-neg-in69.4%
times-frac69.4%
metadata-eval69.4%
metadata-eval69.4%
associate--l+69.4%
fma-define72.0%
Simplified72.0%
Taylor expanded in x around 0 86.9%
associate--l+86.9%
div-sub90.5%
Simplified90.5%
pow290.5%
pow290.5%
difference-of-squares94.1%
Applied egg-rr94.1%
associate-/l*99.9%
Applied egg-rr99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 79.6%
if 5.4000000000000002e59 < x < 4.10000000000000003e192Initial program 56.5%
remove-double-neg56.5%
distribute-lft-neg-out56.5%
distribute-frac-neg256.5%
distribute-frac-neg56.5%
neg-mul-156.5%
distribute-lft-neg-out56.5%
*-commutative56.5%
distribute-lft-neg-in56.5%
times-frac56.5%
metadata-eval56.5%
metadata-eval56.5%
associate--l+56.5%
fma-define60.7%
Simplified60.7%
Taylor expanded in x around 0 84.0%
associate--l+84.0%
div-sub84.0%
Simplified84.0%
pow284.0%
pow284.0%
difference-of-squares88.2%
Applied egg-rr88.2%
Taylor expanded in x around inf 88.1%
div-inv88.1%
Applied egg-rr88.1%
if 4.10000000000000003e192 < x Initial program 56.8%
remove-double-neg56.8%
distribute-lft-neg-out56.8%
distribute-frac-neg256.8%
distribute-frac-neg56.8%
neg-mul-156.8%
distribute-lft-neg-out56.8%
*-commutative56.8%
distribute-lft-neg-in56.8%
times-frac56.8%
metadata-eval56.8%
metadata-eval56.8%
associate--l+56.8%
fma-define59.5%
Simplified59.5%
Taylor expanded in x around 0 46.3%
associate--l+46.3%
div-sub56.8%
Simplified56.8%
pow256.8%
pow256.8%
difference-of-squares75.8%
Applied egg-rr75.8%
Taylor expanded in y around 0 75.8%
associate-*r/85.2%
+-commutative85.2%
Simplified85.2%
x_m = (fabs.f64 x)
(FPCore (x_m y z)
:precision binary64
(let* ((t_0 (/ (- x_m z) y)))
(if (<= x_m 2.5e+59)
(* 0.5 (+ y (* z t_0)))
(if (<= x_m 4.4e+192)
(* 0.5 (+ y (/ (* x_m (- x_m z)) y)))
(* 0.5 (* (+ z x_m) t_0))))))x_m = fabs(x);
double code(double x_m, double y, double z) {
double t_0 = (x_m - z) / y;
double tmp;
if (x_m <= 2.5e+59) {
tmp = 0.5 * (y + (z * t_0));
} else if (x_m <= 4.4e+192) {
tmp = 0.5 * (y + ((x_m * (x_m - z)) / y));
} else {
tmp = 0.5 * ((z + x_m) * t_0);
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x_m - z) / y
if (x_m <= 2.5d+59) then
tmp = 0.5d0 * (y + (z * t_0))
else if (x_m <= 4.4d+192) then
tmp = 0.5d0 * (y + ((x_m * (x_m - z)) / y))
else
tmp = 0.5d0 * ((z + x_m) * t_0)
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z) {
double t_0 = (x_m - z) / y;
double tmp;
if (x_m <= 2.5e+59) {
tmp = 0.5 * (y + (z * t_0));
} else if (x_m <= 4.4e+192) {
tmp = 0.5 * (y + ((x_m * (x_m - z)) / y));
} else {
tmp = 0.5 * ((z + x_m) * t_0);
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z): t_0 = (x_m - z) / y tmp = 0 if x_m <= 2.5e+59: tmp = 0.5 * (y + (z * t_0)) elif x_m <= 4.4e+192: tmp = 0.5 * (y + ((x_m * (x_m - z)) / y)) else: tmp = 0.5 * ((z + x_m) * t_0) return tmp
x_m = abs(x) function code(x_m, y, z) t_0 = Float64(Float64(x_m - z) / y) tmp = 0.0 if (x_m <= 2.5e+59) tmp = Float64(0.5 * Float64(y + Float64(z * t_0))); elseif (x_m <= 4.4e+192) tmp = Float64(0.5 * Float64(y + Float64(Float64(x_m * Float64(x_m - z)) / y))); else tmp = Float64(0.5 * Float64(Float64(z + x_m) * t_0)); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z) t_0 = (x_m - z) / y; tmp = 0.0; if (x_m <= 2.5e+59) tmp = 0.5 * (y + (z * t_0)); elseif (x_m <= 4.4e+192) tmp = 0.5 * (y + ((x_m * (x_m - z)) / y)); else tmp = 0.5 * ((z + x_m) * t_0); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_] := Block[{t$95$0 = N[(N[(x$95$m - z), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x$95$m, 2.5e+59], N[(0.5 * N[(y + N[(z * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x$95$m, 4.4e+192], N[(0.5 * N[(y + N[(N[(x$95$m * N[(x$95$m - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(z + x$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := \frac{x\_m - z}{y}\\
\mathbf{if}\;x\_m \leq 2.5 \cdot 10^{+59}:\\
\;\;\;\;0.5 \cdot \left(y + z \cdot t\_0\right)\\
\mathbf{elif}\;x\_m \leq 4.4 \cdot 10^{+192}:\\
\;\;\;\;0.5 \cdot \left(y + \frac{x\_m \cdot \left(x\_m - z\right)}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(z + x\_m\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if x < 2.4999999999999999e59Initial program 69.4%
remove-double-neg69.4%
distribute-lft-neg-out69.4%
distribute-frac-neg269.4%
distribute-frac-neg69.4%
neg-mul-169.4%
distribute-lft-neg-out69.4%
*-commutative69.4%
distribute-lft-neg-in69.4%
times-frac69.4%
metadata-eval69.4%
metadata-eval69.4%
associate--l+69.4%
fma-define72.0%
Simplified72.0%
Taylor expanded in x around 0 86.9%
associate--l+86.9%
div-sub90.5%
Simplified90.5%
pow290.5%
pow290.5%
difference-of-squares94.1%
Applied egg-rr94.1%
associate-/l*99.9%
Applied egg-rr99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 79.6%
if 2.4999999999999999e59 < x < 4.4000000000000001e192Initial program 56.5%
remove-double-neg56.5%
distribute-lft-neg-out56.5%
distribute-frac-neg256.5%
distribute-frac-neg56.5%
neg-mul-156.5%
distribute-lft-neg-out56.5%
*-commutative56.5%
distribute-lft-neg-in56.5%
times-frac56.5%
metadata-eval56.5%
metadata-eval56.5%
associate--l+56.5%
fma-define60.7%
Simplified60.7%
Taylor expanded in x around 0 84.0%
associate--l+84.0%
div-sub84.0%
Simplified84.0%
pow284.0%
pow284.0%
difference-of-squares88.2%
Applied egg-rr88.2%
Taylor expanded in x around inf 88.1%
if 4.4000000000000001e192 < x Initial program 56.8%
remove-double-neg56.8%
distribute-lft-neg-out56.8%
distribute-frac-neg256.8%
distribute-frac-neg56.8%
neg-mul-156.8%
distribute-lft-neg-out56.8%
*-commutative56.8%
distribute-lft-neg-in56.8%
times-frac56.8%
metadata-eval56.8%
metadata-eval56.8%
associate--l+56.8%
fma-define59.5%
Simplified59.5%
Taylor expanded in x around 0 46.3%
associate--l+46.3%
div-sub56.8%
Simplified56.8%
pow256.8%
pow256.8%
difference-of-squares75.8%
Applied egg-rr75.8%
Taylor expanded in y around 0 75.8%
associate-*r/85.2%
+-commutative85.2%
Simplified85.2%
x_m = (fabs.f64 x) (FPCore (x_m y z) :precision binary64 (let* ((t_0 (/ (- x_m z) y))) (if (<= x_m 1.25e+125) (* 0.5 (+ y (* z t_0))) (* 0.5 (* (+ z x_m) t_0)))))
x_m = fabs(x);
double code(double x_m, double y, double z) {
double t_0 = (x_m - z) / y;
double tmp;
if (x_m <= 1.25e+125) {
tmp = 0.5 * (y + (z * t_0));
} else {
tmp = 0.5 * ((z + x_m) * t_0);
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x_m - z) / y
if (x_m <= 1.25d+125) then
tmp = 0.5d0 * (y + (z * t_0))
else
tmp = 0.5d0 * ((z + x_m) * t_0)
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z) {
double t_0 = (x_m - z) / y;
double tmp;
if (x_m <= 1.25e+125) {
tmp = 0.5 * (y + (z * t_0));
} else {
tmp = 0.5 * ((z + x_m) * t_0);
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z): t_0 = (x_m - z) / y tmp = 0 if x_m <= 1.25e+125: tmp = 0.5 * (y + (z * t_0)) else: tmp = 0.5 * ((z + x_m) * t_0) return tmp
x_m = abs(x) function code(x_m, y, z) t_0 = Float64(Float64(x_m - z) / y) tmp = 0.0 if (x_m <= 1.25e+125) tmp = Float64(0.5 * Float64(y + Float64(z * t_0))); else tmp = Float64(0.5 * Float64(Float64(z + x_m) * t_0)); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z) t_0 = (x_m - z) / y; tmp = 0.0; if (x_m <= 1.25e+125) tmp = 0.5 * (y + (z * t_0)); else tmp = 0.5 * ((z + x_m) * t_0); end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision]
code[x$95$m_, y_, z_] := Block[{t$95$0 = N[(N[(x$95$m - z), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x$95$m, 1.25e+125], N[(0.5 * N[(y + N[(z * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(z + x$95$m), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
t_0 := \frac{x\_m - z}{y}\\
\mathbf{if}\;x\_m \leq 1.25 \cdot 10^{+125}:\\
\;\;\;\;0.5 \cdot \left(y + z \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(z + x\_m\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if x < 1.24999999999999991e125Initial program 68.5%
remove-double-neg68.5%
distribute-lft-neg-out68.5%
distribute-frac-neg268.5%
distribute-frac-neg68.5%
neg-mul-168.5%
distribute-lft-neg-out68.5%
*-commutative68.5%
distribute-lft-neg-in68.5%
times-frac68.5%
metadata-eval68.5%
metadata-eval68.5%
associate--l+68.5%
fma-define70.9%
Simplified70.9%
Taylor expanded in x around 0 87.2%
associate--l+87.2%
div-sub90.6%
Simplified90.6%
pow290.6%
pow290.6%
difference-of-squares94.0%
Applied egg-rr94.0%
associate-/l*99.9%
Applied egg-rr99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around inf 78.9%
if 1.24999999999999991e125 < x Initial program 57.5%
remove-double-neg57.5%
distribute-lft-neg-out57.5%
distribute-frac-neg257.5%
distribute-frac-neg57.5%
neg-mul-157.5%
distribute-lft-neg-out57.5%
*-commutative57.5%
distribute-lft-neg-in57.5%
times-frac57.5%
metadata-eval57.5%
metadata-eval57.5%
associate--l+57.5%
fma-define61.5%
Simplified61.5%
Taylor expanded in x around 0 53.4%
associate--l+53.4%
div-sub61.4%
Simplified61.4%
pow261.4%
pow261.4%
difference-of-squares77.8%
Applied egg-rr77.8%
Taylor expanded in y around 0 75.9%
associate-*r/82.9%
+-commutative82.9%
Simplified82.9%
x_m = (fabs.f64 x) (FPCore (x_m y z) :precision binary64 (if (<= y 2.1e+158) (* 0.5 (* (+ z x_m) (/ (- x_m z) y))) (* 0.5 y)))
x_m = fabs(x);
double code(double x_m, double y, double z) {
double tmp;
if (y <= 2.1e+158) {
tmp = 0.5 * ((z + x_m) * ((x_m - z) / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 2.1d+158) then
tmp = 0.5d0 * ((z + x_m) * ((x_m - z) / y))
else
tmp = 0.5d0 * y
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z) {
double tmp;
if (y <= 2.1e+158) {
tmp = 0.5 * ((z + x_m) * ((x_m - z) / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z): tmp = 0 if y <= 2.1e+158: tmp = 0.5 * ((z + x_m) * ((x_m - z) / y)) else: tmp = 0.5 * y return tmp
x_m = abs(x) function code(x_m, y, z) tmp = 0.0 if (y <= 2.1e+158) tmp = Float64(0.5 * Float64(Float64(z + x_m) * Float64(Float64(x_m - z) / y))); else tmp = Float64(0.5 * y); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z) tmp = 0.0; if (y <= 2.1e+158) tmp = 0.5 * ((z + x_m) * ((x_m - z) / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_] := If[LessEqual[y, 2.1e+158], N[(0.5 * N[(N[(z + x$95$m), $MachinePrecision] * N[(N[(x$95$m - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;y \leq 2.1 \cdot 10^{+158}:\\
\;\;\;\;0.5 \cdot \left(\left(z + x\_m\right) \cdot \frac{x\_m - z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 2.0999999999999999e158Initial program 75.3%
remove-double-neg75.3%
distribute-lft-neg-out75.3%
distribute-frac-neg275.3%
distribute-frac-neg75.3%
neg-mul-175.3%
distribute-lft-neg-out75.3%
*-commutative75.3%
distribute-lft-neg-in75.3%
times-frac75.3%
metadata-eval75.3%
metadata-eval75.3%
associate--l+75.3%
fma-define78.5%
Simplified78.5%
Taylor expanded in x around 0 82.0%
associate--l+82.0%
div-sub87.0%
Simplified87.0%
pow287.0%
pow287.0%
difference-of-squares93.3%
Applied egg-rr93.3%
Taylor expanded in y around 0 70.6%
associate-*r/75.3%
+-commutative75.3%
Simplified75.3%
if 2.0999999999999999e158 < y Initial program 7.6%
remove-double-neg7.6%
distribute-lft-neg-out7.6%
distribute-frac-neg27.6%
distribute-frac-neg7.6%
neg-mul-17.6%
distribute-lft-neg-out7.6%
*-commutative7.6%
distribute-lft-neg-in7.6%
times-frac7.6%
metadata-eval7.6%
metadata-eval7.6%
associate--l+7.6%
fma-define7.6%
Simplified7.6%
Taylor expanded in y around inf 81.5%
*-commutative81.5%
Simplified81.5%
Final simplification76.1%
x_m = (fabs.f64 x) (FPCore (x_m y z) :precision binary64 (if (<= y 1.42e+104) (* (- x_m z) (* 0.5 (/ x_m y))) (* 0.5 y)))
x_m = fabs(x);
double code(double x_m, double y, double z) {
double tmp;
if (y <= 1.42e+104) {
tmp = (x_m - z) * (0.5 * (x_m / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 1.42d+104) then
tmp = (x_m - z) * (0.5d0 * (x_m / y))
else
tmp = 0.5d0 * y
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z) {
double tmp;
if (y <= 1.42e+104) {
tmp = (x_m - z) * (0.5 * (x_m / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z): tmp = 0 if y <= 1.42e+104: tmp = (x_m - z) * (0.5 * (x_m / y)) else: tmp = 0.5 * y return tmp
x_m = abs(x) function code(x_m, y, z) tmp = 0.0 if (y <= 1.42e+104) tmp = Float64(Float64(x_m - z) * Float64(0.5 * Float64(x_m / y))); else tmp = Float64(0.5 * y); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z) tmp = 0.0; if (y <= 1.42e+104) tmp = (x_m - z) * (0.5 * (x_m / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_] := If[LessEqual[y, 1.42e+104], N[(N[(x$95$m - z), $MachinePrecision] * N[(0.5 * N[(x$95$m / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.42 \cdot 10^{+104}:\\
\;\;\;\;\left(x\_m - z\right) \cdot \left(0.5 \cdot \frac{x\_m}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 1.42e104Initial program 74.9%
remove-double-neg74.9%
distribute-lft-neg-out74.9%
distribute-frac-neg274.9%
distribute-frac-neg74.9%
neg-mul-174.9%
distribute-lft-neg-out74.9%
*-commutative74.9%
distribute-lft-neg-in74.9%
times-frac74.9%
metadata-eval74.9%
metadata-eval74.9%
associate--l+74.9%
fma-define78.2%
Simplified78.2%
Taylor expanded in x around 0 81.9%
associate--l+81.9%
div-sub87.1%
Simplified87.1%
pow287.1%
pow287.1%
difference-of-squares93.8%
Applied egg-rr93.8%
Taylor expanded in x around inf 61.8%
Taylor expanded in y around 0 42.4%
*-commutative42.4%
associate-*r/44.1%
*-commutative44.1%
associate-*l*44.1%
Simplified44.1%
if 1.42e104 < y Initial program 26.1%
remove-double-neg26.1%
distribute-lft-neg-out26.1%
distribute-frac-neg226.1%
distribute-frac-neg26.1%
neg-mul-126.1%
distribute-lft-neg-out26.1%
*-commutative26.1%
distribute-lft-neg-in26.1%
times-frac26.1%
metadata-eval26.1%
metadata-eval26.1%
associate--l+26.1%
fma-define26.1%
Simplified26.1%
Taylor expanded in y around inf 77.5%
*-commutative77.5%
Simplified77.5%
Final simplification50.0%
x_m = (fabs.f64 x) (FPCore (x_m y z) :precision binary64 (if (<= y 3.6e-48) (* -0.5 (* x_m (/ z y))) (* 0.5 y)))
x_m = fabs(x);
double code(double x_m, double y, double z) {
double tmp;
if (y <= 3.6e-48) {
tmp = -0.5 * (x_m * (z / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
x_m = abs(x)
real(8) function code(x_m, y, z)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (y <= 3.6d-48) then
tmp = (-0.5d0) * (x_m * (z / y))
else
tmp = 0.5d0 * y
end if
code = tmp
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z) {
double tmp;
if (y <= 3.6e-48) {
tmp = -0.5 * (x_m * (z / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
x_m = math.fabs(x) def code(x_m, y, z): tmp = 0 if y <= 3.6e-48: tmp = -0.5 * (x_m * (z / y)) else: tmp = 0.5 * y return tmp
x_m = abs(x) function code(x_m, y, z) tmp = 0.0 if (y <= 3.6e-48) tmp = Float64(-0.5 * Float64(x_m * Float64(z / y))); else tmp = Float64(0.5 * y); end return tmp end
x_m = abs(x); function tmp_2 = code(x_m, y, z) tmp = 0.0; if (y <= 3.6e-48) tmp = -0.5 * (x_m * (z / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_] := If[LessEqual[y, 3.6e-48], N[(-0.5 * N[(x$95$m * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
x_m = \left|x\right|
\\
\begin{array}{l}
\mathbf{if}\;y \leq 3.6 \cdot 10^{-48}:\\
\;\;\;\;-0.5 \cdot \left(x\_m \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 3.6000000000000002e-48Initial program 73.5%
remove-double-neg73.5%
distribute-lft-neg-out73.5%
distribute-frac-neg273.5%
distribute-frac-neg73.5%
neg-mul-173.5%
distribute-lft-neg-out73.5%
*-commutative73.5%
distribute-lft-neg-in73.5%
times-frac73.5%
metadata-eval73.5%
metadata-eval73.5%
associate--l+73.5%
fma-define76.2%
Simplified76.2%
Taylor expanded in x around 0 81.6%
associate--l+81.6%
div-sub87.7%
Simplified87.7%
pow287.7%
pow287.7%
difference-of-squares93.2%
Applied egg-rr93.2%
Taylor expanded in x around inf 62.3%
Taylor expanded in z around inf 13.4%
associate-/l*14.5%
Simplified14.5%
if 3.6000000000000002e-48 < y Initial program 49.1%
remove-double-neg49.1%
distribute-lft-neg-out49.1%
distribute-frac-neg249.1%
distribute-frac-neg49.1%
neg-mul-149.1%
distribute-lft-neg-out49.1%
*-commutative49.1%
distribute-lft-neg-in49.1%
times-frac49.1%
metadata-eval49.1%
metadata-eval49.1%
associate--l+49.1%
fma-define51.8%
Simplified51.8%
Taylor expanded in y around inf 59.0%
*-commutative59.0%
Simplified59.0%
Final simplification27.5%
x_m = (fabs.f64 x) (FPCore (x_m y z) :precision binary64 (* 0.5 y))
x_m = fabs(x);
double code(double x_m, double y, double z) {
return 0.5 * y;
}
x_m = abs(x)
real(8) function code(x_m, y, z)
real(8), intent (in) :: x_m
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * y
end function
x_m = Math.abs(x);
public static double code(double x_m, double y, double z) {
return 0.5 * y;
}
x_m = math.fabs(x) def code(x_m, y, z): return 0.5 * y
x_m = abs(x) function code(x_m, y, z) return Float64(0.5 * y) end
x_m = abs(x); function tmp = code(x_m, y, z) tmp = 0.5 * y; end
x_m = N[Abs[x], $MachinePrecision] code[x$95$m_, y_, z_] := N[(0.5 * y), $MachinePrecision]
\begin{array}{l}
x_m = \left|x\right|
\\
0.5 \cdot y
\end{array}
Initial program 66.3%
remove-double-neg66.3%
distribute-lft-neg-out66.3%
distribute-frac-neg266.3%
distribute-frac-neg66.3%
neg-mul-166.3%
distribute-lft-neg-out66.3%
*-commutative66.3%
distribute-lft-neg-in66.3%
times-frac66.3%
metadata-eval66.3%
metadata-eval66.3%
associate--l+66.3%
fma-define69.1%
Simplified69.1%
Taylor expanded in y around inf 32.8%
*-commutative32.8%
Simplified32.8%
Final simplification32.8%
(FPCore (x y z) :precision binary64 (- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x))))
double code(double x, double y, double z) {
return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (y * 0.5d0) - (((0.5d0 / y) * (z + x)) * (z - x))
end function
public static double code(double x, double y, double z) {
return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x));
}
def code(x, y, z): return (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x))
function code(x, y, z) return Float64(Float64(y * 0.5) - Float64(Float64(Float64(0.5 / y) * Float64(z + x)) * Float64(z - x))) end
function tmp = code(x, y, z) tmp = (y * 0.5) - (((0.5 / y) * (z + x)) * (z - x)); end
code[x_, y_, z_] := N[(N[(y * 0.5), $MachinePrecision] - N[(N[(N[(0.5 / y), $MachinePrecision] * N[(z + x), $MachinePrecision]), $MachinePrecision] * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 0.5 - \left(\frac{0.5}{y} \cdot \left(z + x\right)\right) \cdot \left(z - x\right)
\end{array}
herbie shell --seed 2024137
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:alt
(! :herbie-platform default (- (* y 1/2) (* (* (/ 1/2 y) (+ z x)) (- z x))))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))