
(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 11 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 (* (fma (/ (+ z x) y) (- z x) (- y)) -0.5))
double code(double x, double y, double z) {
return fma(((z + x) / y), (z - x), -y) * -0.5;
}
function code(x, y, z) return Float64(fma(Float64(Float64(z + x) / y), Float64(z - x), Float64(-y)) * -0.5) end
code[x_, y_, z_] := N[(N[(N[(N[(z + x), $MachinePrecision] / y), $MachinePrecision] * N[(z - x), $MachinePrecision] + (-y)), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(\frac{z + x}{y}, z - x, -y\right) \cdot -0.5
\end{array}
Initial program 63.7%
sub-neg63.7%
+-commutative63.7%
neg-sub063.7%
associate-+l-63.7%
sub0-neg63.7%
neg-mul-163.7%
*-commutative63.7%
times-frac63.7%
associate--r+63.7%
div-sub63.7%
difference-of-squares68.0%
+-commutative68.0%
associate-*l/72.4%
*-commutative72.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
*-commutative99.9%
fma-neg99.9%
+-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ x y) (* x 0.5))))
(if (<= x -7.2e+91)
t_0
(if (<= x -1.75e-46)
(* y 0.5)
(if (<= x -1.7e-263)
(* z (/ (* z -0.5) y))
(if (<= x 8.6e+114) (* y 0.5) t_0))))))
double code(double x, double y, double z) {
double t_0 = (x / y) * (x * 0.5);
double tmp;
if (x <= -7.2e+91) {
tmp = t_0;
} else if (x <= -1.75e-46) {
tmp = y * 0.5;
} else if (x <= -1.7e-263) {
tmp = z * ((z * -0.5) / y);
} else if (x <= 8.6e+114) {
tmp = y * 0.5;
} else {
tmp = 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 / y) * (x * 0.5d0)
if (x <= (-7.2d+91)) then
tmp = t_0
else if (x <= (-1.75d-46)) then
tmp = y * 0.5d0
else if (x <= (-1.7d-263)) then
tmp = z * ((z * (-0.5d0)) / y)
else if (x <= 8.6d+114) then
tmp = y * 0.5d0
else
tmp = t_0
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 (x <= -7.2e+91) {
tmp = t_0;
} else if (x <= -1.75e-46) {
tmp = y * 0.5;
} else if (x <= -1.7e-263) {
tmp = z * ((z * -0.5) / y);
} else if (x <= 8.6e+114) {
tmp = y * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x / y) * (x * 0.5) tmp = 0 if x <= -7.2e+91: tmp = t_0 elif x <= -1.75e-46: tmp = y * 0.5 elif x <= -1.7e-263: tmp = z * ((z * -0.5) / y) elif x <= 8.6e+114: tmp = y * 0.5 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x / y) * Float64(x * 0.5)) tmp = 0.0 if (x <= -7.2e+91) tmp = t_0; elseif (x <= -1.75e-46) tmp = Float64(y * 0.5); elseif (x <= -1.7e-263) tmp = Float64(z * Float64(Float64(z * -0.5) / y)); elseif (x <= 8.6e+114) tmp = Float64(y * 0.5); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / y) * (x * 0.5); tmp = 0.0; if (x <= -7.2e+91) tmp = t_0; elseif (x <= -1.75e-46) tmp = y * 0.5; elseif (x <= -1.7e-263) tmp = z * ((z * -0.5) / y); elseif (x <= 8.6e+114) tmp = y * 0.5; else tmp = t_0; 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[x, -7.2e+91], t$95$0, If[LessEqual[x, -1.75e-46], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, -1.7e-263], N[(z * N[(N[(z * -0.5), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.6e+114], N[(y * 0.5), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\mathbf{if}\;x \leq -7.2 \cdot 10^{+91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -1.75 \cdot 10^{-46}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq -1.7 \cdot 10^{-263}:\\
\;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\
\mathbf{elif}\;x \leq 8.6 \cdot 10^{+114}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -7.2e91 or 8.6000000000000001e114 < x Initial program 59.9%
Taylor expanded in x around inf 63.2%
unpow263.2%
Simplified63.2%
times-frac72.6%
div-inv72.6%
metadata-eval72.6%
Applied egg-rr72.6%
if -7.2e91 < x < -1.7500000000000001e-46 or -1.70000000000000002e-263 < x < 8.6000000000000001e114Initial program 65.4%
Taylor expanded in y around inf 54.4%
*-commutative54.4%
Simplified54.4%
if -1.7500000000000001e-46 < x < -1.70000000000000002e-263Initial program 67.0%
Taylor expanded in z around inf 57.6%
*-commutative57.6%
unpow257.6%
Simplified57.6%
Taylor expanded in z around 0 57.6%
metadata-eval57.6%
times-frac57.6%
*-commutative57.6%
unpow257.6%
associate-*l*57.6%
times-frac64.6%
/-rgt-identity64.6%
Simplified64.6%
Final simplification62.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ x y) (* x 0.5))))
(if (<= x -6.5e+91)
t_0
(if (<= x -2.9e-42)
(* y 0.5)
(if (<= x -1.2e-263)
(* -0.5 (/ z (/ y z)))
(if (<= x 4.5e+114) (* y 0.5) t_0))))))
double code(double x, double y, double z) {
double t_0 = (x / y) * (x * 0.5);
double tmp;
if (x <= -6.5e+91) {
tmp = t_0;
} else if (x <= -2.9e-42) {
tmp = y * 0.5;
} else if (x <= -1.2e-263) {
tmp = -0.5 * (z / (y / z));
} else if (x <= 4.5e+114) {
tmp = y * 0.5;
} else {
tmp = 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 / y) * (x * 0.5d0)
if (x <= (-6.5d+91)) then
tmp = t_0
else if (x <= (-2.9d-42)) then
tmp = y * 0.5d0
else if (x <= (-1.2d-263)) then
tmp = (-0.5d0) * (z / (y / z))
else if (x <= 4.5d+114) then
tmp = y * 0.5d0
else
tmp = t_0
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 (x <= -6.5e+91) {
tmp = t_0;
} else if (x <= -2.9e-42) {
tmp = y * 0.5;
} else if (x <= -1.2e-263) {
tmp = -0.5 * (z / (y / z));
} else if (x <= 4.5e+114) {
tmp = y * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x / y) * (x * 0.5) tmp = 0 if x <= -6.5e+91: tmp = t_0 elif x <= -2.9e-42: tmp = y * 0.5 elif x <= -1.2e-263: tmp = -0.5 * (z / (y / z)) elif x <= 4.5e+114: tmp = y * 0.5 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x / y) * Float64(x * 0.5)) tmp = 0.0 if (x <= -6.5e+91) tmp = t_0; elseif (x <= -2.9e-42) tmp = Float64(y * 0.5); elseif (x <= -1.2e-263) tmp = Float64(-0.5 * Float64(z / Float64(y / z))); elseif (x <= 4.5e+114) tmp = Float64(y * 0.5); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / y) * (x * 0.5); tmp = 0.0; if (x <= -6.5e+91) tmp = t_0; elseif (x <= -2.9e-42) tmp = y * 0.5; elseif (x <= -1.2e-263) tmp = -0.5 * (z / (y / z)); elseif (x <= 4.5e+114) tmp = y * 0.5; else tmp = t_0; 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[x, -6.5e+91], t$95$0, If[LessEqual[x, -2.9e-42], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, -1.2e-263], N[(-0.5 * N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.5e+114], N[(y * 0.5), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\mathbf{if}\;x \leq -6.5 \cdot 10^{+91}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.9 \cdot 10^{-42}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq -1.2 \cdot 10^{-263}:\\
\;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\
\mathbf{elif}\;x \leq 4.5 \cdot 10^{+114}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -6.4999999999999997e91 or 4.5000000000000001e114 < x Initial program 59.9%
Taylor expanded in x around inf 63.2%
unpow263.2%
Simplified63.2%
times-frac72.6%
div-inv72.6%
metadata-eval72.6%
Applied egg-rr72.6%
if -6.4999999999999997e91 < x < -2.9000000000000003e-42 or -1.2e-263 < x < 4.5000000000000001e114Initial program 65.4%
Taylor expanded in y around inf 54.4%
*-commutative54.4%
Simplified54.4%
if -2.9000000000000003e-42 < x < -1.2e-263Initial program 67.0%
Taylor expanded in z around inf 57.6%
*-commutative57.6%
unpow257.6%
associate-/l*64.7%
Simplified64.7%
Final simplification62.4%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 2e+190) (* -0.5 (- (/ z (/ y z)) y)) (* -0.5 (* (- z x) (/ (+ z x) y)))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+190) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = -0.5 * ((z - x) * ((z + 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+190) then
tmp = (-0.5d0) * ((z / (y / z)) - y)
else
tmp = (-0.5d0) * ((z - x) * ((z + x) / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 2e+190) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = -0.5 * ((z - x) * ((z + x) / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 2e+190: tmp = -0.5 * ((z / (y / z)) - y) else: tmp = -0.5 * ((z - x) * ((z + x) / y)) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 2e+190) tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y)); else tmp = Float64(-0.5 * Float64(Float64(z - x) * Float64(Float64(z + x) / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 2e+190) tmp = -0.5 * ((z / (y / z)) - y); else tmp = -0.5 * ((z - x) * ((z + x) / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 2e+190], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(z - x), $MachinePrecision] * N[(N[(z + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 2 \cdot 10^{+190}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{z + x}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 2.0000000000000001e190Initial program 65.7%
sub-neg65.7%
+-commutative65.7%
neg-sub065.7%
associate-+l-65.7%
sub0-neg65.7%
neg-mul-165.7%
*-commutative65.7%
times-frac65.7%
associate--r+65.7%
div-sub65.8%
difference-of-squares65.8%
+-commutative65.8%
associate-*l/68.5%
*-commutative68.5%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 80.1%
unpow280.1%
associate-/l*89.5%
Simplified89.5%
if 2.0000000000000001e190 < (*.f64 x x) Initial program 60.0%
sub-neg60.0%
+-commutative60.0%
neg-sub060.0%
associate-+l-60.0%
sub0-neg60.0%
neg-mul-160.0%
*-commutative60.0%
times-frac60.0%
associate--r+60.0%
div-sub60.0%
difference-of-squares72.3%
+-commutative72.3%
associate-*l/79.7%
*-commutative79.7%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
*-commutative99.9%
fma-neg100.0%
+-commutative100.0%
Applied egg-rr100.0%
Taylor expanded in y around 0 76.9%
*-commutative76.9%
associate-*l/88.8%
*-commutative88.8%
+-commutative88.8%
Simplified88.8%
Final simplification89.2%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 4e+193) (* -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) <= 4e+193) {
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) <= 4d+193) 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) <= 4e+193) {
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) <= 4e+193: 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) <= 4e+193) 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) <= 4e+193) 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], 4e+193], 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 4 \cdot 10^{+193}:\\
\;\;\;\;-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) < 4.00000000000000026e193Initial program 65.9%
sub-neg65.9%
+-commutative65.9%
neg-sub065.9%
associate-+l-65.9%
sub0-neg65.9%
neg-mul-165.9%
*-commutative65.9%
times-frac65.9%
associate--r+65.9%
div-sub66.0%
difference-of-squares66.0%
+-commutative66.0%
associate-*l/68.7%
*-commutative68.7%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 80.2%
unpow280.2%
associate-/l*89.5%
Simplified89.5%
if 4.00000000000000026e193 < (*.f64 x x) Initial program 59.5%
sub-neg59.5%
+-commutative59.5%
neg-sub059.5%
associate-+l-59.5%
sub0-neg59.5%
neg-mul-159.5%
*-commutative59.5%
times-frac59.5%
associate--r+59.5%
div-sub59.5%
difference-of-squares72.0%
+-commutative72.0%
associate-*l/79.4%
*-commutative79.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 89.8%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 20000.0) (* -0.5 (- (* (- z x) (/ x y)) y)) (* -0.5 (- (* (- z x) (/ z y)) y))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 20000.0) {
tmp = -0.5 * (((z - x) * (x / y)) - y);
} else {
tmp = -0.5 * (((z - x) * (z / 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 ((z * z) <= 20000.0d0) then
tmp = (-0.5d0) * (((z - x) * (x / y)) - y)
else
tmp = (-0.5d0) * (((z - x) * (z / y)) - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 20000.0) {
tmp = -0.5 * (((z - x) * (x / y)) - y);
} else {
tmp = -0.5 * (((z - x) * (z / y)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 20000.0: tmp = -0.5 * (((z - x) * (x / y)) - y) else: tmp = -0.5 * (((z - x) * (z / y)) - y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 20000.0) tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) * Float64(x / y)) - y)); else tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) * Float64(z / y)) - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 20000.0) tmp = -0.5 * (((z - x) * (x / y)) - y); else tmp = -0.5 * (((z - x) * (z / y)) - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 20000.0], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] * N[(z / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 20000:\\
\;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{x}{y} - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{z}{y} - y\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 2e4Initial program 71.2%
sub-neg71.2%
+-commutative71.2%
neg-sub071.2%
associate-+l-71.2%
sub0-neg71.2%
neg-mul-171.2%
*-commutative71.2%
times-frac71.2%
associate--r+71.2%
div-sub71.2%
difference-of-squares71.2%
+-commutative71.2%
associate-*l/76.3%
*-commutative76.3%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 92.4%
if 2e4 < (*.f64 z z) Initial program 56.5%
sub-neg56.5%
+-commutative56.5%
neg-sub056.5%
associate-+l-56.5%
sub0-neg56.5%
neg-mul-156.5%
*-commutative56.5%
times-frac56.5%
associate--r+56.5%
div-sub56.5%
difference-of-squares64.9%
+-commutative64.9%
associate-*l/68.5%
*-commutative68.5%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 89.4%
Final simplification90.9%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 5e+34) (* -0.5 (- (/ (- x) (/ y x)) y)) (* -0.5 (- (/ z (/ y z)) y))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e+34) {
tmp = -0.5 * ((-x / (y / x)) - y);
} 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 * z) <= 5d+34) then
tmp = (-0.5d0) * ((-x / (y / x)) - y)
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 * z) <= 5e+34) {
tmp = -0.5 * ((-x / (y / x)) - y);
} else {
tmp = -0.5 * ((z / (y / z)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 5e+34: tmp = -0.5 * ((-x / (y / x)) - y) else: tmp = -0.5 * ((z / (y / z)) - y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e+34) tmp = Float64(-0.5 * Float64(Float64(Float64(-x) / Float64(y / x)) - y)); 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 * z) <= 5e+34) tmp = -0.5 * ((-x / (y / x)) - y); else tmp = -0.5 * ((z / (y / z)) - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e+34], N[(-0.5 * N[(N[((-x) / N[(y / x), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+34}:\\
\;\;\;\;-0.5 \cdot \left(\frac{-x}{\frac{y}{x}} - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 4.9999999999999998e34Initial program 71.1%
sub-neg71.1%
+-commutative71.1%
neg-sub071.1%
associate-+l-71.1%
sub0-neg71.1%
neg-mul-171.1%
*-commutative71.1%
times-frac71.1%
associate--r+71.1%
div-sub71.1%
difference-of-squares71.1%
+-commutative71.1%
associate-*l/76.0%
*-commutative76.0%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
*-commutative99.9%
fma-neg99.9%
+-commutative99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 84.9%
mul-1-neg84.9%
unpow284.9%
associate-/l*92.5%
distribute-neg-frac92.5%
Simplified92.5%
if 4.9999999999999998e34 < (*.f64 z z) Initial program 55.9%
sub-neg55.9%
+-commutative55.9%
neg-sub055.9%
associate-+l-55.9%
sub0-neg55.9%
neg-mul-155.9%
*-commutative55.9%
times-frac55.9%
associate--r+55.9%
div-sub55.9%
difference-of-squares64.8%
+-commutative64.8%
associate-*l/68.5%
*-commutative68.5%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 69.4%
unpow269.4%
associate-/l*84.9%
Simplified84.9%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 4e+193) (* -0.5 (- (/ z (/ y z)) y)) (* (/ x y) (* x 0.5))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4e+193) {
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) <= 4d+193) 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) <= 4e+193) {
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) <= 4e+193: 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) <= 4e+193) 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) <= 4e+193) 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], 4e+193], 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 4 \cdot 10^{+193}:\\
\;\;\;\;-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) < 4.00000000000000026e193Initial program 65.9%
sub-neg65.9%
+-commutative65.9%
neg-sub065.9%
associate-+l-65.9%
sub0-neg65.9%
neg-mul-165.9%
*-commutative65.9%
times-frac65.9%
associate--r+65.9%
div-sub66.0%
difference-of-squares66.0%
+-commutative66.0%
associate-*l/68.7%
*-commutative68.7%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 80.2%
unpow280.2%
associate-/l*89.5%
Simplified89.5%
if 4.00000000000000026e193 < (*.f64 x x) Initial program 59.5%
Taylor expanded in x around inf 62.8%
unpow262.8%
Simplified62.8%
times-frac72.3%
div-inv72.3%
metadata-eval72.3%
Applied egg-rr72.3%
Final simplification83.6%
(FPCore (x y z) :precision binary64 (* -0.5 (- (* (- z x) (/ (+ z x) y)) y)))
double code(double x, double y, double z) {
return -0.5 * (((z - x) * ((z + x) / y)) - 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) * (((z - x) * ((z + x) / y)) - y)
end function
public static double code(double x, double y, double z) {
return -0.5 * (((z - x) * ((z + x) / y)) - y);
}
def code(x, y, z): return -0.5 * (((z - x) * ((z + x) / y)) - y)
function code(x, y, z) return Float64(-0.5 * Float64(Float64(Float64(z - x) * Float64(Float64(z + x) / y)) - y)) end
function tmp = code(x, y, z) tmp = -0.5 * (((z - x) * ((z + x) / y)) - y); end
code[x_, y_, z_] := N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] * N[(N[(z + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-0.5 \cdot \left(\left(z - x\right) \cdot \frac{z + x}{y} - y\right)
\end{array}
Initial program 63.7%
sub-neg63.7%
+-commutative63.7%
neg-sub063.7%
associate-+l-63.7%
sub0-neg63.7%
neg-mul-163.7%
*-commutative63.7%
times-frac63.7%
associate--r+63.7%
div-sub63.7%
difference-of-squares68.0%
+-commutative68.0%
associate-*l/72.4%
*-commutative72.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.45e+141) (not (<= z 2.8e-41))) (* z (/ (* z -0.5) y)) (* y 0.5)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.45e+141) || !(z <= 2.8e-41)) {
tmp = z * ((z * -0.5) / y);
} 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 ((z <= (-1.45d+141)) .or. (.not. (z <= 2.8d-41))) then
tmp = z * ((z * (-0.5d0)) / y)
else
tmp = y * 0.5d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1.45e+141) || !(z <= 2.8e-41)) {
tmp = z * ((z * -0.5) / y);
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.45e+141) or not (z <= 2.8e-41): tmp = z * ((z * -0.5) / y) else: tmp = y * 0.5 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.45e+141) || !(z <= 2.8e-41)) tmp = Float64(z * Float64(Float64(z * -0.5) / y)); else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.45e+141) || ~((z <= 2.8e-41))) tmp = z * ((z * -0.5) / y); else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.45e+141], N[Not[LessEqual[z, 2.8e-41]], $MachinePrecision]], N[(z * N[(N[(z * -0.5), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.45 \cdot 10^{+141} \lor \neg \left(z \leq 2.8 \cdot 10^{-41}\right):\\
\;\;\;\;z \cdot \frac{z \cdot -0.5}{y}\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if z < -1.45000000000000003e141 or 2.8000000000000002e-41 < z Initial program 55.3%
Taylor expanded in z around inf 57.1%
*-commutative57.1%
unpow257.1%
Simplified57.1%
Taylor expanded in z around 0 57.1%
metadata-eval57.1%
times-frac57.1%
*-commutative57.1%
unpow257.1%
associate-*l*57.1%
times-frac64.0%
/-rgt-identity64.0%
Simplified64.0%
if -1.45000000000000003e141 < z < 2.8000000000000002e-41Initial program 70.3%
Taylor expanded in y around inf 48.6%
*-commutative48.6%
Simplified48.6%
Final simplification55.3%
(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 63.7%
Taylor expanded in y around inf 36.4%
*-commutative36.4%
Simplified36.4%
Final simplification36.4%
(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 2023195
(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)))