
(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 10 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 (* 0.5 (+ y (/ (+ x z) (/ y (- x z))))))
double code(double x, double y, double z) {
return 0.5 * (y + ((x + z) / (y / (x - z))));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * (y + ((x + z) / (y / (x - z))))
end function
public static double code(double x, double y, double z) {
return 0.5 * (y + ((x + z) / (y / (x - z))));
}
def code(x, y, z): return 0.5 * (y + ((x + z) / (y / (x - z))))
function code(x, y, z) return Float64(0.5 * Float64(y + Float64(Float64(x + z) / Float64(y / Float64(x - z))))) end
function tmp = code(x, y, z) tmp = 0.5 * (y + ((x + z) / (y / (x - z)))); end
code[x_, y_, z_] := N[(0.5 * N[(y + N[(N[(x + z), $MachinePrecision] / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(y + \frac{x + z}{\frac{y}{x - z}}\right)
\end{array}
Initial program 74.0%
remove-double-neg74.0%
distribute-lft-neg-out74.0%
distribute-frac-neg274.0%
distribute-frac-neg74.0%
neg-mul-174.0%
distribute-lft-neg-out74.0%
*-commutative74.0%
distribute-lft-neg-in74.0%
times-frac74.0%
metadata-eval74.0%
metadata-eval74.0%
associate--l+74.0%
fma-define75.9%
Simplified75.9%
Taylor expanded in x around 0 74.4%
associate--l+74.4%
div-sub81.0%
Simplified81.0%
pow281.0%
pow281.0%
difference-of-squares87.0%
Applied egg-rr87.0%
associate-/l*99.8%
Applied egg-rr99.8%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
(FPCore (x y z) :precision binary64 (if (or (<= y 4.4e+97) (and (not (<= y 9e+145)) (<= y 2.7e+206))) (* 0.5 (* (+ x z) (/ (- x z) y))) (* 0.5 y)))
double code(double x, double y, double z) {
double tmp;
if ((y <= 4.4e+97) || (!(y <= 9e+145) && (y <= 2.7e+206))) {
tmp = 0.5 * ((x + z) * ((x - z) / y));
} else {
tmp = 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 ((y <= 4.4d+97) .or. (.not. (y <= 9d+145)) .and. (y <= 2.7d+206)) then
tmp = 0.5d0 * ((x + z) * ((x - z) / y))
else
tmp = 0.5d0 * y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= 4.4e+97) || (!(y <= 9e+145) && (y <= 2.7e+206))) {
tmp = 0.5 * ((x + z) * ((x - z) / y));
} else {
tmp = 0.5 * y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= 4.4e+97) or (not (y <= 9e+145) and (y <= 2.7e+206)): tmp = 0.5 * ((x + z) * ((x - z) / y)) else: tmp = 0.5 * y return tmp
function code(x, y, z) tmp = 0.0 if ((y <= 4.4e+97) || (!(y <= 9e+145) && (y <= 2.7e+206))) tmp = Float64(0.5 * Float64(Float64(x + z) * Float64(Float64(x - z) / y))); else tmp = Float64(0.5 * y); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= 4.4e+97) || (~((y <= 9e+145)) && (y <= 2.7e+206))) tmp = 0.5 * ((x + z) * ((x - z) / y)); else tmp = 0.5 * y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, 4.4e+97], And[N[Not[LessEqual[y, 9e+145]], $MachinePrecision], LessEqual[y, 2.7e+206]]], N[(0.5 * N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 4.4 \cdot 10^{+97} \lor \neg \left(y \leq 9 \cdot 10^{+145}\right) \land y \leq 2.7 \cdot 10^{+206}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot \frac{x - z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < 4.4000000000000002e97 or 8.9999999999999996e145 < y < 2.70000000000000003e206Initial program 76.6%
remove-double-neg76.6%
distribute-lft-neg-out76.6%
distribute-frac-neg276.6%
distribute-frac-neg76.6%
neg-mul-176.6%
distribute-lft-neg-out76.6%
*-commutative76.6%
distribute-lft-neg-in76.6%
times-frac76.6%
metadata-eval76.6%
metadata-eval76.6%
associate--l+76.6%
fma-define78.8%
Simplified78.8%
Taylor expanded in x around 0 74.6%
associate--l+74.6%
div-sub82.0%
Simplified82.0%
pow282.0%
pow282.0%
difference-of-squares88.7%
Applied egg-rr88.7%
+-commutative88.7%
associate-/l*99.8%
fma-define99.8%
Applied egg-rr99.8%
Taylor expanded in y around 0 72.6%
associate-*r/72.6%
difference-of-squares65.9%
unpow265.9%
unpow265.9%
associate-*r/65.9%
unpow265.9%
unpow265.9%
difference-of-squares72.6%
associate-/l*79.0%
+-commutative79.0%
Simplified79.0%
if 4.4000000000000002e97 < y < 8.9999999999999996e145 or 2.70000000000000003e206 < y Initial program 52.5%
remove-double-neg52.5%
distribute-lft-neg-out52.5%
distribute-frac-neg252.5%
distribute-frac-neg52.5%
neg-mul-152.5%
distribute-lft-neg-out52.5%
*-commutative52.5%
distribute-lft-neg-in52.5%
times-frac52.5%
metadata-eval52.5%
metadata-eval52.5%
associate--l+52.5%
fma-define52.5%
Simplified52.5%
Taylor expanded in y around inf 72.8%
Final simplification78.3%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (- x z) y))) (if (<= (* x x) 5e+121) (* 0.5 (+ y (* z t_0))) (* 0.5 (+ y (* x t_0))))))
double code(double x, double y, double z) {
double t_0 = (x - z) / y;
double tmp;
if ((x * x) <= 5e+121) {
tmp = 0.5 * (y + (z * t_0));
} else {
tmp = 0.5 * (y + (x * t_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) :: t_0
real(8) :: tmp
t_0 = (x - z) / y
if ((x * x) <= 5d+121) then
tmp = 0.5d0 * (y + (z * t_0))
else
tmp = 0.5d0 * (y + (x * t_0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - z) / y;
double tmp;
if ((x * x) <= 5e+121) {
tmp = 0.5 * (y + (z * t_0));
} else {
tmp = 0.5 * (y + (x * t_0));
}
return tmp;
}
def code(x, y, z): t_0 = (x - z) / y tmp = 0 if (x * x) <= 5e+121: tmp = 0.5 * (y + (z * t_0)) else: tmp = 0.5 * (y + (x * t_0)) return tmp
function code(x, y, z) t_0 = Float64(Float64(x - z) / y) tmp = 0.0 if (Float64(x * x) <= 5e+121) tmp = Float64(0.5 * Float64(y + Float64(z * t_0))); else tmp = Float64(0.5 * Float64(y + Float64(x * t_0))); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - z) / y; tmp = 0.0; if ((x * x) <= 5e+121) tmp = 0.5 * (y + (z * t_0)); else tmp = 0.5 * (y + (x * t_0)); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 5e+121], N[(0.5 * N[(y + N[(z * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(x * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - z}{y}\\
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+121}:\\
\;\;\;\;0.5 \cdot \left(y + z \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot t\_0\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 5.00000000000000007e121Initial program 78.1%
remove-double-neg78.1%
distribute-lft-neg-out78.1%
distribute-frac-neg278.1%
distribute-frac-neg78.1%
neg-mul-178.1%
distribute-lft-neg-out78.1%
*-commutative78.1%
distribute-lft-neg-in78.1%
times-frac78.1%
metadata-eval78.1%
metadata-eval78.1%
associate--l+78.1%
fma-define78.1%
Simplified78.1%
Taylor expanded in x around 0 87.1%
associate--l+87.1%
div-sub87.1%
Simplified87.1%
pow287.1%
pow287.1%
difference-of-squares87.1%
Applied egg-rr87.1%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 91.9%
if 5.00000000000000007e121 < (*.f64 x x) Initial program 68.1%
remove-double-neg68.1%
distribute-lft-neg-out68.1%
distribute-frac-neg268.1%
distribute-frac-neg68.1%
neg-mul-168.1%
distribute-lft-neg-out68.1%
*-commutative68.1%
distribute-lft-neg-in68.1%
times-frac68.1%
metadata-eval68.1%
metadata-eval68.1%
associate--l+68.1%
fma-define72.8%
Simplified72.8%
Taylor expanded in x around 0 56.3%
associate--l+56.3%
div-sub72.4%
Simplified72.4%
pow272.4%
pow272.4%
difference-of-squares86.9%
Applied egg-rr86.9%
Taylor expanded in x around inf 80.7%
associate-/l*89.9%
*-commutative89.9%
Applied egg-rr89.9%
Final simplification91.1%
(FPCore (x y z) :precision binary64 (let* ((t_0 (/ (- x z) y))) (if (<= (* x x) 4e+116) (* 0.5 (+ y (* z t_0))) (* 0.5 (* (+ x z) t_0)))))
double code(double x, double y, double z) {
double t_0 = (x - z) / y;
double tmp;
if ((x * x) <= 4e+116) {
tmp = 0.5 * (y + (z * t_0));
} else {
tmp = 0.5 * ((x + z) * t_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) :: t_0
real(8) :: tmp
t_0 = (x - z) / y
if ((x * x) <= 4d+116) then
tmp = 0.5d0 * (y + (z * t_0))
else
tmp = 0.5d0 * ((x + z) * t_0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x - z) / y;
double tmp;
if ((x * x) <= 4e+116) {
tmp = 0.5 * (y + (z * t_0));
} else {
tmp = 0.5 * ((x + z) * t_0);
}
return tmp;
}
def code(x, y, z): t_0 = (x - z) / y tmp = 0 if (x * x) <= 4e+116: tmp = 0.5 * (y + (z * t_0)) else: tmp = 0.5 * ((x + z) * t_0) return tmp
function code(x, y, z) t_0 = Float64(Float64(x - z) / y) tmp = 0.0 if (Float64(x * x) <= 4e+116) tmp = Float64(0.5 * Float64(y + Float64(z * t_0))); else tmp = Float64(0.5 * Float64(Float64(x + z) * t_0)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x - z) / y; tmp = 0.0; if ((x * x) <= 4e+116) tmp = 0.5 * (y + (z * t_0)); else tmp = 0.5 * ((x + z) * t_0); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[N[(x * x), $MachinePrecision], 4e+116], N[(0.5 * N[(y + N[(z * t$95$0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(x + z), $MachinePrecision] * t$95$0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x - z}{y}\\
\mathbf{if}\;x \cdot x \leq 4 \cdot 10^{+116}:\\
\;\;\;\;0.5 \cdot \left(y + z \cdot t\_0\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(x + z\right) \cdot t\_0\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 4.00000000000000006e116Initial program 77.8%
remove-double-neg77.8%
distribute-lft-neg-out77.8%
distribute-frac-neg277.8%
distribute-frac-neg77.8%
neg-mul-177.8%
distribute-lft-neg-out77.8%
*-commutative77.8%
distribute-lft-neg-in77.8%
times-frac77.8%
metadata-eval77.8%
metadata-eval77.8%
associate--l+77.8%
fma-define77.8%
Simplified77.8%
Taylor expanded in x around 0 87.0%
associate--l+87.0%
div-sub86.9%
Simplified86.9%
pow286.9%
pow286.9%
difference-of-squares86.9%
Applied egg-rr86.9%
associate-/l*99.8%
Applied egg-rr99.8%
Taylor expanded in x around 0 92.0%
if 4.00000000000000006e116 < (*.f64 x x) Initial program 68.7%
remove-double-neg68.7%
distribute-lft-neg-out68.7%
distribute-frac-neg268.7%
distribute-frac-neg68.7%
neg-mul-168.7%
distribute-lft-neg-out68.7%
*-commutative68.7%
distribute-lft-neg-in68.7%
times-frac68.7%
metadata-eval68.7%
metadata-eval68.7%
associate--l+68.7%
fma-define73.3%
Simplified73.3%
Taylor expanded in x around 0 57.1%
associate--l+57.1%
div-sub72.9%
Simplified72.9%
pow272.9%
pow272.9%
difference-of-squares87.1%
Applied egg-rr87.1%
+-commutative87.1%
associate-/l*99.9%
fma-define99.9%
Applied egg-rr99.9%
Taylor expanded in y around 0 82.0%
associate-*r/82.0%
difference-of-squares67.7%
unpow267.7%
unpow267.7%
associate-*r/67.7%
unpow267.7%
unpow267.7%
difference-of-squares82.0%
associate-/l*91.3%
+-commutative91.3%
Simplified91.3%
Final simplification91.7%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 4000000000.0) (* z (/ 1.0 (/ y (* z -0.5)))) (* 0.5 (* x (/ (- x z) y)))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4000000000.0) {
tmp = z * (1.0 / (y / (z * -0.5)));
} else {
tmp = 0.5 * (x * ((x - 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 ((x * x) <= 4000000000.0d0) then
tmp = z * (1.0d0 / (y / (z * (-0.5d0))))
else
tmp = 0.5d0 * (x * ((x - z) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4000000000.0) {
tmp = z * (1.0 / (y / (z * -0.5)));
} else {
tmp = 0.5 * (x * ((x - z) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 4000000000.0: tmp = z * (1.0 / (y / (z * -0.5))) else: tmp = 0.5 * (x * ((x - z) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 4000000000.0) tmp = Float64(z * Float64(1.0 / Float64(y / Float64(z * -0.5)))); else tmp = Float64(0.5 * Float64(x * Float64(Float64(x - z) / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 4000000000.0) tmp = z * (1.0 / (y / (z * -0.5))); else tmp = 0.5 * (x * ((x - z) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 4000000000.0], N[(z * N[(1.0 / N[(y / N[(z * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4000000000:\\
\;\;\;\;z \cdot \frac{1}{\frac{y}{z \cdot -0.5}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{x - z}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 4e9Initial program 76.4%
remove-double-neg76.4%
distribute-lft-neg-out76.4%
distribute-frac-neg276.4%
distribute-frac-neg76.4%
neg-mul-176.4%
distribute-lft-neg-out76.4%
*-commutative76.4%
distribute-lft-neg-in76.4%
times-frac76.4%
metadata-eval76.4%
metadata-eval76.4%
associate--l+76.4%
fma-define76.4%
Simplified76.4%
Taylor expanded in z around inf 48.1%
*-commutative48.1%
associate-*l/48.1%
Simplified48.1%
associate-/l*48.0%
pow248.0%
associate-*l*54.1%
Applied egg-rr54.1%
associate-*r/54.1%
clear-num54.1%
Applied egg-rr54.1%
if 4e9 < (*.f64 x x) Initial program 71.2%
remove-double-neg71.2%
distribute-lft-neg-out71.2%
distribute-frac-neg271.2%
distribute-frac-neg71.2%
neg-mul-171.2%
distribute-lft-neg-out71.2%
*-commutative71.2%
distribute-lft-neg-in71.2%
times-frac71.2%
metadata-eval71.2%
metadata-eval71.2%
associate--l+71.2%
fma-define75.4%
Simplified75.4%
Taylor expanded in x around 0 60.9%
associate--l+60.9%
div-sub75.0%
Simplified75.0%
pow275.0%
pow275.0%
difference-of-squares87.7%
Applied egg-rr87.7%
Taylor expanded in x around inf 79.9%
Taylor expanded in y around 0 70.6%
associate-*r/75.5%
Simplified75.5%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 4000000000.0) (* z (* z (/ -0.5 y))) (* 0.5 (* x (/ (- x z) y)))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4000000000.0) {
tmp = z * (z * (-0.5 / y));
} else {
tmp = 0.5 * (x * ((x - 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 ((x * x) <= 4000000000.0d0) then
tmp = z * (z * ((-0.5d0) / y))
else
tmp = 0.5d0 * (x * ((x - z) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4000000000.0) {
tmp = z * (z * (-0.5 / y));
} else {
tmp = 0.5 * (x * ((x - z) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 4000000000.0: tmp = z * (z * (-0.5 / y)) else: tmp = 0.5 * (x * ((x - z) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 4000000000.0) tmp = Float64(z * Float64(z * Float64(-0.5 / y))); else tmp = Float64(0.5 * Float64(x * Float64(Float64(x - z) / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 4000000000.0) tmp = z * (z * (-0.5 / y)); else tmp = 0.5 * (x * ((x - z) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 4000000000.0], N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(x * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4000000000:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{x - z}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 4e9Initial program 76.4%
remove-double-neg76.4%
distribute-lft-neg-out76.4%
distribute-frac-neg276.4%
distribute-frac-neg76.4%
neg-mul-176.4%
distribute-lft-neg-out76.4%
*-commutative76.4%
distribute-lft-neg-in76.4%
times-frac76.4%
metadata-eval76.4%
metadata-eval76.4%
associate--l+76.4%
fma-define76.4%
Simplified76.4%
Taylor expanded in z around inf 48.1%
*-commutative48.1%
associate-*l/48.1%
Simplified48.1%
associate-/l*48.0%
pow248.0%
associate-*l*54.1%
Applied egg-rr54.1%
if 4e9 < (*.f64 x x) Initial program 71.2%
remove-double-neg71.2%
distribute-lft-neg-out71.2%
distribute-frac-neg271.2%
distribute-frac-neg71.2%
neg-mul-171.2%
distribute-lft-neg-out71.2%
*-commutative71.2%
distribute-lft-neg-in71.2%
times-frac71.2%
metadata-eval71.2%
metadata-eval71.2%
associate--l+71.2%
fma-define75.4%
Simplified75.4%
Taylor expanded in x around 0 60.9%
associate--l+60.9%
div-sub75.0%
Simplified75.0%
pow275.0%
pow275.0%
difference-of-squares87.7%
Applied egg-rr87.7%
Taylor expanded in x around inf 79.9%
Taylor expanded in y around 0 70.6%
associate-*r/75.5%
Simplified75.5%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 1e+70) (* z (* z (/ -0.5 y))) (* (* x x) (/ 0.5 y))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+70) {
tmp = z * (z * (-0.5 / y));
} 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 * x) <= 1d+70) then
tmp = z * (z * ((-0.5d0) / y))
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 * x) <= 1e+70) {
tmp = z * (z * (-0.5 / y));
} else {
tmp = (x * x) * (0.5 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 1e+70: tmp = z * (z * (-0.5 / y)) else: tmp = (x * x) * (0.5 / y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 1e+70) tmp = Float64(z * Float64(z * Float64(-0.5 / y))); else tmp = Float64(Float64(x * x) * Float64(0.5 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 1e+70) tmp = z * (z * (-0.5 / y)); else tmp = (x * x) * (0.5 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e+70], N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+70}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y}\\
\end{array}
\end{array}
if (*.f64 x x) < 1.00000000000000007e70Initial program 77.3%
remove-double-neg77.3%
distribute-lft-neg-out77.3%
distribute-frac-neg277.3%
distribute-frac-neg77.3%
neg-mul-177.3%
distribute-lft-neg-out77.3%
*-commutative77.3%
distribute-lft-neg-in77.3%
times-frac77.3%
metadata-eval77.3%
metadata-eval77.3%
associate--l+77.3%
fma-define77.3%
Simplified77.3%
Taylor expanded in z around inf 48.5%
*-commutative48.5%
associate-*l/48.5%
Simplified48.5%
associate-/l*48.4%
pow248.4%
associate-*l*54.3%
Applied egg-rr54.3%
if 1.00000000000000007e70 < (*.f64 x x) Initial program 70.0%
remove-double-neg70.0%
distribute-lft-neg-out70.0%
distribute-frac-neg270.0%
distribute-frac-neg70.0%
neg-mul-170.0%
distribute-lft-neg-out70.0%
*-commutative70.0%
distribute-lft-neg-in70.0%
times-frac70.0%
metadata-eval70.0%
metadata-eval70.0%
associate--l+70.0%
fma-define74.3%
Simplified74.3%
Taylor expanded in x around inf 65.1%
*-commutative65.1%
associate-*l/65.1%
associate-*r/65.1%
Simplified65.1%
pow265.1%
Applied egg-rr65.1%
(FPCore (x y z) :precision binary64 (* 0.5 (+ y (* (+ x z) (/ (- x z) y)))))
double code(double x, double y, double z) {
return 0.5 * (y + ((x + z) * ((x - z) / y)));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * (y + ((x + z) * ((x - z) / y)))
end function
public static double code(double x, double y, double z) {
return 0.5 * (y + ((x + z) * ((x - z) / y)));
}
def code(x, y, z): return 0.5 * (y + ((x + z) * ((x - z) / y)))
function code(x, y, z) return Float64(0.5 * Float64(y + Float64(Float64(x + z) * Float64(Float64(x - z) / y)))) end
function tmp = code(x, y, z) tmp = 0.5 * (y + ((x + z) * ((x - z) / y))); end
code[x_, y_, z_] := N[(0.5 * N[(y + N[(N[(x + z), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot \left(y + \left(x + z\right) \cdot \frac{x - z}{y}\right)
\end{array}
Initial program 74.0%
remove-double-neg74.0%
distribute-lft-neg-out74.0%
distribute-frac-neg274.0%
distribute-frac-neg74.0%
neg-mul-174.0%
distribute-lft-neg-out74.0%
*-commutative74.0%
distribute-lft-neg-in74.0%
times-frac74.0%
metadata-eval74.0%
metadata-eval74.0%
associate--l+74.0%
fma-define75.9%
Simplified75.9%
Taylor expanded in x around 0 74.4%
associate--l+74.4%
div-sub81.0%
Simplified81.0%
pow281.0%
pow281.0%
difference-of-squares87.0%
Applied egg-rr87.0%
associate-/l*99.8%
Applied egg-rr99.8%
(FPCore (x y z) :precision binary64 (if (<= z 1.75e+21) (* 0.5 y) (* z (* z (/ -0.5 y)))))
double code(double x, double y, double z) {
double tmp;
if (z <= 1.75e+21) {
tmp = 0.5 * y;
} else {
tmp = z * (z * (-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 (z <= 1.75d+21) then
tmp = 0.5d0 * y
else
tmp = z * (z * ((-0.5d0) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= 1.75e+21) {
tmp = 0.5 * y;
} else {
tmp = z * (z * (-0.5 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= 1.75e+21: tmp = 0.5 * y else: tmp = z * (z * (-0.5 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= 1.75e+21) tmp = Float64(0.5 * y); else tmp = Float64(z * Float64(z * Float64(-0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 1.75e+21) tmp = 0.5 * y; else tmp = z * (z * (-0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, 1.75e+21], N[(0.5 * y), $MachinePrecision], N[(z * N[(z * N[(-0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 1.75 \cdot 10^{+21}:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{else}:\\
\;\;\;\;z \cdot \left(z \cdot \frac{-0.5}{y}\right)\\
\end{array}
\end{array}
if z < 1.75e21Initial program 76.3%
remove-double-neg76.3%
distribute-lft-neg-out76.3%
distribute-frac-neg276.3%
distribute-frac-neg76.3%
neg-mul-176.3%
distribute-lft-neg-out76.3%
*-commutative76.3%
distribute-lft-neg-in76.3%
times-frac76.3%
metadata-eval76.3%
metadata-eval76.3%
associate--l+76.3%
fma-define77.9%
Simplified77.9%
Taylor expanded in y around inf 33.3%
if 1.75e21 < z Initial program 67.8%
remove-double-neg67.8%
distribute-lft-neg-out67.8%
distribute-frac-neg267.8%
distribute-frac-neg67.8%
neg-mul-167.8%
distribute-lft-neg-out67.8%
*-commutative67.8%
distribute-lft-neg-in67.8%
times-frac67.8%
metadata-eval67.8%
metadata-eval67.8%
associate--l+67.8%
fma-define70.7%
Simplified70.7%
Taylor expanded in z around inf 48.2%
*-commutative48.2%
associate-*l/48.2%
Simplified48.2%
associate-/l*48.2%
pow248.2%
associate-*l*58.5%
Applied egg-rr58.5%
(FPCore (x y z) :precision binary64 (* 0.5 y))
double code(double x, double y, double z) {
return 0.5 * y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 0.5d0 * y
end function
public static double code(double x, double y, double z) {
return 0.5 * y;
}
def code(x, y, z): return 0.5 * y
function code(x, y, z) return Float64(0.5 * y) end
function tmp = code(x, y, z) tmp = 0.5 * y; end
code[x_, y_, z_] := N[(0.5 * y), $MachinePrecision]
\begin{array}{l}
\\
0.5 \cdot y
\end{array}
Initial program 74.0%
remove-double-neg74.0%
distribute-lft-neg-out74.0%
distribute-frac-neg274.0%
distribute-frac-neg74.0%
neg-mul-174.0%
distribute-lft-neg-out74.0%
*-commutative74.0%
distribute-lft-neg-in74.0%
times-frac74.0%
metadata-eval74.0%
metadata-eval74.0%
associate--l+74.0%
fma-define75.9%
Simplified75.9%
Taylor expanded in y around inf 27.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 2024132
(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)))