
(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}
(FPCore (x y z)
:precision binary64
(if (<= y -6.2e+161)
(* 0.5 (- y (/ z (/ y z))))
(if (<= y 3.2e+150)
(/ (fma x x (* (+ y z) (- y z))) (* y 2.0))
(* 0.5 (* (- y z) (/ (+ y z) y))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.2e+161) {
tmp = 0.5 * (y - (z / (y / z)));
} else if (y <= 3.2e+150) {
tmp = fma(x, x, ((y + z) * (y - z))) / (y * 2.0);
} else {
tmp = 0.5 * ((y - z) * ((y + z) / y));
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -6.2e+161) tmp = Float64(0.5 * Float64(y - Float64(z / Float64(y / z)))); elseif (y <= 3.2e+150) tmp = Float64(fma(x, x, Float64(Float64(y + z) * Float64(y - z))) / Float64(y * 2.0)); else tmp = Float64(0.5 * Float64(Float64(y - z) * Float64(Float64(y + z) / y))); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -6.2e+161], N[(0.5 * N[(y - N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.2e+150], N[(N[(x * x + N[(N[(y + z), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y - z), $MachinePrecision] * N[(N[(y + z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+161}:\\
\;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+150}:\\
\;\;\;\;\frac{\mathsf{fma}\left(x, x, \left(y + z\right) \cdot \left(y - z\right)\right)}{y \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(y - z\right) \cdot \frac{y + z}{y}\right)\\
\end{array}
\end{array}
if y < -6.20000000000000013e161Initial program 8.8%
Taylor expanded in x around 0 8.8%
unpow28.8%
unpow28.8%
div-sub8.8%
associate-/l*77.4%
*-inverses77.4%
/-rgt-identity77.4%
associate-/l*96.4%
Simplified96.4%
if -6.20000000000000013e161 < y < 3.20000000000000016e150Initial program 91.1%
associate--l+91.1%
fma-def93.6%
difference-of-squares93.6%
Simplified93.6%
if 3.20000000000000016e150 < y Initial program 11.7%
Taylor expanded in x around 0 11.7%
unpow211.7%
unpow211.7%
difference-of-squares16.3%
associate-/l*96.8%
associate-/r/96.9%
Simplified96.9%
Final simplification94.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.2e+161) (not (<= y 3.2e+99))) (* 0.5 (- y (/ z (/ y z)))) (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.2e+161) || !(y <= 3.2e+99)) {
tmp = 0.5 * (y - (z / (y / z)));
} else {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
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 ((y <= (-6.2d+161)) .or. (.not. (y <= 3.2d+99))) then
tmp = 0.5d0 * (y - (z / (y / z)))
else
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.2e+161) || !(y <= 3.2e+99)) {
tmp = 0.5 * (y - (z / (y / z)));
} else {
tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.2e+161) or not (y <= 3.2e+99): tmp = 0.5 * (y - (z / (y / z))) else: tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.2e+161) || !(y <= 3.2e+99)) tmp = Float64(0.5 * Float64(y - Float64(z / Float64(y / z)))); else tmp = Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.2e+161) || ~((y <= 3.2e+99))) tmp = 0.5 * (y - (z / (y / z))); else tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.2e+161], N[Not[LessEqual[y, 3.2e+99]], $MachinePrecision]], N[(0.5 * N[(y - N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 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}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+161} \lor \neg \left(y \leq 3.2 \cdot 10^{+99}\right):\\
\;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}\\
\end{array}
\end{array}
if y < -6.20000000000000013e161 or 3.19999999999999999e99 < y Initial program 20.8%
Taylor expanded in x around 0 18.1%
unpow218.1%
unpow218.1%
div-sub18.1%
associate-/l*75.4%
*-inverses75.4%
/-rgt-identity75.4%
associate-/l*93.0%
Simplified93.0%
if -6.20000000000000013e161 < y < 3.19999999999999999e99Initial program 92.1%
Final simplification92.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 0.5 (/ x (/ y x)))) (t_1 (* -0.5 (* z (/ z y)))))
(if (<= y -2.35e+14)
(* y 0.5)
(if (<= y -1.8e-48)
t_1
(if (<= y -6e-179)
t_0
(if (<= y -1.65e-206) t_1 (if (<= y 1.25e+28) t_0 (* y 0.5))))))))
double code(double x, double y, double z) {
double t_0 = 0.5 * (x / (y / x));
double t_1 = -0.5 * (z * (z / y));
double tmp;
if (y <= -2.35e+14) {
tmp = y * 0.5;
} else if (y <= -1.8e-48) {
tmp = t_1;
} else if (y <= -6e-179) {
tmp = t_0;
} else if (y <= -1.65e-206) {
tmp = t_1;
} else if (y <= 1.25e+28) {
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 = 0.5d0 * (x / (y / x))
t_1 = (-0.5d0) * (z * (z / y))
if (y <= (-2.35d+14)) then
tmp = y * 0.5d0
else if (y <= (-1.8d-48)) then
tmp = t_1
else if (y <= (-6d-179)) then
tmp = t_0
else if (y <= (-1.65d-206)) then
tmp = t_1
else if (y <= 1.25d+28) 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 = 0.5 * (x / (y / x));
double t_1 = -0.5 * (z * (z / y));
double tmp;
if (y <= -2.35e+14) {
tmp = y * 0.5;
} else if (y <= -1.8e-48) {
tmp = t_1;
} else if (y <= -6e-179) {
tmp = t_0;
} else if (y <= -1.65e-206) {
tmp = t_1;
} else if (y <= 1.25e+28) {
tmp = t_0;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y, z): t_0 = 0.5 * (x / (y / x)) t_1 = -0.5 * (z * (z / y)) tmp = 0 if y <= -2.35e+14: tmp = y * 0.5 elif y <= -1.8e-48: tmp = t_1 elif y <= -6e-179: tmp = t_0 elif y <= -1.65e-206: tmp = t_1 elif y <= 1.25e+28: tmp = t_0 else: tmp = y * 0.5 return tmp
function code(x, y, z) t_0 = Float64(0.5 * Float64(x / Float64(y / x))) t_1 = Float64(-0.5 * Float64(z * Float64(z / y))) tmp = 0.0 if (y <= -2.35e+14) tmp = Float64(y * 0.5); elseif (y <= -1.8e-48) tmp = t_1; elseif (y <= -6e-179) tmp = t_0; elseif (y <= -1.65e-206) tmp = t_1; elseif (y <= 1.25e+28) tmp = t_0; else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 0.5 * (x / (y / x)); t_1 = -0.5 * (z * (z / y)); tmp = 0.0; if (y <= -2.35e+14) tmp = y * 0.5; elseif (y <= -1.8e-48) tmp = t_1; elseif (y <= -6e-179) tmp = t_0; elseif (y <= -1.65e-206) tmp = t_1; elseif (y <= 1.25e+28) tmp = t_0; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.35e+14], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -1.8e-48], t$95$1, If[LessEqual[y, -6e-179], t$95$0, If[LessEqual[y, -1.65e-206], t$95$1, If[LessEqual[y, 1.25e+28], t$95$0, N[(y * 0.5), $MachinePrecision]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{x}{\frac{y}{x}}\\
t_1 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\mathbf{if}\;y \leq -2.35 \cdot 10^{+14}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;y \leq -1.8 \cdot 10^{-48}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -6 \cdot 10^{-179}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.65 \cdot 10^{-206}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.25 \cdot 10^{+28}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -2.35e14 or 1.24999999999999989e28 < y Initial program 52.2%
Taylor expanded in y around inf 75.3%
if -2.35e14 < y < -1.8000000000000001e-48 or -6.00000000000000012e-179 < y < -1.6499999999999999e-206Initial program 95.0%
Taylor expanded in z around inf 74.3%
*-commutative74.3%
unpow274.3%
associate-*l/74.2%
*-commutative74.2%
Simplified74.2%
if -1.8000000000000001e-48 < y < -6.00000000000000012e-179 or -1.6499999999999999e-206 < y < 1.24999999999999989e28Initial program 89.5%
Taylor expanded in x around inf 56.3%
unpow256.3%
associate-/l*57.1%
Simplified57.1%
Final simplification66.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 0.5 (/ x (/ y x)))))
(if (<= y -1.26e+14)
(* y 0.5)
(if (<= y -1.45e-48)
(* -0.5 (* z (/ z y)))
(if (<= y -1.2e-181)
t_0
(if (<= y -2e-206)
(* -0.5 (/ (* z z) y))
(if (<= y 4.8e+26) t_0 (* y 0.5))))))))
double code(double x, double y, double z) {
double t_0 = 0.5 * (x / (y / x));
double tmp;
if (y <= -1.26e+14) {
tmp = y * 0.5;
} else if (y <= -1.45e-48) {
tmp = -0.5 * (z * (z / y));
} else if (y <= -1.2e-181) {
tmp = t_0;
} else if (y <= -2e-206) {
tmp = -0.5 * ((z * z) / y);
} else if (y <= 4.8e+26) {
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 = 0.5d0 * (x / (y / x))
if (y <= (-1.26d+14)) then
tmp = y * 0.5d0
else if (y <= (-1.45d-48)) then
tmp = (-0.5d0) * (z * (z / y))
else if (y <= (-1.2d-181)) then
tmp = t_0
else if (y <= (-2d-206)) then
tmp = (-0.5d0) * ((z * z) / y)
else if (y <= 4.8d+26) 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 = 0.5 * (x / (y / x));
double tmp;
if (y <= -1.26e+14) {
tmp = y * 0.5;
} else if (y <= -1.45e-48) {
tmp = -0.5 * (z * (z / y));
} else if (y <= -1.2e-181) {
tmp = t_0;
} else if (y <= -2e-206) {
tmp = -0.5 * ((z * z) / y);
} else if (y <= 4.8e+26) {
tmp = t_0;
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y, z): t_0 = 0.5 * (x / (y / x)) tmp = 0 if y <= -1.26e+14: tmp = y * 0.5 elif y <= -1.45e-48: tmp = -0.5 * (z * (z / y)) elif y <= -1.2e-181: tmp = t_0 elif y <= -2e-206: tmp = -0.5 * ((z * z) / y) elif y <= 4.8e+26: tmp = t_0 else: tmp = y * 0.5 return tmp
function code(x, y, z) t_0 = Float64(0.5 * Float64(x / Float64(y / x))) tmp = 0.0 if (y <= -1.26e+14) tmp = Float64(y * 0.5); elseif (y <= -1.45e-48) tmp = Float64(-0.5 * Float64(z * Float64(z / y))); elseif (y <= -1.2e-181) tmp = t_0; elseif (y <= -2e-206) tmp = Float64(-0.5 * Float64(Float64(z * z) / y)); elseif (y <= 4.8e+26) tmp = t_0; else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 0.5 * (x / (y / x)); tmp = 0.0; if (y <= -1.26e+14) tmp = y * 0.5; elseif (y <= -1.45e-48) tmp = -0.5 * (z * (z / y)); elseif (y <= -1.2e-181) tmp = t_0; elseif (y <= -2e-206) tmp = -0.5 * ((z * z) / y); elseif (y <= 4.8e+26) tmp = t_0; else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.26e+14], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, -1.45e-48], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, -1.2e-181], t$95$0, If[LessEqual[y, -2e-206], N[(-0.5 * N[(N[(z * z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 4.8e+26], t$95$0, N[(y * 0.5), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{x}{\frac{y}{x}}\\
\mathbf{if}\;y \leq -1.26 \cdot 10^{+14}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;y \leq -1.45 \cdot 10^{-48}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\mathbf{elif}\;y \leq -1.2 \cdot 10^{-181}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -2 \cdot 10^{-206}:\\
\;\;\;\;-0.5 \cdot \frac{z \cdot z}{y}\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+26}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -1.26e14 or 4.80000000000000009e26 < y Initial program 52.2%
Taylor expanded in y around inf 75.3%
if -1.26e14 < y < -1.4500000000000001e-48Initial program 100.0%
Taylor expanded in z around inf 73.3%
*-commutative73.3%
unpow273.3%
associate-*l/73.3%
*-commutative73.3%
Simplified73.3%
if -1.4500000000000001e-48 < y < -1.2000000000000001e-181 or -2.00000000000000006e-206 < y < 4.80000000000000009e26Initial program 89.5%
Taylor expanded in x around inf 56.3%
unpow256.3%
associate-/l*57.1%
Simplified57.1%
if -1.2000000000000001e-181 < y < -2.00000000000000006e-206Initial program 88.1%
Taylor expanded in z around inf 75.7%
*-commutative75.7%
unpow275.7%
Simplified75.7%
Final simplification66.4%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 2e+113) (* 0.5 (- y (/ z (/ y z)))) (* 0.5 (+ y (* x (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+113) {
tmp = 0.5 * (y - (z / (y / z)));
} else {
tmp = 0.5 * (y + (x * (x / 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) <= 2d+113) then
tmp = 0.5d0 * (y - (z / (y / z)))
else
tmp = 0.5d0 * (y + (x * (x / y)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+113) {
tmp = 0.5 * (y - (z / (y / z)));
} else {
tmp = 0.5 * (y + (x * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+113: tmp = 0.5 * (y - (z / (y / z))) else: tmp = 0.5 * (y + (x * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+113) tmp = Float64(0.5 * Float64(y - Float64(z / Float64(y / z)))); else tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+113) tmp = 0.5 * (y - (z / (y / z))); else tmp = 0.5 * (y + (x * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+113], N[(0.5 * N[(y - N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+113}:\\
\;\;\;\;0.5 \cdot \left(y - \frac{z}{\frac{y}{z}}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 2e113Initial program 75.7%
Taylor expanded in x around 0 66.8%
unpow266.8%
unpow266.8%
div-sub66.8%
associate-/l*84.0%
*-inverses84.0%
/-rgt-identity84.0%
associate-/l*90.4%
Simplified90.4%
if 2e113 < (*.f64 x x) Initial program 70.1%
Taylor expanded in z around 0 71.1%
unpow271.1%
unpow271.1%
Simplified71.1%
Taylor expanded in x around 0 79.3%
distribute-lft-out79.3%
unpow279.3%
Simplified79.3%
associate-*l/86.4%
Applied egg-rr86.4%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (<= y -7.6e-16) (* y 0.5) (if (<= y 2.2e+27) (* 0.5 (/ x (/ y x))) (* y 0.5))))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.6e-16) {
tmp = y * 0.5;
} else if (y <= 2.2e+27) {
tmp = 0.5 * (x / (y / x));
} 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) :: tmp
if (y <= (-7.6d-16)) then
tmp = y * 0.5d0
else if (y <= 2.2d+27) then
tmp = 0.5d0 * (x / (y / x))
else
tmp = y * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -7.6e-16) {
tmp = y * 0.5;
} else if (y <= 2.2e+27) {
tmp = 0.5 * (x / (y / x));
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.6e-16: tmp = y * 0.5 elif y <= 2.2e+27: tmp = 0.5 * (x / (y / x)) else: tmp = y * 0.5 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.6e-16) tmp = Float64(y * 0.5); elseif (y <= 2.2e+27) tmp = Float64(0.5 * Float64(x / Float64(y / x))); else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -7.6e-16) tmp = y * 0.5; elseif (y <= 2.2e+27) tmp = 0.5 * (x / (y / x)); else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.6e-16], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, 2.2e+27], N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.6 \cdot 10^{-16}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;y \leq 2.2 \cdot 10^{+27}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -7.60000000000000024e-16 or 2.1999999999999999e27 < y Initial program 55.0%
Taylor expanded in y around inf 72.6%
if -7.60000000000000024e-16 < y < 2.1999999999999999e27Initial program 89.7%
Taylor expanded in x around inf 52.9%
unpow252.9%
associate-/l*53.6%
Simplified53.6%
Final simplification62.5%
(FPCore (x y z) :precision binary64 (if (<= z 8.2e+169) (* 0.5 (+ y (* x (/ x y)))) (* (/ z (/ y z)) -0.5)))
double code(double x, double y, double z) {
double tmp;
if (z <= 8.2e+169) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = (z / (y / z)) * -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 (z <= 8.2d+169) then
tmp = 0.5d0 * (y + (x * (x / y)))
else
tmp = (z / (y / z)) * (-0.5d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 8.2e+169) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = (z / (y / z)) * -0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 8.2e+169: tmp = 0.5 * (y + (x * (x / y))) else: tmp = (z / (y / z)) * -0.5 return tmp
function code(x, y, z) tmp = 0.0 if (z <= 8.2e+169) tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))); else tmp = Float64(Float64(z / Float64(y / z)) * -0.5); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 8.2e+169) tmp = 0.5 * (y + (x * (x / y))); else tmp = (z / (y / z)) * -0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 8.2e+169], N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 8.2 \cdot 10^{+169}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{y}{z}} \cdot -0.5\\
\end{array}
\end{array}
if z < 8.2000000000000006e169Initial program 74.7%
Taylor expanded in z around 0 56.7%
unpow256.7%
unpow256.7%
Simplified56.7%
Taylor expanded in x around 0 73.1%
distribute-lft-out73.1%
unpow273.1%
Simplified73.1%
associate-*l/76.2%
Applied egg-rr76.2%
if 8.2000000000000006e169 < z Initial program 61.1%
Taylor expanded in z around inf 74.7%
*-commutative74.7%
unpow274.7%
associate-/l*83.8%
Simplified83.8%
Final simplification76.9%
(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.4%
Taylor expanded in y around inf 38.6%
Final simplification38.6%
(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 2023275
(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)))