
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 9 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (- (+ (* x x) (* y y)) (* z z)) (* y 2.0)))
double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((x * x) + (y * y)) - (z * z)) / (y * 2.0d0)
end function
public static double code(double x, double y, double z) {
return (((x * x) + (y * y)) - (z * z)) / (y * 2.0);
}
def code(x, y, z): return (((x * x) + (y * y)) - (z * z)) / (y * 2.0)
function code(x, y, z) return Float64(Float64(Float64(Float64(x * x) + Float64(y * y)) - Float64(z * z)) / Float64(y * 2.0)) end
function tmp = code(x, y, z) tmp = (((x * x) + (y * y)) - (z * z)) / (y * 2.0); end
code[x_, y_, z_] := N[(N[(N[(N[(x * x), $MachinePrecision] + N[(y * y), $MachinePrecision]), $MachinePrecision] - N[(z * z), $MachinePrecision]), $MachinePrecision] / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{\left(x \cdot x + y \cdot y\right) - z \cdot z}{y \cdot 2}
\end{array}
(FPCore (x y z) :precision binary64 (* (- (* (- z x) (/ (+ z x) y)) y) -0.5))
double code(double x, double y, double z) {
return (((z - x) * ((z + x) / y)) - y) * -0.5;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (((z - x) * ((z + x) / y)) - y) * (-0.5d0)
end function
public static double code(double x, double y, double z) {
return (((z - x) * ((z + x) / y)) - y) * -0.5;
}
def code(x, y, z): return (((z - x) * ((z + x) / y)) - y) * -0.5
function code(x, y, z) return Float64(Float64(Float64(Float64(z - x) * Float64(Float64(z + x) / y)) - y) * -0.5) end
function tmp = code(x, y, z) tmp = (((z - x) * ((z + x) / y)) - y) * -0.5; end
code[x_, y_, z_] := N[(N[(N[(N[(z - x), $MachinePrecision] * N[(N[(z + x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(z - x\right) \cdot \frac{z + x}{y} - y\right) \cdot -0.5
\end{array}
Initial program 70.1%
sub-neg70.1%
+-commutative70.1%
neg-sub070.1%
associate-+l-70.1%
sub0-neg70.1%
neg-mul-170.1%
*-commutative70.1%
times-frac70.1%
associate--r+70.1%
div-sub70.0%
difference-of-squares75.5%
+-commutative75.5%
associate-*l/77.3%
*-commutative77.3%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -0.5 (* z (/ z y)))) (t_1 (* (/ x y) (* x 0.5))))
(if (<= (* z z) 5e-169)
(* y 0.5)
(if (<= (* z z) 5e+60)
t_1
(if (<= (* z z) 5e+88)
t_0
(if (<= (* z z) 2e+121)
t_1
(if (<= (* z z) 4e+173) (* y 0.5) t_0)))))))
double code(double x, double y, double z) {
double t_0 = -0.5 * (z * (z / y));
double t_1 = (x / y) * (x * 0.5);
double tmp;
if ((z * z) <= 5e-169) {
tmp = y * 0.5;
} else if ((z * z) <= 5e+60) {
tmp = t_1;
} else if ((z * z) <= 5e+88) {
tmp = t_0;
} else if ((z * z) <= 2e+121) {
tmp = t_1;
} else if ((z * z) <= 4e+173) {
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) :: t_1
real(8) :: tmp
t_0 = (-0.5d0) * (z * (z / y))
t_1 = (x / y) * (x * 0.5d0)
if ((z * z) <= 5d-169) then
tmp = y * 0.5d0
else if ((z * z) <= 5d+60) then
tmp = t_1
else if ((z * z) <= 5d+88) then
tmp = t_0
else if ((z * z) <= 2d+121) then
tmp = t_1
else if ((z * z) <= 4d+173) 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 = -0.5 * (z * (z / y));
double t_1 = (x / y) * (x * 0.5);
double tmp;
if ((z * z) <= 5e-169) {
tmp = y * 0.5;
} else if ((z * z) <= 5e+60) {
tmp = t_1;
} else if ((z * z) <= 5e+88) {
tmp = t_0;
} else if ((z * z) <= 2e+121) {
tmp = t_1;
} else if ((z * z) <= 4e+173) {
tmp = y * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -0.5 * (z * (z / y)) t_1 = (x / y) * (x * 0.5) tmp = 0 if (z * z) <= 5e-169: tmp = y * 0.5 elif (z * z) <= 5e+60: tmp = t_1 elif (z * z) <= 5e+88: tmp = t_0 elif (z * z) <= 2e+121: tmp = t_1 elif (z * z) <= 4e+173: tmp = y * 0.5 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-0.5 * Float64(z * Float64(z / y))) t_1 = Float64(Float64(x / y) * Float64(x * 0.5)) tmp = 0.0 if (Float64(z * z) <= 5e-169) tmp = Float64(y * 0.5); elseif (Float64(z * z) <= 5e+60) tmp = t_1; elseif (Float64(z * z) <= 5e+88) tmp = t_0; elseif (Float64(z * z) <= 2e+121) tmp = t_1; elseif (Float64(z * z) <= 4e+173) tmp = Float64(y * 0.5); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -0.5 * (z * (z / y)); t_1 = (x / y) * (x * 0.5); tmp = 0.0; if ((z * z) <= 5e-169) tmp = y * 0.5; elseif ((z * z) <= 5e+60) tmp = t_1; elseif ((z * z) <= 5e+88) tmp = t_0; elseif ((z * z) <= 2e+121) tmp = t_1; elseif ((z * z) <= 4e+173) tmp = y * 0.5; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * z), $MachinePrecision], 5e-169], N[(y * 0.5), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 5e+60], t$95$1, If[LessEqual[N[(z * z), $MachinePrecision], 5e+88], t$95$0, If[LessEqual[N[(z * z), $MachinePrecision], 2e+121], t$95$1, If[LessEqual[N[(z * z), $MachinePrecision], 4e+173], N[(y * 0.5), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
t_1 := \frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-169}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+60}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+121}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \cdot z \leq 4 \cdot 10^{+173}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000002e-169 or 2.00000000000000007e121 < (*.f64 z z) < 4.0000000000000001e173Initial program 66.2%
Taylor expanded in y around inf 53.2%
*-commutative53.2%
Simplified53.2%
if 5.0000000000000002e-169 < (*.f64 z z) < 4.99999999999999975e60 or 4.99999999999999997e88 < (*.f64 z z) < 2.00000000000000007e121Initial program 90.0%
Taylor expanded in x around inf 54.2%
unpow254.2%
Simplified54.2%
times-frac55.9%
div-inv55.9%
metadata-eval55.9%
Applied egg-rr55.9%
if 4.99999999999999975e60 < (*.f64 z z) < 4.99999999999999997e88 or 4.0000000000000001e173 < (*.f64 z z) Initial program 62.5%
Taylor expanded in z around inf 72.3%
*-commutative72.3%
unpow272.3%
associate-/l*75.0%
Simplified75.0%
associate-/r/75.1%
Applied egg-rr75.1%
Final simplification62.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -0.5 (* z (/ z y)))))
(if (<= (* z z) 5e-169)
(* y 0.5)
(if (<= (* z z) 5e+60)
(* (/ x y) (* x 0.5))
(if (<= (* z z) 5e+88)
t_0
(if (<= (* z z) 2e+121)
(/ x (* y (/ 2.0 x)))
(if (<= (* z z) 4e+173) (* y 0.5) t_0)))))))
double code(double x, double y, double z) {
double t_0 = -0.5 * (z * (z / y));
double tmp;
if ((z * z) <= 5e-169) {
tmp = y * 0.5;
} else if ((z * z) <= 5e+60) {
tmp = (x / y) * (x * 0.5);
} else if ((z * z) <= 5e+88) {
tmp = t_0;
} else if ((z * z) <= 2e+121) {
tmp = x / (y * (2.0 / x));
} else if ((z * z) <= 4e+173) {
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 = (-0.5d0) * (z * (z / y))
if ((z * z) <= 5d-169) then
tmp = y * 0.5d0
else if ((z * z) <= 5d+60) then
tmp = (x / y) * (x * 0.5d0)
else if ((z * z) <= 5d+88) then
tmp = t_0
else if ((z * z) <= 2d+121) then
tmp = x / (y * (2.0d0 / x))
else if ((z * z) <= 4d+173) 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 = -0.5 * (z * (z / y));
double tmp;
if ((z * z) <= 5e-169) {
tmp = y * 0.5;
} else if ((z * z) <= 5e+60) {
tmp = (x / y) * (x * 0.5);
} else if ((z * z) <= 5e+88) {
tmp = t_0;
} else if ((z * z) <= 2e+121) {
tmp = x / (y * (2.0 / x));
} else if ((z * z) <= 4e+173) {
tmp = y * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -0.5 * (z * (z / y)) tmp = 0 if (z * z) <= 5e-169: tmp = y * 0.5 elif (z * z) <= 5e+60: tmp = (x / y) * (x * 0.5) elif (z * z) <= 5e+88: tmp = t_0 elif (z * z) <= 2e+121: tmp = x / (y * (2.0 / x)) elif (z * z) <= 4e+173: tmp = y * 0.5 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-0.5 * Float64(z * Float64(z / y))) tmp = 0.0 if (Float64(z * z) <= 5e-169) tmp = Float64(y * 0.5); elseif (Float64(z * z) <= 5e+60) tmp = Float64(Float64(x / y) * Float64(x * 0.5)); elseif (Float64(z * z) <= 5e+88) tmp = t_0; elseif (Float64(z * z) <= 2e+121) tmp = Float64(x / Float64(y * Float64(2.0 / x))); elseif (Float64(z * z) <= 4e+173) tmp = Float64(y * 0.5); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -0.5 * (z * (z / y)); tmp = 0.0; if ((z * z) <= 5e-169) tmp = y * 0.5; elseif ((z * z) <= 5e+60) tmp = (x / y) * (x * 0.5); elseif ((z * z) <= 5e+88) tmp = t_0; elseif ((z * z) <= 2e+121) tmp = x / (y * (2.0 / x)); elseif ((z * z) <= 4e+173) tmp = y * 0.5; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * z), $MachinePrecision], 5e-169], N[(y * 0.5), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 5e+60], N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 5e+88], t$95$0, If[LessEqual[N[(z * z), $MachinePrecision], 2e+121], N[(x / N[(y * N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 4e+173], N[(y * 0.5), $MachinePrecision], t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-169}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+60}:\\
\;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+88}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+121}:\\
\;\;\;\;\frac{x}{y \cdot \frac{2}{x}}\\
\mathbf{elif}\;z \cdot z \leq 4 \cdot 10^{+173}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (*.f64 z z) < 5.0000000000000002e-169 or 2.00000000000000007e121 < (*.f64 z z) < 4.0000000000000001e173Initial program 66.2%
Taylor expanded in y around inf 53.2%
*-commutative53.2%
Simplified53.2%
if 5.0000000000000002e-169 < (*.f64 z z) < 4.99999999999999975e60Initial program 89.2%
Taylor expanded in x around inf 52.6%
unpow252.6%
Simplified52.6%
times-frac54.4%
div-inv54.4%
metadata-eval54.4%
Applied egg-rr54.4%
if 4.99999999999999975e60 < (*.f64 z z) < 4.99999999999999997e88 or 4.0000000000000001e173 < (*.f64 z z) Initial program 62.5%
Taylor expanded in z around inf 72.3%
*-commutative72.3%
unpow272.3%
associate-/l*75.0%
Simplified75.0%
associate-/r/75.1%
Applied egg-rr75.1%
if 4.99999999999999997e88 < (*.f64 z z) < 2.00000000000000007e121Initial program 99.6%
Taylor expanded in x around inf 75.3%
unpow275.3%
Simplified75.3%
times-frac75.3%
div-inv75.3%
metadata-eval75.3%
Applied egg-rr75.3%
metadata-eval75.3%
div-inv75.3%
*-commutative75.3%
clear-num75.3%
frac-times75.7%
*-un-lft-identity75.7%
Applied egg-rr75.7%
Final simplification62.4%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 2e+60) (* -0.5 (- (* (- z x) (/ x y)) y)) (* -0.5 (- (/ z (/ y z)) y))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+60) {
tmp = -0.5 * (((z - x) * (x / y)) - 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) <= 2d+60) then
tmp = (-0.5d0) * (((z - x) * (x / y)) - 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) <= 2e+60) {
tmp = -0.5 * (((z - x) * (x / y)) - y);
} else {
tmp = -0.5 * ((z / (y / z)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 2e+60: tmp = -0.5 * (((z - x) * (x / y)) - y) else: tmp = -0.5 * ((z / (y / z)) - y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+60) tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) * Float64(x / y)) - 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) <= 2e+60) tmp = -0.5 * (((z - x) * (x / y)) - y); else tmp = -0.5 * ((z / (y / z)) - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+60], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] * N[(x / y), $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 2 \cdot 10^{+60}:\\
\;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{x}{y} - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1.9999999999999999e60Initial program 75.7%
sub-neg75.7%
+-commutative75.7%
neg-sub075.7%
associate-+l-75.7%
sub0-neg75.7%
neg-mul-175.7%
*-commutative75.7%
times-frac75.7%
associate--r+75.7%
div-sub75.7%
difference-of-squares75.7%
+-commutative75.7%
associate-*l/78.4%
*-commutative78.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 93.1%
if 1.9999999999999999e60 < (*.f64 z z) Initial program 63.0%
sub-neg63.0%
+-commutative63.0%
neg-sub063.0%
associate-+l-63.0%
sub0-neg63.0%
neg-mul-163.0%
*-commutative63.0%
times-frac63.0%
associate--r+63.0%
div-sub63.0%
difference-of-squares75.3%
+-commutative75.3%
associate-*l/75.9%
*-commutative75.9%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 79.3%
unpow279.3%
associate-/l*88.6%
Simplified88.6%
Final simplification91.1%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 2e+60) (* -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) <= 2e+60) {
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) <= 2d+60) 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) <= 2e+60) {
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) <= 2e+60: 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) <= 2e+60) 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) <= 2e+60) 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], 2e+60], 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 2 \cdot 10^{+60}:\\
\;\;\;\;-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) < 1.9999999999999999e60Initial program 75.7%
sub-neg75.7%
+-commutative75.7%
neg-sub075.7%
associate-+l-75.7%
sub0-neg75.7%
neg-mul-175.7%
*-commutative75.7%
times-frac75.7%
associate--r+75.7%
div-sub75.7%
difference-of-squares75.7%
+-commutative75.7%
associate-*l/78.4%
*-commutative78.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 93.1%
if 1.9999999999999999e60 < (*.f64 z z) Initial program 63.0%
sub-neg63.0%
+-commutative63.0%
neg-sub063.0%
associate-+l-63.0%
sub0-neg63.0%
neg-mul-163.0%
*-commutative63.0%
times-frac63.0%
associate--r+63.0%
div-sub63.0%
difference-of-squares75.3%
+-commutative75.3%
associate-*l/75.9%
*-commutative75.9%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 92.3%
Final simplification92.7%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 2e+60) (* -0.5 (- (* x (/ (- x) y)) y)) (* -0.5 (- (/ z (/ y z)) y))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+60) {
tmp = -0.5 * ((x * (-x / y)) - 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) <= 2d+60) then
tmp = (-0.5d0) * ((x * (-x / y)) - 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) <= 2e+60) {
tmp = -0.5 * ((x * (-x / y)) - y);
} else {
tmp = -0.5 * ((z / (y / z)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 2e+60: tmp = -0.5 * ((x * (-x / y)) - y) else: tmp = -0.5 * ((z / (y / z)) - y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+60) tmp = Float64(-0.5 * Float64(Float64(x * Float64(Float64(-x) / y)) - 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) <= 2e+60) tmp = -0.5 * ((x * (-x / y)) - y); else tmp = -0.5 * ((z / (y / z)) - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+60], N[(-0.5 * N[(N[(x * N[((-x) / y), $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 2 \cdot 10^{+60}:\\
\;\;\;\;-0.5 \cdot \left(x \cdot \frac{-x}{y} - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1.9999999999999999e60Initial program 75.7%
sub-neg75.7%
+-commutative75.7%
neg-sub075.7%
associate-+l-75.7%
sub0-neg75.7%
neg-mul-175.7%
*-commutative75.7%
times-frac75.7%
associate--r+75.7%
div-sub75.7%
difference-of-squares75.7%
+-commutative75.7%
associate-*l/78.4%
*-commutative78.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.8%
un-div-inv99.8%
+-commutative99.8%
Applied egg-rr99.8%
Taylor expanded in z around 0 86.5%
unpow286.5%
associate-*r/86.5%
mul-1-neg86.5%
distribute-rgt-neg-out86.5%
associate-*l/93.0%
Simplified93.0%
if 1.9999999999999999e60 < (*.f64 z z) Initial program 63.0%
sub-neg63.0%
+-commutative63.0%
neg-sub063.0%
associate-+l-63.0%
sub0-neg63.0%
neg-mul-163.0%
*-commutative63.0%
times-frac63.0%
associate--r+63.0%
div-sub63.0%
difference-of-squares75.3%
+-commutative75.3%
associate-*l/75.9%
*-commutative75.9%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 79.3%
unpow279.3%
associate-/l*88.6%
Simplified88.6%
Final simplification91.1%
(FPCore (x y z) :precision binary64 (if (<= x -2.75e+219) (* (/ x y) (* x 0.5)) (if (<= x 4e+78) (* -0.5 (- (/ z (/ y z)) y)) (/ x (* y (/ 2.0 x))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -2.75e+219) {
tmp = (x / y) * (x * 0.5);
} else if (x <= 4e+78) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = x / (y * (2.0 / x));
}
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 <= (-2.75d+219)) then
tmp = (x / y) * (x * 0.5d0)
else if (x <= 4d+78) then
tmp = (-0.5d0) * ((z / (y / z)) - y)
else
tmp = x / (y * (2.0d0 / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -2.75e+219) {
tmp = (x / y) * (x * 0.5);
} else if (x <= 4e+78) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = x / (y * (2.0 / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -2.75e+219: tmp = (x / y) * (x * 0.5) elif x <= 4e+78: tmp = -0.5 * ((z / (y / z)) - y) else: tmp = x / (y * (2.0 / x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -2.75e+219) tmp = Float64(Float64(x / y) * Float64(x * 0.5)); elseif (x <= 4e+78) tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y)); else tmp = Float64(x / Float64(y * Float64(2.0 / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -2.75e+219) tmp = (x / y) * (x * 0.5); elseif (x <= 4e+78) tmp = -0.5 * ((z / (y / z)) - y); else tmp = x / (y * (2.0 / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -2.75e+219], N[(N[(x / y), $MachinePrecision] * N[(x * 0.5), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4e+78], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(x / N[(y * N[(2.0 / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.75 \cdot 10^{+219}:\\
\;\;\;\;\frac{x}{y} \cdot \left(x \cdot 0.5\right)\\
\mathbf{elif}\;x \leq 4 \cdot 10^{+78}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y \cdot \frac{2}{x}}\\
\end{array}
\end{array}
if x < -2.74999999999999986e219Initial program 80.1%
Taylor expanded in x around inf 87.2%
unpow287.2%
Simplified87.2%
times-frac93.4%
div-inv93.4%
metadata-eval93.4%
Applied egg-rr93.4%
if -2.74999999999999986e219 < x < 4.00000000000000003e78Initial program 72.6%
sub-neg72.6%
+-commutative72.6%
neg-sub072.6%
associate-+l-72.6%
sub0-neg72.6%
neg-mul-172.6%
*-commutative72.6%
times-frac72.6%
associate--r+72.6%
div-sub72.6%
difference-of-squares74.1%
+-commutative74.1%
associate-*l/76.0%
*-commutative76.0%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 76.2%
unpow276.2%
associate-/l*81.8%
Simplified81.8%
if 4.00000000000000003e78 < x Initial program 57.5%
Taylor expanded in x around inf 63.4%
unpow263.4%
Simplified63.4%
times-frac68.8%
div-inv68.8%
metadata-eval68.8%
Applied egg-rr68.8%
metadata-eval68.8%
div-inv68.8%
*-commutative68.8%
clear-num68.8%
frac-times68.8%
*-un-lft-identity68.8%
Applied egg-rr68.8%
Final simplification79.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.8e+45) (not (<= y 63000000000.0))) (* y 0.5) (* -0.5 (* z (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.8e+45) || !(y <= 63000000000.0)) {
tmp = y * 0.5;
} else {
tmp = -0.5 * (z * (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 ((y <= (-2.8d+45)) .or. (.not. (y <= 63000000000.0d0))) then
tmp = y * 0.5d0
else
tmp = (-0.5d0) * (z * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -2.8e+45) || !(y <= 63000000000.0)) {
tmp = y * 0.5;
} else {
tmp = -0.5 * (z * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.8e+45) or not (y <= 63000000000.0): tmp = y * 0.5 else: tmp = -0.5 * (z * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.8e+45) || !(y <= 63000000000.0)) tmp = Float64(y * 0.5); else tmp = Float64(-0.5 * Float64(z * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.8e+45) || ~((y <= 63000000000.0))) tmp = y * 0.5; else tmp = -0.5 * (z * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.8e+45], N[Not[LessEqual[y, 63000000000.0]], $MachinePrecision]], N[(y * 0.5), $MachinePrecision], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.8 \cdot 10^{+45} \lor \neg \left(y \leq 63000000000\right):\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if y < -2.7999999999999999e45 or 6.3e10 < y Initial program 44.8%
Taylor expanded in y around inf 67.1%
*-commutative67.1%
Simplified67.1%
if -2.7999999999999999e45 < y < 6.3e10Initial program 90.6%
Taylor expanded in z around inf 48.6%
*-commutative48.6%
unpow248.6%
associate-/l*49.2%
Simplified49.2%
associate-/r/49.3%
Applied egg-rr49.3%
Final simplification57.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 70.1%
Taylor expanded in y around inf 35.1%
*-commutative35.1%
Simplified35.1%
Final simplification35.1%
(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 2023196
(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)))