
(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 8 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 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-squares73.0%
+-commutative73.0%
associate-*l/76.5%
*-commutative76.5%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
un-div-inv99.9%
+-commutative99.9%
Applied egg-rr99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -0.5 (/ z (/ y z)))))
(if (<= (* z z) 1e-164)
(* y 0.5)
(if (<= (* z z) 5e-122)
(* 0.5 (/ x (/ y x)))
(if (<= (* z z) 5e+75)
(* y 0.5)
(if (<= (* z z) 2e+165)
t_0
(if (<= (* z z) 1e+197)
(* x (/ x (* y 2.0)))
(if (<= (* z z) 1e+245) (* y 0.5) t_0))))))))
double code(double x, double y, double z) {
double t_0 = -0.5 * (z / (y / z));
double tmp;
if ((z * z) <= 1e-164) {
tmp = y * 0.5;
} else if ((z * z) <= 5e-122) {
tmp = 0.5 * (x / (y / x));
} else if ((z * z) <= 5e+75) {
tmp = y * 0.5;
} else if ((z * z) <= 2e+165) {
tmp = t_0;
} else if ((z * z) <= 1e+197) {
tmp = x * (x / (y * 2.0));
} else if ((z * z) <= 1e+245) {
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 / (y / z))
if ((z * z) <= 1d-164) then
tmp = y * 0.5d0
else if ((z * z) <= 5d-122) then
tmp = 0.5d0 * (x / (y / x))
else if ((z * z) <= 5d+75) then
tmp = y * 0.5d0
else if ((z * z) <= 2d+165) then
tmp = t_0
else if ((z * z) <= 1d+197) then
tmp = x * (x / (y * 2.0d0))
else if ((z * z) <= 1d+245) 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 / (y / z));
double tmp;
if ((z * z) <= 1e-164) {
tmp = y * 0.5;
} else if ((z * z) <= 5e-122) {
tmp = 0.5 * (x / (y / x));
} else if ((z * z) <= 5e+75) {
tmp = y * 0.5;
} else if ((z * z) <= 2e+165) {
tmp = t_0;
} else if ((z * z) <= 1e+197) {
tmp = x * (x / (y * 2.0));
} else if ((z * z) <= 1e+245) {
tmp = y * 0.5;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -0.5 * (z / (y / z)) tmp = 0 if (z * z) <= 1e-164: tmp = y * 0.5 elif (z * z) <= 5e-122: tmp = 0.5 * (x / (y / x)) elif (z * z) <= 5e+75: tmp = y * 0.5 elif (z * z) <= 2e+165: tmp = t_0 elif (z * z) <= 1e+197: tmp = x * (x / (y * 2.0)) elif (z * z) <= 1e+245: tmp = y * 0.5 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-0.5 * Float64(z / Float64(y / z))) tmp = 0.0 if (Float64(z * z) <= 1e-164) tmp = Float64(y * 0.5); elseif (Float64(z * z) <= 5e-122) tmp = Float64(0.5 * Float64(x / Float64(y / x))); elseif (Float64(z * z) <= 5e+75) tmp = Float64(y * 0.5); elseif (Float64(z * z) <= 2e+165) tmp = t_0; elseif (Float64(z * z) <= 1e+197) tmp = Float64(x * Float64(x / Float64(y * 2.0))); elseif (Float64(z * z) <= 1e+245) 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 / (y / z)); tmp = 0.0; if ((z * z) <= 1e-164) tmp = y * 0.5; elseif ((z * z) <= 5e-122) tmp = 0.5 * (x / (y / x)); elseif ((z * z) <= 5e+75) tmp = y * 0.5; elseif ((z * z) <= 2e+165) tmp = t_0; elseif ((z * z) <= 1e+197) tmp = x * (x / (y * 2.0)); elseif ((z * z) <= 1e+245) 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[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * z), $MachinePrecision], 1e-164], N[(y * 0.5), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 5e-122], N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 5e+75], N[(y * 0.5), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 2e+165], t$95$0, If[LessEqual[N[(z * z), $MachinePrecision], 1e+197], N[(x * N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 1e+245], N[(y * 0.5), $MachinePrecision], t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -0.5 \cdot \frac{z}{\frac{y}{z}}\\
\mathbf{if}\;z \cdot z \leq 10^{-164}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{-122}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\
\mathbf{elif}\;z \cdot z \leq 5 \cdot 10^{+75}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;z \cdot z \leq 2 \cdot 10^{+165}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \cdot z \leq 10^{+197}:\\
\;\;\;\;x \cdot \frac{x}{y \cdot 2}\\
\mathbf{elif}\;z \cdot z \leq 10^{+245}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if (*.f64 z z) < 9.99999999999999962e-165 or 4.9999999999999999e-122 < (*.f64 z z) < 5.0000000000000002e75 or 9.9999999999999995e196 < (*.f64 z z) < 1.00000000000000004e245Initial program 72.2%
Taylor expanded in y around inf 55.4%
*-commutative55.4%
Simplified55.4%
if 9.99999999999999962e-165 < (*.f64 z z) < 4.9999999999999999e-122Initial program 76.3%
Taylor expanded in x around inf 59.4%
unpow259.4%
Simplified59.4%
Taylor expanded in x around 0 59.4%
*-commutative59.4%
unpow259.4%
associate-*l/67.0%
associate-/r/67.1%
Simplified67.1%
if 5.0000000000000002e75 < (*.f64 z z) < 1.9999999999999998e165 or 1.00000000000000004e245 < (*.f64 z z) Initial program 65.7%
Taylor expanded in z around inf 66.5%
*-commutative66.5%
unpow266.5%
associate-/l*70.9%
Simplified70.9%
if 1.9999999999999998e165 < (*.f64 z z) < 9.9999999999999995e196Initial program 60.5%
Taylor expanded in x around inf 59.7%
unpow259.7%
Simplified59.7%
associate-/l*85.9%
associate-/r/86.1%
Applied egg-rr86.1%
Final simplification63.1%
(FPCore (x y z) :precision binary64 (if (<= (* x x) 1e-36) (* -0.5 (- (/ z (/ y z)) y)) (* -0.5 (- (* (- z x) (/ x y)) y))))
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e-36) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = -0.5 * (((z - x) * (x / y)) - y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x * x) <= 1d-36) then
tmp = (-0.5d0) * ((z / (y / z)) - y)
else
tmp = (-0.5d0) * (((z - x) * (x / y)) - y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e-36) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = -0.5 * (((z - x) * (x / y)) - y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x * x) <= 1e-36: tmp = -0.5 * ((z / (y / z)) - y) else: tmp = -0.5 * (((z - x) * (x / y)) - y) return tmp
function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 1e-36) tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y)); else tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) * Float64(x / y)) - y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 1e-36) tmp = -0.5 * ((z / (y / z)) - y); else tmp = -0.5 * (((z - x) * (x / y)) - y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e-36], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(-0.5 * N[(N[(N[(z - x), $MachinePrecision] * N[(x / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{-36}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(\left(z - x\right) \cdot \frac{x}{y} - y\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 9.9999999999999994e-37Initial program 70.4%
sub-neg70.4%
+-commutative70.4%
neg-sub070.4%
associate-+l-70.4%
sub0-neg70.4%
neg-mul-170.4%
*-commutative70.4%
times-frac70.4%
associate--r+70.4%
div-sub70.4%
difference-of-squares70.4%
+-commutative70.4%
associate-*l/73.0%
*-commutative73.0%
associate-/l*100.0%
*-inverses100.0%
/-rgt-identity100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in z around inf 90.7%
unpow290.7%
associate-/l*96.9%
Simplified96.9%
if 9.9999999999999994e-37 < (*.f64 x x) Initial program 68.5%
sub-neg68.5%
+-commutative68.5%
neg-sub068.5%
associate-+l-68.5%
sub0-neg68.5%
neg-mul-168.5%
*-commutative68.5%
times-frac68.5%
associate--r+68.5%
div-sub68.5%
difference-of-squares75.5%
+-commutative75.5%
associate-*l/79.9%
*-commutative79.9%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 84.9%
Final simplification90.8%
(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 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-squares73.0%
+-commutative73.0%
associate-*l/76.5%
*-commutative76.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 5.5e+172) (* -0.5 (- (/ z (/ y z)) y)) (* x (/ x (* y 2.0)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 5.5e+172) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = x * (x / (y * 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 <= 5.5d+172) then
tmp = (-0.5d0) * ((z / (y / z)) - y)
else
tmp = x * (x / (y * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 5.5e+172) {
tmp = -0.5 * ((z / (y / z)) - y);
} else {
tmp = x * (x / (y * 2.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 5.5e+172: tmp = -0.5 * ((z / (y / z)) - y) else: tmp = x * (x / (y * 2.0)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 5.5e+172) tmp = Float64(-0.5 * Float64(Float64(z / Float64(y / z)) - y)); else tmp = Float64(x * Float64(x / Float64(y * 2.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 5.5e+172) tmp = -0.5 * ((z / (y / z)) - y); else tmp = x * (x / (y * 2.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 5.5e+172], N[(-0.5 * N[(N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(x * N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 5.5 \cdot 10^{+172}:\\
\;\;\;\;-0.5 \cdot \left(\frac{z}{\frac{y}{z}} - y\right)\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{x}{y \cdot 2}\\
\end{array}
\end{array}
if x < 5.4999999999999999e172Initial program 69.0%
sub-neg69.0%
+-commutative69.0%
neg-sub069.0%
associate-+l-69.0%
sub0-neg69.0%
neg-mul-169.0%
*-commutative69.0%
times-frac69.0%
associate--r+69.0%
div-sub69.0%
difference-of-squares70.3%
+-commutative70.3%
associate-*l/73.9%
*-commutative73.9%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 72.5%
unpow272.5%
associate-/l*78.5%
Simplified78.5%
if 5.4999999999999999e172 < x Initial program 73.2%
Taylor expanded in x around inf 90.4%
unpow290.4%
Simplified90.4%
associate-/l*93.3%
associate-/r/93.3%
Applied egg-rr93.3%
Final simplification80.1%
(FPCore (x y z) :precision binary64 (if (<= x 7e+53) (* y 0.5) (* x (/ x (* y 2.0)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 7e+53) {
tmp = y * 0.5;
} else {
tmp = x * (x / (y * 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 <= 7d+53) then
tmp = y * 0.5d0
else
tmp = x * (x / (y * 2.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 7e+53) {
tmp = y * 0.5;
} else {
tmp = x * (x / (y * 2.0));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 7e+53: tmp = y * 0.5 else: tmp = x * (x / (y * 2.0)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 7e+53) tmp = Float64(y * 0.5); else tmp = Float64(x * Float64(x / Float64(y * 2.0))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 7e+53) tmp = y * 0.5; else tmp = x * (x / (y * 2.0)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 7e+53], N[(y * 0.5), $MachinePrecision], N[(x * N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 7 \cdot 10^{+53}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{x}{y \cdot 2}\\
\end{array}
\end{array}
if x < 7.00000000000000038e53Initial program 69.5%
Taylor expanded in y around inf 41.2%
*-commutative41.2%
Simplified41.2%
if 7.00000000000000038e53 < x Initial program 69.2%
Taylor expanded in x around inf 63.5%
unpow263.5%
Simplified63.5%
associate-/l*66.7%
associate-/r/66.7%
Applied egg-rr66.7%
Final simplification46.5%
(FPCore (x y z) :precision binary64 (if (<= x 3.5e+53) (* y 0.5) (* 0.5 (/ x (/ y x)))))
double code(double x, double y, double z) {
double tmp;
if (x <= 3.5e+53) {
tmp = y * 0.5;
} else {
tmp = 0.5 * (x / (y / 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 <= 3.5d+53) then
tmp = y * 0.5d0
else
tmp = 0.5d0 * (x / (y / x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= 3.5e+53) {
tmp = y * 0.5;
} else {
tmp = 0.5 * (x / (y / x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= 3.5e+53: tmp = y * 0.5 else: tmp = 0.5 * (x / (y / x)) return tmp
function code(x, y, z) tmp = 0.0 if (x <= 3.5e+53) tmp = Float64(y * 0.5); else tmp = Float64(0.5 * Float64(x / Float64(y / x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= 3.5e+53) tmp = y * 0.5; else tmp = 0.5 * (x / (y / x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, 3.5e+53], N[(y * 0.5), $MachinePrecision], N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq 3.5 \cdot 10^{+53}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\
\end{array}
\end{array}
if x < 3.50000000000000019e53Initial program 69.5%
Taylor expanded in y around inf 41.2%
*-commutative41.2%
Simplified41.2%
if 3.50000000000000019e53 < x Initial program 69.2%
Taylor expanded in x around inf 63.5%
unpow263.5%
Simplified63.5%
Taylor expanded in x around 0 63.5%
*-commutative63.5%
unpow263.5%
associate-*l/66.7%
associate-/r/66.7%
Simplified66.7%
Final simplification46.5%
(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 69.4%
Taylor expanded in y around inf 36.6%
*-commutative36.6%
Simplified36.6%
Final simplification36.6%
(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 2023200
(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)))