
(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 (* (- (/ (- z x) (/ y (+ z x))) y) -0.5))
double code(double x, double y, double z) {
return (((z - x) / (y / (z + x))) - 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) / (y / (z + x))) - y) * (-0.5d0)
end function
public static double code(double x, double y, double z) {
return (((z - x) / (y / (z + x))) - y) * -0.5;
}
def code(x, y, z): return (((z - x) / (y / (z + x))) - y) * -0.5
function code(x, y, z) return Float64(Float64(Float64(Float64(z - x) / Float64(y / Float64(z + x))) - y) * -0.5) end
function tmp = code(x, y, z) tmp = (((z - x) / (y / (z + x))) - y) * -0.5; end
code[x_, y_, z_] := N[(N[(N[(N[(z - x), $MachinePrecision] / N[(y / N[(z + x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision] * -0.5), $MachinePrecision]
\begin{array}{l}
\\
\left(\frac{z - x}{\frac{y}{z + x}} - y\right) \cdot -0.5
\end{array}
Initial program 87.4%
sub-neg87.4%
+-commutative87.4%
neg-sub087.4%
associate-+l-87.4%
sub0-neg87.4%
neg-mul-187.4%
*-commutative87.4%
times-frac87.4%
associate--r+87.4%
div-sub87.4%
difference-of-squares98.3%
+-commutative98.3%
associate-*r/99.5%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
associate-*r/98.7%
*-commutative98.7%
associate-/l*99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 5e+32) (* -0.5 (- (* (+ z x) (/ z y)) y)) (* (/ x y) (/ x 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e+32) {
tmp = -0.5 * (((z + x) * (z / y)) - y);
} else {
tmp = (x / y) * (x / 2.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) :: tmp
if ((x * x) <= 5d+32) then
tmp = (-0.5d0) * (((z + x) * (z / y)) - y)
else
tmp = (x / y) * (x / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e+32) {
tmp = -0.5 * (((z + x) * (z / y)) - y);
} else {
tmp = (x / y) * (x / 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 5e+32: tmp = -0.5 * (((z + x) * (z / y)) - y) else: tmp = (x / y) * (x / 2.0) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 5e+32) tmp = Float64(-0.5 * Float64(Float64(Float64(z + x) * Float64(z / y)) - y)); else tmp = Float64(Float64(x / y) * Float64(x / 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 5e+32) tmp = -0.5 * (((z + x) * (z / y)) - y); else tmp = (x / y) * (x / 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e+32], N[(-0.5 * N[(N[(N[(z + x), $MachinePrecision] * N[(z / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+32}:\\
\;\;\;\;-0.5 \cdot \left(\left(z + x\right) \cdot \frac{z}{y} - y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\
\end{array}
\end{array}
if (*.f64 x x) < 4.9999999999999997e32Initial program 96.6%
sub-neg96.6%
+-commutative96.6%
neg-sub096.6%
associate-+l-96.6%
sub0-neg96.6%
neg-mul-196.6%
*-commutative96.6%
times-frac96.6%
associate--r+96.6%
div-sub96.6%
difference-of-squares96.6%
+-commutative96.6%
associate-*r/99.0%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 85.7%
if 4.9999999999999997e32 < (*.f64 x x) Initial program 79.0%
Taylor expanded in x around inf 78.9%
unpow278.9%
Simplified78.9%
times-frac79.0%
Applied egg-rr79.0%
Final simplification82.2%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 4e-92) (* -0.5 (- (* (+ z x) (/ z y)) y)) (* -0.5 (- (* (- z x) (/ x y)) y))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 4e-92) {
tmp = -0.5 * (((z + x) * (z / y)) - 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-92) then
tmp = (-0.5d0) * (((z + x) * (z / y)) - 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-92) {
tmp = -0.5 * (((z + x) * (z / y)) - y);
} else {
tmp = -0.5 * (((z - x) * (x / y)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 4e-92: tmp = -0.5 * (((z + x) * (z / y)) - 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-92) tmp = Float64(-0.5 * Float64(Float64(Float64(z + x) * Float64(z / y)) - 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-92) tmp = -0.5 * (((z + x) * (z / y)) - 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-92], N[(-0.5 * N[(N[(N[(z + x), $MachinePrecision] * N[(z / y), $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^{-92}:\\
\;\;\;\;-0.5 \cdot \left(\left(z + x\right) \cdot \frac{z}{y} - 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) < 3.99999999999999995e-92Initial program 96.0%
sub-neg96.0%
+-commutative96.0%
neg-sub096.0%
associate-+l-96.0%
sub0-neg96.0%
neg-mul-196.0%
*-commutative96.0%
times-frac96.0%
associate--r+96.0%
div-sub96.0%
difference-of-squares96.0%
+-commutative96.0%
associate-*r/98.9%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 91.5%
if 3.99999999999999995e-92 < (*.f64 x x) Initial program 81.7%
sub-neg81.7%
+-commutative81.7%
neg-sub081.7%
associate-+l-81.7%
sub0-neg81.7%
neg-mul-181.7%
*-commutative81.7%
times-frac81.7%
associate--r+81.7%
div-sub81.7%
difference-of-squares99.8%
+-commutative99.8%
associate-*l/99.9%
*-commutative99.9%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 85.9%
Final simplification88.2%
(FPCore (x y z) :precision binary64 (if (<= (* z z) 1e-239) (* -0.5 (- (* (- z x) (/ x y)) y)) (* (/ (+ z x) y) (/ (- x z) 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e-239) {
tmp = -0.5 * (((z - x) * (x / y)) - y);
} else {
tmp = ((z + x) / y) * ((x - z) / 2.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) :: tmp
if ((z * z) <= 1d-239) then
tmp = (-0.5d0) * (((z - x) * (x / y)) - y)
else
tmp = ((z + x) / y) * ((x - z) / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 1e-239) {
tmp = -0.5 * (((z - x) * (x / y)) - y);
} else {
tmp = ((z + x) / y) * ((x - z) / 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z * z) <= 1e-239: tmp = -0.5 * (((z - x) * (x / y)) - y) else: tmp = ((z + x) / y) * ((x - z) / 2.0) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 1e-239) tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) * Float64(x / y)) - y)); else tmp = Float64(Float64(Float64(z + x) / y) * Float64(Float64(x - z) / 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 1e-239) tmp = -0.5 * (((z - x) * (x / y)) - y); else tmp = ((z + x) / y) * ((x - z) / 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 1e-239], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(N[(N[(z + x), $MachinePrecision] / y), $MachinePrecision] * N[(N[(x - z), $MachinePrecision] / 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 10^{-239}:\\
\;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{x}{y} - y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{z + x}{y} \cdot \frac{x - z}{2}\\
\end{array}
\end{array}
if (*.f64 z z) < 1.0000000000000001e-239Initial program 94.7%
sub-neg94.7%
+-commutative94.7%
neg-sub094.7%
associate-+l-94.7%
sub0-neg94.7%
neg-mul-194.7%
*-commutative94.7%
times-frac94.7%
associate--r+94.7%
div-sub94.7%
difference-of-squares94.7%
+-commutative94.7%
associate-*l/98.6%
*-commutative98.6%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 95.0%
if 1.0000000000000001e-239 < (*.f64 z z) Initial program 84.2%
Taylor expanded in y around 0 82.9%
unpow282.9%
unpow282.9%
Simplified82.9%
difference-of-squares98.5%
times-frac98.5%
+-commutative98.5%
Applied egg-rr98.5%
Final simplification97.5%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 5e+32) (* -0.5 (- (/ (* z z) y) y)) (* (/ x y) (/ x 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e+32) {
tmp = -0.5 * (((z * z) / y) - y);
} else {
tmp = (x / y) * (x / 2.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) :: tmp
if ((x * x) <= 5d+32) then
tmp = (-0.5d0) * (((z * z) / y) - y)
else
tmp = (x / y) * (x / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e+32) {
tmp = -0.5 * (((z * z) / y) - y);
} else {
tmp = (x / y) * (x / 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 5e+32: tmp = -0.5 * (((z * z) / y) - y) else: tmp = (x / y) * (x / 2.0) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 5e+32) tmp = Float64(-0.5 * Float64(Float64(Float64(z * z) / y) - y)); else tmp = Float64(Float64(x / y) * Float64(x / 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 5e+32) tmp = -0.5 * (((z * z) / y) - y); else tmp = (x / y) * (x / 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e+32], N[(-0.5 * N[(N[(N[(z * z), $MachinePrecision] / y), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+32}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z \cdot z}{y} - y\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\
\end{array}
\end{array}
if (*.f64 x x) < 4.9999999999999997e32Initial program 96.6%
sub-neg96.6%
+-commutative96.6%
neg-sub096.6%
associate-+l-96.6%
sub0-neg96.6%
neg-mul-196.6%
*-commutative96.6%
times-frac96.6%
associate--r+96.6%
div-sub96.6%
difference-of-squares96.6%
+-commutative96.6%
associate-*r/99.0%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 84.1%
unpow284.1%
Simplified84.1%
if 4.9999999999999997e32 < (*.f64 x x) Initial program 79.0%
Taylor expanded in x around inf 78.9%
unpow278.9%
Simplified78.9%
times-frac79.0%
Applied egg-rr79.0%
Final simplification81.4%
(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 87.4%
sub-neg87.4%
+-commutative87.4%
neg-sub087.4%
associate-+l-87.4%
sub0-neg87.4%
neg-mul-187.4%
*-commutative87.4%
times-frac87.4%
associate--r+87.4%
div-sub87.4%
difference-of-squares98.3%
+-commutative98.3%
associate-*r/99.5%
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) 5e+32) (* -0.5 (/ z (/ y z))) (* (/ x y) (/ x 2.0))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e+32) {
tmp = -0.5 * (z / (y / z));
} else {
tmp = (x / y) * (x / 2.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) :: tmp
if ((x * x) <= 5d+32) then
tmp = (-0.5d0) * (z / (y / z))
else
tmp = (x / y) * (x / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e+32) {
tmp = -0.5 * (z / (y / z));
} else {
tmp = (x / y) * (x / 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 5e+32: tmp = -0.5 * (z / (y / z)) else: tmp = (x / y) * (x / 2.0) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 5e+32) tmp = Float64(-0.5 * Float64(z / Float64(y / z))); else tmp = Float64(Float64(x / y) * Float64(x / 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 5e+32) tmp = -0.5 * (z / (y / z)); else tmp = (x / y) * (x / 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e+32], N[(-0.5 * N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+32}:\\
\;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\
\end{array}
\end{array}
if (*.f64 x x) < 4.9999999999999997e32Initial program 96.6%
Taylor expanded in z around inf 67.6%
*-commutative67.6%
unpow267.6%
associate-/l*69.2%
Simplified69.2%
if 4.9999999999999997e32 < (*.f64 x x) Initial program 79.0%
Taylor expanded in x around inf 78.9%
unpow278.9%
Simplified78.9%
times-frac79.0%
Applied egg-rr79.0%
Final simplification74.3%
(FPCore (x y z) :precision binary64 (if (<= x 6.8e-136) (* y 0.5) (* (* x x) (/ 0.5 y))))
double code(double x, double y, double z) {
double tmp;
if (x <= 6.8e-136) {
tmp = y * 0.5;
} 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 <= 6.8d-136) then
tmp = y * 0.5d0
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 <= 6.8e-136) {
tmp = y * 0.5;
} else {
tmp = (x * x) * (0.5 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 6.8e-136: tmp = y * 0.5 else: tmp = (x * x) * (0.5 / y) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 6.8e-136) tmp = Float64(y * 0.5); else tmp = Float64(Float64(x * x) * Float64(0.5 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 6.8e-136) tmp = y * 0.5; else tmp = (x * x) * (0.5 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 6.8e-136], N[(y * 0.5), $MachinePrecision], N[(N[(x * x), $MachinePrecision] * N[(0.5 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.8 \cdot 10^{-136}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\left(x \cdot x\right) \cdot \frac{0.5}{y}\\
\end{array}
\end{array}
if x < 6.8000000000000001e-136Initial program 88.5%
Taylor expanded in y around inf 11.6%
*-commutative11.6%
Simplified11.6%
if 6.8000000000000001e-136 < x Initial program 85.4%
Taylor expanded in y around 0 82.2%
unpow282.2%
unpow282.2%
Simplified82.2%
Taylor expanded in x around inf 61.1%
associate-*r/61.1%
associate-*l/61.0%
*-commutative61.0%
unpow261.0%
Simplified61.0%
Final simplification29.0%
(FPCore (x y z) :precision binary64 (if (<= x 6.8e-136) (* y 0.5) (* (/ x y) (/ x 2.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= 6.8e-136) {
tmp = y * 0.5;
} else {
tmp = (x / y) * (x / 2.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) :: tmp
if (x <= 6.8d-136) then
tmp = y * 0.5d0
else
tmp = (x / y) * (x / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 6.8e-136) {
tmp = y * 0.5;
} else {
tmp = (x / y) * (x / 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 6.8e-136: tmp = y * 0.5 else: tmp = (x / y) * (x / 2.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 6.8e-136) tmp = Float64(y * 0.5); else tmp = Float64(Float64(x / y) * Float64(x / 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 6.8e-136) tmp = y * 0.5; else tmp = (x / y) * (x / 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 6.8e-136], N[(y * 0.5), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.8 \cdot 10^{-136}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\
\end{array}
\end{array}
if x < 6.8000000000000001e-136Initial program 88.5%
Taylor expanded in y around inf 11.6%
*-commutative11.6%
Simplified11.6%
if 6.8000000000000001e-136 < x Initial program 85.4%
Taylor expanded in x around inf 61.1%
unpow261.1%
Simplified61.1%
times-frac61.1%
Applied egg-rr61.1%
Final simplification29.0%
(FPCore (x y z) :precision binary64 (if (<= x 6.2e+16) (* (/ z y) (* z -0.5)) (* (/ x y) (/ x 2.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= 6.2e+16) {
tmp = (z / y) * (z * -0.5);
} else {
tmp = (x / y) * (x / 2.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) :: tmp
if (x <= 6.2d+16) then
tmp = (z / y) * (z * (-0.5d0))
else
tmp = (x / y) * (x / 2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 6.2e+16) {
tmp = (z / y) * (z * -0.5);
} else {
tmp = (x / y) * (x / 2.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 6.2e+16: tmp = (z / y) * (z * -0.5) else: tmp = (x / y) * (x / 2.0) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 6.2e+16) tmp = Float64(Float64(z / y) * Float64(z * -0.5)); else tmp = Float64(Float64(x / y) * Float64(x / 2.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 6.2e+16) tmp = (z / y) * (z * -0.5); else tmp = (x / y) * (x / 2.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 6.2e+16], N[(N[(z / y), $MachinePrecision] * N[(z * -0.5), $MachinePrecision]), $MachinePrecision], N[(N[(x / y), $MachinePrecision] * N[(x / 2.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 6.2 \cdot 10^{+16}:\\
\;\;\;\;\frac{z}{y} \cdot \left(z \cdot -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{y} \cdot \frac{x}{2}\\
\end{array}
\end{array}
if x < 6.2e16Initial program 90.1%
Taylor expanded in z around inf 49.6%
*-commutative49.6%
unpow249.6%
Simplified49.6%
Taylor expanded in z around 0 49.6%
*-commutative49.6%
unpow249.6%
associate-*l/50.5%
associate-*l*50.5%
Simplified50.5%
if 6.2e16 < x Initial program 78.9%
Taylor expanded in x around inf 77.2%
unpow277.2%
Simplified77.2%
times-frac77.1%
Applied egg-rr77.1%
Final simplification57.0%
(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 87.4%
Taylor expanded in y around inf 9.4%
*-commutative9.4%
Simplified9.4%
Final simplification9.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 2023278
(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)))