
(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 9 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}
(FPCore (x y z) :precision binary64 (* (- (* (+ x z) (/ (- z x) y)) y) -0.5))
double code(double x, double y, double z) {
return (((x + z) * ((z - x) / y)) - y) * -0.5;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x + z) * ((z - x) / y)) - y) * (-0.5d0)
end function
public static double code(double x, double y, double z) {
return (((x + z) * ((z - x) / y)) - y) * -0.5;
}
def code(x, y, z): return (((x + z) * ((z - x) / y)) - y) * -0.5
function code(x, y, z) return Float64(Float64(Float64(Float64(x + z) * Float64(Float64(z - x) / y)) - y) * -0.5) end
function tmp = code(x, y, z) tmp = (((x + z) * ((z - x) / y)) - y) * -0.5; end
code[x_, y_, z_] := N[(N[(N[(N[(x + z), $MachinePrecision] * N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + z\right) \cdot \frac{z - x}{y} - y\right) \cdot -0.5
\end{array}
Initial program 73.5%
sub-neg73.5%
+-commutative73.5%
neg-sub073.5%
associate-+l-73.5%
sub0-neg73.5%
neg-mul-173.5%
*-commutative73.5%
times-frac73.5%
associate--r+73.5%
div-sub73.5%
difference-of-squares75.9%
+-commutative75.9%
associate-*r/80.9%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* x (/ 0.5 y)))) (t_1 (* z (* -0.5 (/ z y)))))
(if (<= y -1.85e-39)
(* y 0.5)
(if (<= y -2.8e-175)
t_1
(if (<= y 2.2e-89)
t_0
(if (<= y 1.4e-15)
t_1
(if (<= y 5e+53) (* y 0.5) (if (<= y 8e+82) t_0 (* y 0.5)))))))))
double code(double x, double y, double z) {
double t_0 = x * (x * (0.5 / y));
double t_1 = z * (-0.5 * (z / y));
double tmp;
if (y <= -1.85e-39) {
tmp = y * 0.5;
} else if (y <= -2.8e-175) {
tmp = t_1;
} else if (y <= 2.2e-89) {
tmp = t_0;
} else if (y <= 1.4e-15) {
tmp = t_1;
} else if (y <= 5e+53) {
tmp = y * 0.5;
} else if (y <= 8e+82) {
tmp = t_0;
} else {
tmp = y * 0.5;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = x * (x * (0.5d0 / y))
t_1 = z * ((-0.5d0) * (z / y))
if (y <= (-1.85d-39)) then
tmp = y * 0.5d0
else if (y <= (-2.8d-175)) then
tmp = t_1
else if (y <= 2.2d-89) then
tmp = t_0
else if (y <= 1.4d-15) then
tmp = t_1
else if (y <= 5d+53) then
tmp = y * 0.5d0
else if (y <= 8d+82) then
tmp = t_0
else
tmp = y * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (x * (0.5 / y));
double t_1 = z * (-0.5 * (z / y));
double tmp;
if (y <= -1.85e-39) {
tmp = y * 0.5;
} else if (y <= -2.8e-175) {
tmp = t_1;
} else if (y <= 2.2e-89) {
tmp = t_0;
} else if (y <= 1.4e-15) {
tmp = t_1;
} else if (y <= 5e+53) {
tmp = y * 0.5;
} else if (y <= 8e+82) {
tmp = t_0;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y, z): t_0 = x * (x * (0.5 / y)) t_1 = z * (-0.5 * (z / y)) tmp = 0 if y <= -1.85e-39: tmp = y * 0.5 elif y <= -2.8e-175: tmp = t_1 elif y <= 2.2e-89: tmp = t_0 elif y <= 1.4e-15: tmp = t_1 elif y <= 5e+53: tmp = y * 0.5 elif y <= 8e+82: tmp = t_0 else: tmp = y * 0.5 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(x * Float64(0.5 / y))) t_1 = Float64(z * Float64(-0.5 * Float64(z / y))) tmp = 0.0 if (y <= -1.85e-39) tmp = Float64(y * 0.5); elseif (y <= -2.8e-175) tmp = t_1; elseif (y <= 2.2e-89) tmp = t_0; elseif (y <= 1.4e-15) tmp = t_1; elseif (y <= 5e+53) tmp = Float64(y * 0.5); elseif (y <= 8e+82) tmp = t_0; else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (x * (0.5 / y)); t_1 = z * (-0.5 * (z / y)); tmp = 0.0; if (y <= -1.85e-39) tmp = y * 0.5; elseif (y <= -2.8e-175) tmp = t_1; elseif (y <= 2.2e-89) tmp = t_0; elseif (y <= 1.4e-15) tmp = t_1; elseif (y <= 5e+53) tmp = y * 0.5; elseif (y <= 8e+82) tmp = t_0; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(-0.5 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.85e-39], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -2.8e-175], t$95$1, If[LessEqual[y, 2.2e-89], t$95$0, If[LessEqual[y, 1.4e-15], t$95$1, If[LessEqual[y, 5e+53], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, 8e+82], t$95$0, N[(y * 0.5), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
t_1 := z \cdot \left(-0.5 \cdot \frac{z}{y}\right)\\
\mathbf{if}\;y \leq -1.85 \cdot 10^{-39}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;y \leq -2.8 \cdot 10^{-175}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{-89}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-15}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+53}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;y \leq 8 \cdot 10^{+82}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -1.85000000000000007e-39 or 1.40000000000000007e-15 < y < 5.0000000000000004e53 or 7.9999999999999997e82 < y Initial program 57.8%
Taylor expanded in y around inf 67.6%
*-commutative67.6%
Simplified67.6%
if -1.85000000000000007e-39 < y < -2.8e-175 or 2.20000000000000012e-89 < y < 1.40000000000000007e-15Initial program 94.1%
sub-neg94.1%
+-commutative94.1%
neg-sub094.1%
associate-+l-94.1%
sub0-neg94.1%
neg-mul-194.1%
*-commutative94.1%
times-frac94.1%
associate--r+94.1%
div-sub94.0%
difference-of-squares99.6%
+-commutative99.6%
associate-*r/99.6%
associate-/l*99.6%
*-inverses99.6%
/-rgt-identity99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 91.7%
Taylor expanded in y around 0 70.5%
*-commutative70.5%
+-commutative70.5%
associate-*l/70.6%
associate-*l*70.6%
Simplified70.6%
Taylor expanded in z around inf 65.0%
unpow265.0%
associate-*r/65.0%
*-commutative65.0%
associate-*l*65.0%
Simplified65.0%
if -2.8e-175 < y < 2.20000000000000012e-89 or 5.0000000000000004e53 < y < 7.9999999999999997e82Initial program 89.7%
Taylor expanded in x around inf 62.0%
unpow262.0%
Simplified62.0%
Taylor expanded in x around 0 62.0%
*-commutative62.0%
unpow262.0%
metadata-eval62.0%
times-frac62.0%
associate-*r/61.9%
associate-*r*65.1%
*-commutative65.1%
associate-/r*65.1%
metadata-eval65.1%
Simplified65.1%
Final simplification66.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ x y) (* x 0.5))) (t_1 (* z (* -0.5 (/ z y)))))
(if (<= y -8.5e-36)
(* y 0.5)
(if (<= y -1.02e-173)
t_1
(if (<= y 7.6e-87)
t_0
(if (<= y 3.6e-17)
t_1
(if (<= y 5.8e+54)
(* y 0.5)
(if (<= y 8.2e+82) t_0 (* y 0.5)))))))))
double code(double x, double y, double z) {
double t_0 = (x / y) * (x * 0.5);
double t_1 = z * (-0.5 * (z / y));
double tmp;
if (y <= -8.5e-36) {
tmp = y * 0.5;
} else if (y <= -1.02e-173) {
tmp = t_1;
} else if (y <= 7.6e-87) {
tmp = t_0;
} else if (y <= 3.6e-17) {
tmp = t_1;
} else if (y <= 5.8e+54) {
tmp = y * 0.5;
} else if (y <= 8.2e+82) {
tmp = t_0;
} else {
tmp = y * 0.5;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (x / y) * (x * 0.5d0)
t_1 = z * ((-0.5d0) * (z / y))
if (y <= (-8.5d-36)) then
tmp = y * 0.5d0
else if (y <= (-1.02d-173)) then
tmp = t_1
else if (y <= 7.6d-87) then
tmp = t_0
else if (y <= 3.6d-17) then
tmp = t_1
else if (y <= 5.8d+54) then
tmp = y * 0.5d0
else if (y <= 8.2d+82) then
tmp = t_0
else
tmp = y * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / y) * (x * 0.5);
double t_1 = z * (-0.5 * (z / y));
double tmp;
if (y <= -8.5e-36) {
tmp = y * 0.5;
} else if (y <= -1.02e-173) {
tmp = t_1;
} else if (y <= 7.6e-87) {
tmp = t_0;
} else if (y <= 3.6e-17) {
tmp = t_1;
} else if (y <= 5.8e+54) {
tmp = y * 0.5;
} else if (y <= 8.2e+82) {
tmp = t_0;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y, z): t_0 = (x / y) * (x * 0.5) t_1 = z * (-0.5 * (z / y)) tmp = 0 if y <= -8.5e-36: tmp = y * 0.5 elif y <= -1.02e-173: tmp = t_1 elif y <= 7.6e-87: tmp = t_0 elif y <= 3.6e-17: tmp = t_1 elif y <= 5.8e+54: tmp = y * 0.5 elif y <= 8.2e+82: tmp = t_0 else: tmp = y * 0.5 return tmp
function code(x, y, z) t_0 = Float64(Float64(x / y) * Float64(x * 0.5)) t_1 = Float64(z * Float64(-0.5 * Float64(z / y))) tmp = 0.0 if (y <= -8.5e-36) tmp = Float64(y * 0.5); elseif (y <= -1.02e-173) tmp = t_1; elseif (y <= 7.6e-87) tmp = t_0; elseif (y <= 3.6e-17) tmp = t_1; elseif (y <= 5.8e+54) tmp = Float64(y * 0.5); elseif (y <= 8.2e+82) tmp = t_0; else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / y) * (x * 0.5); t_1 = z * (-0.5 * (z / y)); tmp = 0.0; if (y <= -8.5e-36) tmp = y * 0.5; elseif (y <= -1.02e-173) tmp = t_1; elseif (y <= 7.6e-87) tmp = t_0; elseif (y <= 3.6e-17) tmp = t_1; elseif (y <= 5.8e+54) tmp = y * 0.5; elseif (y <= 8.2e+82) tmp = t_0; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(z * N[(-0.5 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.5e-36], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -1.02e-173], t$95$1, If[LessEqual[y, 7.6e-87], t$95$0, If[LessEqual[y, 3.6e-17], t$95$1, If[LessEqual[y, 5.8e+54], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, 8.2e+82], t$95$0, N[(y * 0.5), $MachinePrecision]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
t_1 := z \cdot \left(-0.5 \cdot \frac{z}{y}\right)\\
\mathbf{if}\;y \leq -8.5 \cdot 10^{-36}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;y \leq -1.02 \cdot 10^{-173}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 7.6 \cdot 10^{-87}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{-17}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+54}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{+82}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -8.5000000000000007e-36 or 3.59999999999999995e-17 < y < 5.7999999999999997e54 or 8.1999999999999999e82 < y Initial program 57.8%
Taylor expanded in y around inf 67.6%
*-commutative67.6%
Simplified67.6%
if -8.5000000000000007e-36 < y < -1.02000000000000006e-173 or 7.6e-87 < y < 3.59999999999999995e-17Initial program 94.1%
sub-neg94.1%
+-commutative94.1%
neg-sub094.1%
associate-+l-94.1%
sub0-neg94.1%
neg-mul-194.1%
*-commutative94.1%
times-frac94.1%
associate--r+94.1%
div-sub94.0%
difference-of-squares99.6%
+-commutative99.6%
associate-*r/99.6%
associate-/l*99.6%
*-inverses99.6%
/-rgt-identity99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 91.7%
Taylor expanded in y around 0 70.5%
*-commutative70.5%
+-commutative70.5%
associate-*l/70.6%
associate-*l*70.6%
Simplified70.6%
Taylor expanded in z around inf 65.0%
unpow265.0%
associate-*r/65.0%
*-commutative65.0%
associate-*l*65.0%
Simplified65.0%
if -1.02000000000000006e-173 < y < 7.6e-87 or 5.7999999999999997e54 < y < 8.1999999999999999e82Initial program 89.7%
Taylor expanded in x around inf 62.0%
unpow262.0%
Simplified62.0%
times-frac65.2%
div-inv65.2%
metadata-eval65.2%
Applied egg-rr65.2%
Final simplification66.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ x y) (* x 0.5))))
(if (<= y -8.5e-36)
(* y 0.5)
(if (<= y -1.02e-174)
(* -0.5 (/ (* z z) y))
(if (<= y 1.15e-91)
t_0
(if (<= y 2.1e-15)
(* z (* -0.5 (/ z y)))
(if (<= y 8.6e+54)
(* y 0.5)
(if (<= y 8.6e+82) t_0 (* y 0.5)))))))))
double code(double x, double y, double z) {
double t_0 = (x / y) * (x * 0.5);
double tmp;
if (y <= -8.5e-36) {
tmp = y * 0.5;
} else if (y <= -1.02e-174) {
tmp = -0.5 * ((z * z) / y);
} else if (y <= 1.15e-91) {
tmp = t_0;
} else if (y <= 2.1e-15) {
tmp = z * (-0.5 * (z / y));
} else if (y <= 8.6e+54) {
tmp = y * 0.5;
} else if (y <= 8.6e+82) {
tmp = t_0;
} else {
tmp = y * 0.5;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (x / y) * (x * 0.5d0)
if (y <= (-8.5d-36)) then
tmp = y * 0.5d0
else if (y <= (-1.02d-174)) then
tmp = (-0.5d0) * ((z * z) / y)
else if (y <= 1.15d-91) then
tmp = t_0
else if (y <= 2.1d-15) then
tmp = z * ((-0.5d0) * (z / y))
else if (y <= 8.6d+54) then
tmp = y * 0.5d0
else if (y <= 8.6d+82) then
tmp = t_0
else
tmp = y * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / y) * (x * 0.5);
double tmp;
if (y <= -8.5e-36) {
tmp = y * 0.5;
} else if (y <= -1.02e-174) {
tmp = -0.5 * ((z * z) / y);
} else if (y <= 1.15e-91) {
tmp = t_0;
} else if (y <= 2.1e-15) {
tmp = z * (-0.5 * (z / y));
} else if (y <= 8.6e+54) {
tmp = y * 0.5;
} else if (y <= 8.6e+82) {
tmp = t_0;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y, z): t_0 = (x / y) * (x * 0.5) tmp = 0 if y <= -8.5e-36: tmp = y * 0.5 elif y <= -1.02e-174: tmp = -0.5 * ((z * z) / y) elif y <= 1.15e-91: tmp = t_0 elif y <= 2.1e-15: tmp = z * (-0.5 * (z / y)) elif y <= 8.6e+54: tmp = y * 0.5 elif y <= 8.6e+82: tmp = t_0 else: tmp = y * 0.5 return tmp
function code(x, y, z) t_0 = Float64(Float64(x / y) * Float64(x * 0.5)) tmp = 0.0 if (y <= -8.5e-36) tmp = Float64(y * 0.5); elseif (y <= -1.02e-174) tmp = Float64(-0.5 * Float64(Float64(z * z) / y)); elseif (y <= 1.15e-91) tmp = t_0; elseif (y <= 2.1e-15) tmp = Float64(z * Float64(-0.5 * Float64(z / y))); elseif (y <= 8.6e+54) tmp = Float64(y * 0.5); elseif (y <= 8.6e+82) tmp = t_0; else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / y) * (x * 0.5); tmp = 0.0; if (y <= -8.5e-36) tmp = y * 0.5; elseif (y <= -1.02e-174) tmp = -0.5 * ((z * z) / y); elseif (y <= 1.15e-91) tmp = t_0; elseif (y <= 2.1e-15) tmp = z * (-0.5 * (z / y)); elseif (y <= 8.6e+54) tmp = y * 0.5; elseif (y <= 8.6e+82) tmp = t_0; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -8.5e-36], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -1.02e-174], N[(-0.5 * N[(N[(z * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.15e-91], t$95$0, If[LessEqual[y, 2.1e-15], N[(z * N[(-0.5 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.6e+54], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, 8.6e+82], t$95$0, N[(y * 0.5), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\mathbf{if}\;y \leq -8.5 \cdot 10^{-36}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;y \leq -1.02 \cdot 10^{-174}:\\
\;\;\;\;-0.5 \cdot \frac{z \cdot z}{y}\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{-91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.1 \cdot 10^{-15}:\\
\;\;\;\;z \cdot \left(-0.5 \cdot \frac{z}{y}\right)\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{+54}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;y \leq 8.6 \cdot 10^{+82}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -8.5000000000000007e-36 or 2.09999999999999981e-15 < y < 8.59999999999999952e54 or 8.60000000000000029e82 < y Initial program 57.8%
Taylor expanded in y around inf 67.6%
*-commutative67.6%
Simplified67.6%
if -8.5000000000000007e-36 < y < -1.02000000000000011e-174Initial program 99.9%
Taylor expanded in z around inf 58.2%
*-commutative58.2%
unpow258.2%
Simplified58.2%
if -1.02000000000000011e-174 < y < 1.14999999999999998e-91 or 8.59999999999999952e54 < y < 8.60000000000000029e82Initial program 89.7%
Taylor expanded in x around inf 62.0%
unpow262.0%
Simplified62.0%
times-frac65.2%
div-inv65.2%
metadata-eval65.2%
Applied egg-rr65.2%
if 1.14999999999999998e-91 < y < 2.09999999999999981e-15Initial program 86.0%
sub-neg86.0%
+-commutative86.0%
neg-sub086.0%
associate-+l-86.0%
sub0-neg86.0%
neg-mul-186.0%
*-commutative86.0%
times-frac86.0%
associate--r+86.0%
div-sub85.9%
difference-of-squares99.3%
+-commutative99.3%
associate-*r/99.4%
associate-/l*99.4%
*-inverses99.4%
/-rgt-identity99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in z around inf 92.8%
Taylor expanded in y around 0 74.5%
*-commutative74.5%
+-commutative74.5%
associate-*l/74.6%
associate-*l*74.6%
Simplified74.6%
Taylor expanded in z around inf 74.5%
unpow274.5%
associate-*r/74.6%
*-commutative74.6%
associate-*l*74.6%
Simplified74.6%
Final simplification66.4%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 1e-34) (* -0.5 (- (/ z (/ y z)) y)) (* -0.5 (- (* (- z x) (/ x y)) y))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e-34) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = -0.5 * (((z - x) * (x / y)) - y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x * x) <= 1d-34) then
tmp = (-0.5d0) * ((z / (y / z)) - y)
else
tmp = (-0.5d0) * (((z - x) * (x / y)) - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e-34) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = -0.5 * (((z - x) * (x / y)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 1e-34: tmp = -0.5 * ((z / (y / z)) - y) else: tmp = -0.5 * (((z - x) * (x / y)) - y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 1e-34) tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y)); else tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) * Float64(x / y)) - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 1e-34) tmp = -0.5 * ((z / (y / z)) - y); else tmp = -0.5 * (((z - x) * (x / y)) - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e-34], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{-34}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{x}{y} - y\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 9.99999999999999928e-35Initial program 73.0%
sub-neg73.0%
+-commutative73.0%
neg-sub073.0%
associate-+l-73.0%
sub0-neg73.0%
neg-mul-173.0%
*-commutative73.0%
times-frac73.0%
associate--r+73.0%
div-sub72.9%
difference-of-squares72.9%
+-commutative72.9%
associate-*r/78.3%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 87.4%
unpow287.4%
associate-/l*94.8%
Simplified94.8%
if 9.99999999999999928e-35 < (*.f64 x x) Initial program 74.1%
sub-neg74.1%
+-commutative74.1%
neg-sub074.1%
associate-+l-74.1%
sub0-neg74.1%
neg-mul-174.1%
*-commutative74.1%
times-frac74.1%
associate--r+74.1%
div-sub74.1%
difference-of-squares79.0%
+-commutative79.0%
associate-*l/83.5%
*-commutative83.5%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 84.5%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (or (<= x 0.0033) (and (not (<= x 3e+29)) (<= x 9e+117))) (* y 0.5) (* x (* x (/ 0.5 y)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= 0.0033) || (!(x <= 3e+29) && (x <= 9e+117))) {
tmp = y * 0.5;
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= 0.0033d0) .or. (.not. (x <= 3d+29)) .and. (x <= 9d+117)) then
tmp = y * 0.5d0
else
tmp = x * (x * (0.5d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= 0.0033) || (!(x <= 3e+29) && (x <= 9e+117))) {
tmp = y * 0.5;
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= 0.0033) or (not (x <= 3e+29) and (x <= 9e+117)): tmp = y * 0.5 else: tmp = x * (x * (0.5 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= 0.0033) || (!(x <= 3e+29) && (x <= 9e+117))) tmp = Float64(y * 0.5); else tmp = Float64(x * Float64(x * Float64(0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= 0.0033) || (~((x <= 3e+29)) && (x <= 9e+117))) tmp = y * 0.5; else tmp = x * (x * (0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, 0.0033], And[N[Not[LessEqual[x, 3e+29]], $MachinePrecision], LessEqual[x, 9e+117]]], N[(y * 0.5), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 0.0033 \lor \neg \left(x \leq 3 \cdot 10^{+29}\right) \land x \leq 9 \cdot 10^{+117}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if x < 0.0033 or 2.9999999999999999e29 < x < 9e117Initial program 73.6%
Taylor expanded in y around inf 44.7%
*-commutative44.7%
Simplified44.7%
if 0.0033 < x < 2.9999999999999999e29 or 9e117 < x Initial program 73.4%
Taylor expanded in x around inf 67.3%
unpow267.3%
Simplified67.3%
Taylor expanded in x around 0 67.3%
*-commutative67.3%
unpow267.3%
metadata-eval67.3%
times-frac67.3%
associate-*r/67.2%
associate-*r*69.0%
*-commutative69.0%
associate-/r*69.0%
metadata-eval69.0%
Simplified69.0%
Final simplification49.2%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 1e+236) (* -0.5 (- (/ z (/ y z)) y)) (* (/ x y) (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+236) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = (x / y) * (x * 0.5);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x * x) <= 1d+236) then
tmp = (-0.5d0) * ((z / (y / z)) - y)
else
tmp = (x / y) * (x * 0.5d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+236) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = (x / y) * (x * 0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 1e+236: tmp = -0.5 * ((z / (y / z)) - y) else: tmp = (x / y) * (x * 0.5) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 1e+236) tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y)); else tmp = Float64(Float64(x / y) * Float64(x * 0.5)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 1e+236) tmp = -0.5 * ((z / (y / z)) - y); else tmp = (x / y) * (x * 0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e+236], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+236}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.00000000000000005e236Initial program 73.1%
sub-neg73.1%
+-commutative73.1%
neg-sub073.1%
associate-+l-73.1%
sub0-neg73.1%
neg-mul-173.1%
*-commutative73.1%
times-frac73.1%
associate--r+73.1%
div-sub73.1%
difference-of-squares73.1%
+-commutative73.1%
associate-*r/77.8%
associate-/l*99.8%
*-inverses99.8%
/-rgt-identity99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 80.3%
unpow280.3%
associate-/l*87.5%
Simplified87.5%
if 1.00000000000000005e236 < (*.f64 x x) Initial program 74.7%
Taylor expanded in x around inf 80.6%
unpow280.6%
Simplified80.6%
times-frac84.5%
div-inv84.5%
metadata-eval84.5%
Applied egg-rr84.5%
Final simplification86.7%
(FPCore (x y z) :precision binary64 (if (<= z 2.4e-10) (* (+ y (/ (* x x) y)) (- -0.5)) (* -0.5 (- (/ z (/ y z)) y))))
double code(double x, double y, double z) {
double tmp;
if (z <= 2.4e-10) {
tmp = (y + ((x * x) / y)) * -(-0.5);
} else {
tmp = -0.5 * ((z / (y / z)) - y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (z <= 2.4d-10) then
tmp = (y + ((x * x) / y)) * -(-0.5d0)
else
tmp = (-0.5d0) * ((z / (y / z)) - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2.4e-10) {
tmp = (y + ((x * x) / y)) * -(-0.5);
} else {
tmp = -0.5 * ((z / (y / z)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 2.4e-10: tmp = (y + ((x * x) / y)) * -(-0.5) else: tmp = -0.5 * ((z / (y / z)) - y) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 2.4e-10) tmp = Float64(Float64(y + Float64(Float64(x * x) / y)) * Float64(-(-0.5))); else tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2.4e-10) tmp = (y + ((x * x) / y)) * -(-0.5); else tmp = -0.5 * ((z / (y / z)) - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 2.4e-10], N[(N[(y + N[(N[(x * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] * (--0.5)), $MachinePrecision], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.4 \cdot 10^{-10}:\\
\;\;\;\;\left(y + \frac{x \cdot x}{y}\right) \cdot \left(--0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\end{array}
\end{array}
if z < 2.4e-10Initial program 74.8%
sub-neg74.8%
+-commutative74.8%
neg-sub074.8%
associate-+l-74.8%
sub0-neg74.8%
neg-mul-174.8%
*-commutative74.8%
times-frac74.8%
associate--r+74.8%
div-sub74.7%
difference-of-squares77.3%
+-commutative77.3%
associate-*r/81.3%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 76.5%
unpow276.5%
associate-*r/76.5%
neg-mul-176.5%
distribute-rgt-neg-in76.5%
Simplified76.5%
if 2.4e-10 < z Initial program 69.5%
sub-neg69.5%
+-commutative69.5%
neg-sub069.5%
associate-+l-69.5%
sub0-neg69.5%
neg-mul-169.5%
*-commutative69.5%
times-frac69.5%
associate--r+69.5%
div-sub69.5%
difference-of-squares71.3%
+-commutative71.3%
associate-*r/79.6%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in x around 0 70.7%
unpow270.7%
associate-/l*85.0%
Simplified85.0%
Final simplification78.5%
(FPCore (x y z) :precision binary64 (* y 0.5))
double code(double x, double y, double z) {
return y * 0.5;
}
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
end function
public static double code(double x, double y, double z) {
return y * 0.5;
}
def code(x, y, z): return y * 0.5
function code(x, y, z) return Float64(y * 0.5) end
function tmp = code(x, y, z) tmp = y * 0.5; end
code[x_, y_, z_] := N[(y * 0.5), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 0.5
\end{array}
Initial program 73.5%
Taylor expanded in y around inf 40.9%
*-commutative40.9%
Simplified40.9%
Final simplification40.9%
(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 2023224
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:herbie-target
(- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))