
(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 (* (- (* (+ x z) (/ (- z x) y)) y) -0.5))
double code(double x, double y, double z) {
return (((x + z) * ((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 = (((x + z) * ((z - x) / y)) - y) * (-0.5d0)
end function
public static double code(double x, double y, double z) {
return (((x + z) * ((z - x) / y)) - y) * -0.5;
}
def code(x, y, z): return (((x + z) * ((z - x) / y)) - y) * -0.5
function code(x, y, z) return Float64(Float64(Float64(Float64(x + z) * Float64(Float64(z - x) / y)) - y) * -0.5) end
function tmp = code(x, y, z) tmp = (((x + z) * ((z - x) / y)) - y) * -0.5; end
code[x_, y_, z_] := N[(N[(N[(N[(x + z), $MachinePrecision] * N[(N[(z - x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\left(x + z\right) \cdot \frac{z - x}{y} - y\right) \cdot -0.5
\end{array}
Initial program 73.2%
sub-neg73.2%
+-commutative73.2%
neg-sub073.2%
associate-+l-73.2%
sub0-neg73.2%
neg-mul-173.2%
*-commutative73.2%
times-frac73.2%
associate--r+73.2%
div-sub73.2%
difference-of-squares77.5%
+-commutative77.5%
associate-*r/79.7%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 4e+121) (* -0.5 (- (/ z (/ y z)) y)) (* -0.5 (- (* (+ x z) (- (/ x y))) y))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4e+121) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = -0.5 * (((x + z) * -(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+121) then
tmp = (-0.5d0) * ((z / (y / z)) - y)
else
tmp = (-0.5d0) * (((x + z) * -(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+121) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = -0.5 * (((x + z) * -(x / y)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 4e+121: tmp = -0.5 * ((z / (y / z)) - y) else: tmp = -0.5 * (((x + z) * -(x / y)) - y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 4e+121) tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y)); else tmp = Float64(-0.5 * Float64(Float64(Float64(x + z) * Float64(-Float64(x / y))) - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 4e+121) tmp = -0.5 * ((z / (y / z)) - y); else tmp = -0.5 * (((x + z) * -(x / y)) - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 4e+121], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(N[(x + z), $MachinePrecision] * (-N[(x / y), $MachinePrecision])), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 4 \cdot 10^{+121}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\left(x + z\right) \cdot \left(-\frac{x}{y}\right) - y\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 4.00000000000000015e121Initial program 75.6%
sub-neg75.6%
+-commutative75.6%
neg-sub075.6%
associate-+l-75.6%
sub0-neg75.6%
neg-mul-175.6%
*-commutative75.6%
times-frac75.6%
associate--r+75.6%
div-sub75.6%
difference-of-squares75.6%
+-commutative75.6%
associate-*r/76.9%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 88.0%
unpow288.0%
associate-/l*91.1%
Simplified91.1%
if 4.00000000000000015e121 < (*.f64 x x) Initial program 69.7%
sub-neg69.7%
+-commutative69.7%
neg-sub069.7%
associate-+l-69.7%
sub0-neg69.7%
neg-mul-169.7%
*-commutative69.7%
times-frac69.7%
associate--r+69.7%
div-sub69.7%
difference-of-squares80.3%
+-commutative80.3%
associate-*r/83.8%
associate-/l*99.8%
*-inverses99.8%
/-rgt-identity99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 92.2%
neg-mul-192.2%
distribute-neg-frac92.2%
Simplified92.2%
Final simplification91.5%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 1e+161) (* -0.5 (- (* x (- (/ x y))) y)) (* -0.5 (- (* (+ x z) (/ z y)) y))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+161) {
tmp = -0.5 * ((x * -(x / y)) - y);
} else {
tmp = -0.5 * (((x + z) * (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) <= 1d+161) then
tmp = (-0.5d0) * ((x * -(x / y)) - y)
else
tmp = (-0.5d0) * (((x + z) * (z / y)) - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e+161) {
tmp = -0.5 * ((x * -(x / y)) - y);
} else {
tmp = -0.5 * (((x + z) * (z / y)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 1e+161: tmp = -0.5 * ((x * -(x / y)) - y) else: tmp = -0.5 * (((x + z) * (z / y)) - y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e+161) tmp = Float64(-0.5 * Float64(Float64(x * Float64(-Float64(x / y))) - y)); else tmp = Float64(-0.5 * Float64(Float64(Float64(x + z) * Float64(z / y)) - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 1e+161) tmp = -0.5 * ((x * -(x / y)) - y); else tmp = -0.5 * (((x + z) * (z / y)) - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e+161], N[(-0.5 * N[(N[(x * (-N[(x / y), $MachinePrecision])), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(N[(x + z), $MachinePrecision] * N[(z / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{+161}:\\
\;\;\;\;-0.5 \cdot \left(x \cdot \left(-\frac{x}{y}\right) - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\left(x + z\right) \cdot \frac{z}{y} - y\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1e161Initial program 74.7%
sub-neg74.7%
+-commutative74.7%
neg-sub074.7%
associate-+l-74.7%
sub0-neg74.7%
neg-mul-174.7%
*-commutative74.7%
times-frac74.7%
associate--r+74.7%
div-sub74.6%
difference-of-squares74.6%
+-commutative74.6%
associate-*r/76.8%
associate-/l*99.8%
*-inverses99.8%
/-rgt-identity99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 83.7%
mul-1-neg83.7%
unpow283.7%
associate-*r/90.9%
distribute-lft-neg-in90.9%
Simplified90.9%
if 1e161 < (*.f64 z z) Initial program 70.7%
sub-neg70.7%
+-commutative70.7%
neg-sub070.7%
associate-+l-70.7%
sub0-neg70.7%
neg-mul-170.7%
*-commutative70.7%
times-frac70.7%
associate--r+70.7%
div-sub70.7%
difference-of-squares82.5%
+-commutative82.5%
associate-*r/84.6%
associate-/l*100.0%
*-inverses100.0%
/-rgt-identity100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 88.6%
Final simplification90.0%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 5e+125) (* -0.5 (- (/ z (/ y z)) y)) (* -0.5 (- (* x (- (/ x y))) y))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e+125) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = -0.5 * ((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) <= 5d+125) then
tmp = (-0.5d0) * ((z / (y / z)) - y)
else
tmp = (-0.5d0) * ((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) <= 5e+125) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = -0.5 * ((x * -(x / y)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 5e+125: tmp = -0.5 * ((z / (y / z)) - y) else: tmp = -0.5 * ((x * -(x / y)) - y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 5e+125) tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y)); else tmp = Float64(-0.5 * Float64(Float64(x * Float64(-Float64(x / y))) - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 5e+125) tmp = -0.5 * ((z / (y / z)) - y); else tmp = -0.5 * ((x * -(x / y)) - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e+125], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(x * (-N[(x / y), $MachinePrecision])), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+125}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(x \cdot \left(-\frac{x}{y}\right) - y\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 4.99999999999999962e125Initial program 75.8%
sub-neg75.8%
+-commutative75.8%
neg-sub075.8%
associate-+l-75.8%
sub0-neg75.8%
neg-mul-175.8%
*-commutative75.8%
times-frac75.8%
associate--r+75.8%
div-sub75.7%
difference-of-squares75.7%
+-commutative75.7%
associate-*r/77.0%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 88.1%
unpow288.1%
associate-/l*91.1%
Simplified91.1%
if 4.99999999999999962e125 < (*.f64 x x) Initial program 69.4%
sub-neg69.4%
+-commutative69.4%
neg-sub069.4%
associate-+l-69.4%
sub0-neg69.4%
neg-mul-169.4%
*-commutative69.4%
times-frac69.4%
associate--r+69.4%
div-sub69.4%
difference-of-squares80.2%
+-commutative80.2%
associate-*r/83.6%
associate-/l*99.8%
*-inverses99.8%
/-rgt-identity99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
associate-/r/99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 75.0%
mul-1-neg75.0%
unpow275.0%
associate-*r/87.2%
distribute-lft-neg-in87.2%
Simplified87.2%
Final simplification89.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (* x (/ 0.5 y)))))
(if (<= x -2.8e+46)
t_0
(if (<= x 1.9e-112)
(* y 0.5)
(if (<= x 7e+62) (* -0.5 (* z (/ z y))) t_0)))))
double code(double x, double y, double z) {
double t_0 = x * (x * (0.5 / y));
double tmp;
if (x <= -2.8e+46) {
tmp = t_0;
} else if (x <= 1.9e-112) {
tmp = y * 0.5;
} else if (x <= 7e+62) {
tmp = -0.5 * (z * (z / y));
} 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 * (x * (0.5d0 / y))
if (x <= (-2.8d+46)) then
tmp = t_0
else if (x <= 1.9d-112) then
tmp = y * 0.5d0
else if (x <= 7d+62) then
tmp = (-0.5d0) * (z * (z / y))
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (x * (0.5 / y));
double tmp;
if (x <= -2.8e+46) {
tmp = t_0;
} else if (x <= 1.9e-112) {
tmp = y * 0.5;
} else if (x <= 7e+62) {
tmp = -0.5 * (z * (z / y));
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (x * (0.5 / y)) tmp = 0 if x <= -2.8e+46: tmp = t_0 elif x <= 1.9e-112: tmp = y * 0.5 elif x <= 7e+62: tmp = -0.5 * (z * (z / y)) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(x * Float64(0.5 / y))) tmp = 0.0 if (x <= -2.8e+46) tmp = t_0; elseif (x <= 1.9e-112) tmp = Float64(y * 0.5); elseif (x <= 7e+62) tmp = Float64(-0.5 * Float64(z * Float64(z / y))); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (x * (0.5 / y)); tmp = 0.0; if (x <= -2.8e+46) tmp = t_0; elseif (x <= 1.9e-112) tmp = y * 0.5; elseif (x <= 7e+62) tmp = -0.5 * (z * (z / y)); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.8e+46], t$95$0, If[LessEqual[x, 1.9e-112], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 7e+62], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\mathbf{if}\;x \leq -2.8 \cdot 10^{+46}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.9 \cdot 10^{-112}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+62}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -2.80000000000000018e46 or 6.99999999999999967e62 < x Initial program 70.6%
Taylor expanded in x around inf 64.3%
unpow264.3%
Simplified64.3%
Taylor expanded in x around 0 64.3%
unpow264.3%
associate-*r/64.3%
associate-*l/64.2%
*-commutative64.2%
associate-*r*72.5%
Simplified72.5%
if -2.80000000000000018e46 < x < 1.89999999999999997e-112Initial program 71.5%
Taylor expanded in y around inf 54.4%
*-commutative54.4%
Simplified54.4%
if 1.89999999999999997e-112 < x < 6.99999999999999967e62Initial program 88.2%
Taylor expanded in z around inf 56.3%
*-commutative56.3%
unpow256.3%
associate-/l*61.8%
Simplified61.8%
associate-/r/61.8%
Applied egg-rr61.8%
Final simplification62.9%
(FPCore (x y z)
:precision binary64
(if (<= x -3e+46)
(* 0.5 (/ x (/ y x)))
(if (<= x 2e-112)
(* y 0.5)
(if (<= x 4.9e+63) (* -0.5 (* z (/ z y))) (* x (* x (/ 0.5 y)))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3e+46) {
tmp = 0.5 * (x / (y / x));
} else if (x <= 2e-112) {
tmp = y * 0.5;
} else if (x <= 4.9e+63) {
tmp = -0.5 * (z * (z / 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 <= (-3d+46)) then
tmp = 0.5d0 * (x / (y / x))
else if (x <= 2d-112) then
tmp = y * 0.5d0
else if (x <= 4.9d+63) then
tmp = (-0.5d0) * (z * (z / 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 <= -3e+46) {
tmp = 0.5 * (x / (y / x));
} else if (x <= 2e-112) {
tmp = y * 0.5;
} else if (x <= 4.9e+63) {
tmp = -0.5 * (z * (z / y));
} else {
tmp = x * (x * (0.5 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3e+46: tmp = 0.5 * (x / (y / x)) elif x <= 2e-112: tmp = y * 0.5 elif x <= 4.9e+63: tmp = -0.5 * (z * (z / y)) else: tmp = x * (x * (0.5 / y)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3e+46) tmp = Float64(0.5 * Float64(x / Float64(y / x))); elseif (x <= 2e-112) tmp = Float64(y * 0.5); elseif (x <= 4.9e+63) tmp = Float64(-0.5 * Float64(z * Float64(z / y))); else tmp = Float64(x * Float64(x * Float64(0.5 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3e+46) tmp = 0.5 * (x / (y / x)); elseif (x <= 2e-112) tmp = y * 0.5; elseif (x <= 4.9e+63) tmp = -0.5 * (z * (z / y)); else tmp = x * (x * (0.5 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3e+46], N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2e-112], N[(y * 0.5), $MachinePrecision], If[LessEqual[x, 4.9e+63], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{+46}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-112}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;x \leq 4.9 \cdot 10^{+63}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\end{array}
\end{array}
if x < -3.00000000000000023e46Initial program 73.5%
Taylor expanded in x around inf 67.0%
*-commutative67.0%
unpow267.0%
associate-/l*72.5%
Simplified72.5%
if -3.00000000000000023e46 < x < 1.9999999999999999e-112Initial program 71.5%
Taylor expanded in y around inf 54.4%
*-commutative54.4%
Simplified54.4%
if 1.9999999999999999e-112 < x < 4.8999999999999997e63Initial program 88.2%
Taylor expanded in z around inf 56.3%
*-commutative56.3%
unpow256.3%
associate-/l*61.8%
Simplified61.8%
associate-/r/61.8%
Applied egg-rr61.8%
if 4.8999999999999997e63 < x Initial program 66.7%
Taylor expanded in x around inf 60.7%
unpow260.7%
Simplified60.7%
Taylor expanded in x around 0 60.7%
unpow260.7%
associate-*r/60.7%
associate-*l/60.6%
*-commutative60.6%
associate-*r*72.5%
Simplified72.5%
Final simplification62.9%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.7e+69) (not (<= x 1.2e+153))) (* x (* x (/ 0.5 y))) (* -0.5 (- (/ z (/ y z)) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.7e+69) || !(x <= 1.2e+153)) {
tmp = x * (x * (0.5 / 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 ((x <= (-1.7d+69)) .or. (.not. (x <= 1.2d+153))) then
tmp = x * (x * (0.5d0 / 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 ((x <= -1.7e+69) || !(x <= 1.2e+153)) {
tmp = x * (x * (0.5 / y));
} else {
tmp = -0.5 * ((z / (y / z)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.7e+69) or not (x <= 1.2e+153): tmp = x * (x * (0.5 / y)) else: tmp = -0.5 * ((z / (y / z)) - y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.7e+69) || !(x <= 1.2e+153)) tmp = Float64(x * Float64(x * Float64(0.5 / 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 ((x <= -1.7e+69) || ~((x <= 1.2e+153))) tmp = x * (x * (0.5 / y)); else tmp = -0.5 * ((z / (y / z)) - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.7e+69], N[Not[LessEqual[x, 1.2e+153]], $MachinePrecision]], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+69} \lor \neg \left(x \leq 1.2 \cdot 10^{+153}\right):\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\end{array}
\end{array}
if x < -1.69999999999999993e69 or 1.19999999999999996e153 < x Initial program 69.0%
Taylor expanded in x around inf 71.3%
unpow271.3%
Simplified71.3%
Taylor expanded in x around 0 71.3%
unpow271.3%
associate-*r/71.3%
associate-*l/71.3%
*-commutative71.3%
associate-*r*81.6%
Simplified81.6%
if -1.69999999999999993e69 < x < 1.19999999999999996e153Initial program 75.4%
sub-neg75.4%
+-commutative75.4%
neg-sub075.4%
associate-+l-75.4%
sub0-neg75.4%
neg-mul-175.4%
*-commutative75.4%
times-frac75.4%
associate--r+75.4%
div-sub75.3%
difference-of-squares75.3%
+-commutative75.3%
associate-*r/76.5%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 85.1%
unpow285.1%
associate-/l*88.4%
Simplified88.4%
Final simplification86.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.9e+46) (not (<= x 1.04e+152))) (* x (* x (/ 0.5 y))) (* y 0.5)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.9e+46) || !(x <= 1.04e+152)) {
tmp = x * (x * (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 ((x <= (-1.9d+46)) .or. (.not. (x <= 1.04d+152))) then
tmp = x * (x * (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 ((x <= -1.9e+46) || !(x <= 1.04e+152)) {
tmp = x * (x * (0.5 / y));
} else {
tmp = y * 0.5;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.9e+46) or not (x <= 1.04e+152): tmp = x * (x * (0.5 / y)) else: tmp = y * 0.5 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.9e+46) || !(x <= 1.04e+152)) tmp = Float64(x * Float64(x * Float64(0.5 / y))); else tmp = Float64(y * 0.5); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.9e+46) || ~((x <= 1.04e+152))) tmp = x * (x * (0.5 / y)); else tmp = y * 0.5; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.9e+46], N[Not[LessEqual[x, 1.04e+152]], $MachinePrecision]], N[(x * N[(x * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{+46} \lor \neg \left(x \leq 1.04 \cdot 10^{+152}\right):\\
\;\;\;\;x \cdot \left(x \cdot \frac{0.5}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if x < -1.9e46 or 1.04000000000000005e152 < x Initial program 70.3%
Taylor expanded in x around inf 69.3%
unpow269.3%
Simplified69.3%
Taylor expanded in x around 0 69.3%
unpow269.3%
associate-*r/69.3%
associate-*l/69.3%
*-commutative69.3%
associate-*r*79.1%
Simplified79.1%
if -1.9e46 < x < 1.04000000000000005e152Initial program 74.8%
Taylor expanded in y around inf 46.4%
*-commutative46.4%
Simplified46.4%
Final simplification57.9%
(FPCore (x y z) :precision binary64 (* y 0.5))
double code(double x, double y, double z) {
return y * 0.5;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y * 0.5d0
end function
public static double code(double x, double y, double z) {
return y * 0.5;
}
def code(x, y, z): return y * 0.5
function code(x, y, z) return Float64(y * 0.5) end
function tmp = code(x, y, z) tmp = y * 0.5; end
code[x_, y_, z_] := N[(y * 0.5), $MachinePrecision]
\begin{array}{l}
\\
y \cdot 0.5
\end{array}
Initial program 73.2%
Taylor expanded in y around inf 33.9%
*-commutative33.9%
Simplified33.9%
Final simplification33.9%
(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 2023181
(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)))