
(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 5 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}
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 10.0)
(* 0.5 (/ (fma x x (- (* y_m y_m) (* z z))) y_m))
(* 0.5 (+ (- y_m (* z (/ z y_m))) (* x (/ x y_m)))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 10.0) {
tmp = 0.5 * (fma(x, x, ((y_m * y_m) - (z * z))) / y_m);
} else {
tmp = 0.5 * ((y_m - (z * (z / y_m))) + (x * (x / y_m)));
}
return y_s * tmp;
}
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 10.0) tmp = Float64(0.5 * Float64(fma(x, x, Float64(Float64(y_m * y_m) - Float64(z * z))) / y_m)); else tmp = Float64(0.5 * Float64(Float64(y_m - Float64(z * Float64(z / y_m))) + Float64(x * Float64(x / y_m)))); end return Float64(y_s * tmp) end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 10.0], N[(0.5 * N[(N[(x * x + N[(N[(y$95$m * y$95$m), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y$95$m), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 10:\\
\;\;\;\;0.5 \cdot \frac{\mathsf{fma}\left(x, x, y\_m \cdot y\_m - z \cdot z\right)}{y\_m}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(y\_m - z \cdot \frac{z}{y\_m}\right) + x \cdot \frac{x}{y\_m}\right)\\
\end{array}
\end{array}
if y < 10Initial program 81.6%
remove-double-neg81.6%
distribute-lft-neg-out81.6%
distribute-frac-neg281.6%
distribute-frac-neg81.6%
neg-mul-181.6%
distribute-lft-neg-out81.6%
*-commutative81.6%
distribute-lft-neg-in81.6%
times-frac81.6%
metadata-eval81.6%
metadata-eval81.6%
associate--l+81.6%
fma-define85.9%
Simplified85.9%
if 10 < y Initial program 49.3%
remove-double-neg49.3%
distribute-lft-neg-out49.3%
distribute-frac-neg249.3%
distribute-frac-neg49.3%
neg-mul-149.3%
distribute-lft-neg-out49.3%
*-commutative49.3%
distribute-lft-neg-in49.3%
times-frac49.3%
metadata-eval49.3%
metadata-eval49.3%
associate--l+49.3%
fma-define49.3%
Simplified49.3%
Taylor expanded in z around inf 47.8%
associate--l+47.8%
unpow247.8%
associate-/l*49.3%
fmm-def49.3%
distribute-neg-frac49.3%
metadata-eval49.3%
Simplified49.3%
Taylor expanded in z around 0 76.0%
associate-+r+76.0%
mul-1-neg76.0%
sub-neg76.0%
Simplified76.0%
unpow276.0%
*-un-lft-identity76.0%
times-frac81.7%
Applied egg-rr81.7%
unpow281.7%
*-un-lft-identity81.7%
times-frac98.5%
Applied egg-rr98.5%
Final simplification89.4%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (let* ((t_0 (/ (- (+ (* y_m y_m) (* x x)) (* z z)) (* y_m 2.0)))) (* y_s (if (<= t_0 -2e-57) t_0 (* 0.5 (+ y_m (/ x (/ y_m x))))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double t_0 = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
double tmp;
if (t_0 <= -2e-57) {
tmp = t_0;
} else {
tmp = 0.5 * (y_m + (x / (y_m / x)));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0d0)
if (t_0 <= (-2d-57)) then
tmp = t_0
else
tmp = 0.5d0 * (y_m + (x / (y_m / x)))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double t_0 = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
double tmp;
if (t_0 <= -2e-57) {
tmp = t_0;
} else {
tmp = 0.5 * (y_m + (x / (y_m / x)));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): t_0 = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0) tmp = 0 if t_0 <= -2e-57: tmp = t_0 else: tmp = 0.5 * (y_m + (x / (y_m / x))) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) t_0 = Float64(Float64(Float64(Float64(y_m * y_m) + Float64(x * x)) - Float64(z * z)) / Float64(y_m * 2.0)) tmp = 0.0 if (t_0 <= -2e-57) tmp = t_0; else tmp = Float64(0.5 * Float64(y_m + Float64(x / Float64(y_m / x)))); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) t_0 = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0); tmp = 0.0; if (t_0 <= -2e-57) tmp = t_0; else tmp = 0.5 * (y_m + (x / (y_m / x))); end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := Block[{t$95$0 = N[(N[(N[(N[(y$95$m * y$95$m), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision]}, N[(y$95$s * If[LessEqual[t$95$0, -2e-57], t$95$0, N[(0.5 * N[(y$95$m + N[(x / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
\begin{array}{l}
t_0 := \frac{\left(y\_m \cdot y\_m + x \cdot x\right) - z \cdot z}{y\_m \cdot 2}\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;t\_0 \leq -2 \cdot 10^{-57}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y\_m + \frac{x}{\frac{y\_m}{x}}\right)\\
\end{array}
\end{array}
\end{array}
if (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) < -1.99999999999999991e-57Initial program 87.5%
if -1.99999999999999991e-57 < (/.f64 (-.f64 (+.f64 (*.f64 x x) (*.f64 y y)) (*.f64 z z)) (*.f64 y #s(literal 2 binary64))) Initial program 62.1%
remove-double-neg62.1%
distribute-lft-neg-out62.1%
distribute-frac-neg262.1%
distribute-frac-neg62.1%
neg-mul-162.1%
distribute-lft-neg-out62.1%
*-commutative62.1%
distribute-lft-neg-in62.1%
times-frac62.1%
metadata-eval62.1%
metadata-eval62.1%
associate--l+62.1%
fma-define67.4%
Simplified67.4%
Taylor expanded in z around inf 51.4%
associate--l+51.4%
unpow251.4%
associate-/l*57.5%
fmm-def57.5%
distribute-neg-frac57.5%
metadata-eval57.5%
Simplified57.5%
Taylor expanded in z around 0 74.3%
associate-+r+74.3%
mul-1-neg74.3%
sub-neg74.3%
Simplified74.3%
Taylor expanded in z around 0 54.9%
+-commutative54.9%
unpow254.9%
associate-*r/64.7%
fma-define64.7%
Simplified64.7%
fma-undefine64.7%
clear-num64.7%
un-div-inv64.7%
Applied egg-rr64.7%
Final simplification74.1%
y\_m = (fabs.f64 y)
y\_s = (copysign.f64 #s(literal 1 binary64) y)
(FPCore (y_s x y_m z)
:precision binary64
(*
y_s
(if (<= y_m 5.5e-120)
(/ (- (+ (* y_m y_m) (* x x)) (* z z)) (* y_m 2.0))
(* 0.5 (+ (- y_m (* z (/ z y_m))) (* x (/ x y_m)))))))y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 5.5e-120) {
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
} else {
tmp = 0.5 * ((y_m - (z * (z / y_m))) + (x * (x / y_m)));
}
return y_s * tmp;
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
real(8) :: tmp
if (y_m <= 5.5d-120) then
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0d0)
else
tmp = 0.5d0 * ((y_m - (z * (z / y_m))) + (x * (x / y_m)))
end if
code = y_s * tmp
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
double tmp;
if (y_m <= 5.5e-120) {
tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0);
} else {
tmp = 0.5 * ((y_m - (z * (z / y_m))) + (x * (x / y_m)));
}
return y_s * tmp;
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): tmp = 0 if y_m <= 5.5e-120: tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0) else: tmp = 0.5 * ((y_m - (z * (z / y_m))) + (x * (x / y_m))) return y_s * tmp
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) tmp = 0.0 if (y_m <= 5.5e-120) tmp = Float64(Float64(Float64(Float64(y_m * y_m) + Float64(x * x)) - Float64(z * z)) / Float64(y_m * 2.0)); else tmp = Float64(0.5 * Float64(Float64(y_m - Float64(z * Float64(z / y_m))) + Float64(x * Float64(x / y_m)))); end return Float64(y_s * tmp) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp_2 = code(y_s, x, y_m, z) tmp = 0.0; if (y_m <= 5.5e-120) tmp = (((y_m * y_m) + (x * x)) - (z * z)) / (y_m * 2.0); else tmp = 0.5 * ((y_m - (z * (z / y_m))) + (x * (x / y_m))); end tmp_2 = y_s * tmp; end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * If[LessEqual[y$95$m, 5.5e-120], N[(N[(N[(N[(y$95$m * y$95$m), $MachinePrecision] + N[(x * x), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y$95$m * 2.0), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(y$95$m - N[(z * N[(z / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x * N[(x / y$95$m), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \begin{array}{l}
\mathbf{if}\;y\_m \leq 5.5 \cdot 10^{-120}:\\
\;\;\;\;\frac{\left(y\_m \cdot y\_m + x \cdot x\right) - z \cdot z}{y\_m \cdot 2}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\left(y\_m - z \cdot \frac{z}{y\_m}\right) + x \cdot \frac{x}{y\_m}\right)\\
\end{array}
\end{array}
if y < 5.5000000000000001e-120Initial program 78.6%
if 5.5000000000000001e-120 < y Initial program 62.9%
remove-double-neg62.9%
distribute-lft-neg-out62.9%
distribute-frac-neg262.9%
distribute-frac-neg62.9%
neg-mul-162.9%
distribute-lft-neg-out62.9%
*-commutative62.9%
distribute-lft-neg-in62.9%
times-frac62.9%
metadata-eval62.9%
metadata-eval62.9%
associate--l+62.9%
fma-define62.9%
Simplified62.9%
Taylor expanded in z around inf 58.3%
associate--l+58.3%
unpow258.3%
associate-/l*59.4%
fmm-def59.4%
distribute-neg-frac59.4%
metadata-eval59.4%
Simplified59.4%
Taylor expanded in z around 0 82.4%
associate-+r+82.4%
mul-1-neg82.4%
sub-neg82.4%
Simplified82.4%
unpow282.4%
*-un-lft-identity82.4%
times-frac86.6%
Applied egg-rr86.6%
unpow286.6%
*-un-lft-identity86.6%
times-frac98.9%
Applied egg-rr98.9%
Final simplification86.3%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (* 0.5 (+ y_m (/ x (/ y_m x))))))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
return y_s * (0.5 * (y_m + (x / (y_m / x))));
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (0.5d0 * (y_m + (x / (y_m / x))))
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (0.5 * (y_m + (x / (y_m / x))));
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): return y_s * (0.5 * (y_m + (x / (y_m / x))))
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) return Float64(y_s * Float64(0.5 * Float64(y_m + Float64(x / Float64(y_m / x))))) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z) tmp = y_s * (0.5 * (y_m + (x / (y_m / x)))); end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(0.5 * N[(y$95$m + N[(x / N[(y$95$m / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \left(0.5 \cdot \left(y\_m + \frac{x}{\frac{y\_m}{x}}\right)\right)
\end{array}
Initial program 72.6%
remove-double-neg72.6%
distribute-lft-neg-out72.6%
distribute-frac-neg272.6%
distribute-frac-neg72.6%
neg-mul-172.6%
distribute-lft-neg-out72.6%
*-commutative72.6%
distribute-lft-neg-in72.6%
times-frac72.6%
metadata-eval72.6%
metadata-eval72.6%
associate--l+72.6%
fma-define75.7%
Simplified75.7%
Taylor expanded in z around inf 61.1%
associate--l+61.1%
unpow261.1%
associate-/l*64.7%
fmm-def64.7%
distribute-neg-frac64.7%
metadata-eval64.7%
Simplified64.7%
Taylor expanded in z around 0 81.4%
associate-+r+81.4%
mul-1-neg81.4%
sub-neg81.4%
Simplified81.4%
Taylor expanded in z around 0 57.8%
+-commutative57.8%
unpow257.8%
associate-*r/63.5%
fma-define63.5%
Simplified63.5%
fma-undefine63.5%
clear-num63.5%
un-div-inv63.5%
Applied egg-rr63.5%
Final simplification63.5%
y\_m = (fabs.f64 y) y\_s = (copysign.f64 #s(literal 1 binary64) y) (FPCore (y_s x y_m z) :precision binary64 (* y_s (* y_m 0.5)))
y\_m = fabs(y);
y\_s = copysign(1.0, y);
double code(double y_s, double x, double y_m, double z) {
return y_s * (y_m * 0.5);
}
y\_m = abs(y)
y\_s = copysign(1.0d0, y)
real(8) function code(y_s, x, y_m, z)
real(8), intent (in) :: y_s
real(8), intent (in) :: x
real(8), intent (in) :: y_m
real(8), intent (in) :: z
code = y_s * (y_m * 0.5d0)
end function
y\_m = Math.abs(y);
y\_s = Math.copySign(1.0, y);
public static double code(double y_s, double x, double y_m, double z) {
return y_s * (y_m * 0.5);
}
y\_m = math.fabs(y) y\_s = math.copysign(1.0, y) def code(y_s, x, y_m, z): return y_s * (y_m * 0.5)
y\_m = abs(y) y\_s = copysign(1.0, y) function code(y_s, x, y_m, z) return Float64(y_s * Float64(y_m * 0.5)) end
y\_m = abs(y); y\_s = sign(y) * abs(1.0); function tmp = code(y_s, x, y_m, z) tmp = y_s * (y_m * 0.5); end
y\_m = N[Abs[y], $MachinePrecision]
y\_s = N[With[{TMP1 = Abs[1.0], TMP2 = Sign[y]}, TMP1 * If[TMP2 == 0, 1, TMP2]], $MachinePrecision]
code[y$95$s_, x_, y$95$m_, z_] := N[(y$95$s * N[(y$95$m * 0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
y\_m = \left|y\right|
\\
y\_s = \mathsf{copysign}\left(1, y\right)
\\
y\_s \cdot \left(y\_m \cdot 0.5\right)
\end{array}
Initial program 72.6%
Taylor expanded in y around inf 34.2%
*-commutative34.2%
Simplified34.2%
Final simplification34.2%
(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 2024095
(FPCore (x y z)
:name "Diagrams.TwoD.Apollonian:initialConfig from diagrams-contrib-1.3.0.5, A"
:precision binary64
:alt
(- (* y 0.5) (* (* (/ 0.5 y) (+ z x)) (- z x)))
(/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))