
(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}
NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (* (- (* (+ x z) (/ (- z x) y)) y) -0.5))
z = abs(z);
double code(double x, double y, double z) {
return (((x + z) * ((z - x) / y)) - y) * -0.5;
}
NOTE: z should be positive before calling this function
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
z = Math.abs(z);
public static double code(double x, double y, double z) {
return (((x + z) * ((z - x) / y)) - y) * -0.5;
}
z = abs(z) def code(x, y, z): return (((x + z) * ((z - x) / y)) - y) * -0.5
z = abs(z) function code(x, y, z) return Float64(Float64(Float64(Float64(x + z) * Float64(Float64(z - x) / y)) - y) * -0.5) end
z = abs(z) function tmp = code(x, y, z) tmp = (((x + z) * ((z - x) / y)) - y) * -0.5; end
NOTE: z should be positive before calling this function 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}
z = |z|\\
\\
\left(\left(x + z\right) \cdot \frac{z - x}{y} - y\right) \cdot -0.5
\end{array}
Initial program 70.8%
sub-neg70.8%
+-commutative70.8%
neg-sub070.8%
associate-+l-70.8%
sub0-neg70.8%
neg-mul-170.8%
*-commutative70.8%
times-frac70.8%
associate--r+70.8%
div-sub70.8%
difference-of-squares76.0%
+-commutative76.0%
associate-*r/79.0%
associate-/l*99.6%
*-inverses99.6%
/-rgt-identity99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.6%
NOTE: z should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 0.5 (+ y (* x (/ x y))))))
(if (<= (* z z) 5e+110)
t_0
(if (<= (* z z) 1e+175)
(* -0.5 (* z (/ z y)))
(if (<= (* z z) 1e+234) t_0 (/ (* z -0.5) (/ y z)))))))z = abs(z);
double code(double x, double y, double z) {
double t_0 = 0.5 * (y + (x * (x / y)));
double tmp;
if ((z * z) <= 5e+110) {
tmp = t_0;
} else if ((z * z) <= 1e+175) {
tmp = -0.5 * (z * (z / y));
} else if ((z * z) <= 1e+234) {
tmp = t_0;
} else {
tmp = (z * -0.5) / (y / z);
}
return tmp;
}
NOTE: z should be positive before calling this function
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 * (y + (x * (x / y)))
if ((z * z) <= 5d+110) then
tmp = t_0
else if ((z * z) <= 1d+175) then
tmp = (-0.5d0) * (z * (z / y))
else if ((z * z) <= 1d+234) then
tmp = t_0
else
tmp = (z * (-0.5d0)) / (y / z)
end if
code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
double t_0 = 0.5 * (y + (x * (x / y)));
double tmp;
if ((z * z) <= 5e+110) {
tmp = t_0;
} else if ((z * z) <= 1e+175) {
tmp = -0.5 * (z * (z / y));
} else if ((z * z) <= 1e+234) {
tmp = t_0;
} else {
tmp = (z * -0.5) / (y / z);
}
return tmp;
}
z = abs(z) def code(x, y, z): t_0 = 0.5 * (y + (x * (x / y))) tmp = 0 if (z * z) <= 5e+110: tmp = t_0 elif (z * z) <= 1e+175: tmp = -0.5 * (z * (z / y)) elif (z * z) <= 1e+234: tmp = t_0 else: tmp = (z * -0.5) / (y / z) return tmp
z = abs(z) function code(x, y, z) t_0 = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))) tmp = 0.0 if (Float64(z * z) <= 5e+110) tmp = t_0; elseif (Float64(z * z) <= 1e+175) tmp = Float64(-0.5 * Float64(z * Float64(z / y))); elseif (Float64(z * z) <= 1e+234) tmp = t_0; else tmp = Float64(Float64(z * -0.5) / Float64(y / z)); end return tmp end
z = abs(z) function tmp_2 = code(x, y, z) t_0 = 0.5 * (y + (x * (x / y))); tmp = 0.0; if ((z * z) <= 5e+110) tmp = t_0; elseif ((z * z) <= 1e+175) tmp = -0.5 * (z * (z / y)); elseif ((z * z) <= 1e+234) tmp = t_0; else tmp = (z * -0.5) / (y / z); end tmp_2 = tmp; end
NOTE: z should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[N[(z * z), $MachinePrecision], 5e+110], t$95$0, If[LessEqual[N[(z * z), $MachinePrecision], 1e+175], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 1e+234], t$95$0, N[(N[(z * -0.5), $MachinePrecision] / N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{+110}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \cdot z \leq 10^{+175}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\mathbf{elif}\;z \cdot z \leq 10^{+234}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot -0.5}{\frac{y}{z}}\\
\end{array}
\end{array}
if (*.f64 z z) < 4.99999999999999978e110 or 9.9999999999999994e174 < (*.f64 z z) < 1.00000000000000002e234Initial program 74.4%
sub-neg74.4%
+-commutative74.4%
neg-sub074.4%
associate-+l-74.4%
sub0-neg74.4%
neg-mul-174.4%
*-commutative74.4%
times-frac74.4%
associate--r+74.4%
div-sub74.4%
difference-of-squares74.4%
+-commutative74.4%
associate-*l/78.0%
*-commutative78.0%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.8%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 80.5%
sub-neg80.5%
+-commutative80.5%
neg-mul-180.5%
distribute-lft-out80.5%
associate-*r*80.5%
metadata-eval80.5%
unpow280.5%
associate-*r/87.0%
Simplified87.0%
if 4.99999999999999978e110 < (*.f64 z z) < 9.9999999999999994e174Initial program 85.6%
sub-neg85.6%
+-commutative85.6%
neg-sub085.6%
associate-+l-85.6%
sub0-neg85.6%
neg-mul-185.6%
*-commutative85.6%
times-frac85.6%
associate--r+85.6%
div-sub85.6%
difference-of-squares85.6%
+-commutative85.6%
associate-*r/85.6%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 63.5%
unpow263.5%
associate-*l/63.5%
Simplified63.5%
if 1.00000000000000002e234 < (*.f64 z z) Initial program 60.1%
sub-neg60.1%
+-commutative60.1%
neg-sub060.1%
associate-+l-60.1%
sub0-neg60.1%
neg-mul-160.1%
*-commutative60.1%
times-frac60.1%
associate--r+60.1%
div-sub60.1%
difference-of-squares76.9%
+-commutative76.9%
associate-*r/79.5%
associate-/l*98.9%
*-inverses98.9%
/-rgt-identity98.9%
metadata-eval98.9%
Simplified98.9%
Taylor expanded in z around inf 75.3%
unpow275.3%
Simplified75.3%
associate-*l/78.7%
*-commutative78.7%
associate-*l/75.3%
associate-/l*78.8%
associate-*l/79.8%
Applied egg-rr79.8%
Final simplification83.0%
NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-274) (* 0.5 (* x (/ x y))) (if (<= (* z z) 1e+25) (* y 0.5) (* -0.5 (* z (/ z y))))))
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-274) {
tmp = 0.5 * (x * (x / y));
} else if ((z * z) <= 1e+25) {
tmp = y * 0.5;
} else {
tmp = -0.5 * (z * (z / y));
}
return tmp;
}
NOTE: z should be positive before calling this function
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) <= 5d-274) then
tmp = 0.5d0 * (x * (x / y))
else if ((z * z) <= 1d+25) then
tmp = y * 0.5d0
else
tmp = (-0.5d0) * (z * (z / y))
end if
code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-274) {
tmp = 0.5 * (x * (x / y));
} else if ((z * z) <= 1e+25) {
tmp = y * 0.5;
} else {
tmp = -0.5 * (z * (z / y));
}
return tmp;
}
z = abs(z) def code(x, y, z): tmp = 0 if (z * z) <= 5e-274: tmp = 0.5 * (x * (x / y)) elif (z * z) <= 1e+25: tmp = y * 0.5 else: tmp = -0.5 * (z * (z / y)) return tmp
z = abs(z) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-274) tmp = Float64(0.5 * Float64(x * Float64(x / y))); elseif (Float64(z * z) <= 1e+25) tmp = Float64(y * 0.5); else tmp = Float64(-0.5 * Float64(z * Float64(z / y))); end return tmp end
z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 5e-274) tmp = 0.5 * (x * (x / y)); elseif ((z * z) <= 1e+25) tmp = y * 0.5; else tmp = -0.5 * (z * (z / y)); end tmp_2 = tmp; end
NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-274], N[(0.5 * N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 1e+25], N[(y * 0.5), $MachinePrecision], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-274}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y}\right)\\
\mathbf{elif}\;z \cdot z \leq 10^{+25}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 5e-274Initial program 75.5%
sub-neg75.5%
+-commutative75.5%
neg-sub075.5%
associate-+l-75.5%
sub0-neg75.5%
neg-mul-175.5%
*-commutative75.5%
times-frac75.5%
associate--r+75.5%
div-sub75.5%
difference-of-squares75.5%
+-commutative75.5%
associate-*l/82.4%
*-commutative82.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.7%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 47.8%
*-commutative47.8%
unpow247.8%
associate-*r/54.6%
Simplified54.6%
if 5e-274 < (*.f64 z z) < 1.00000000000000009e25Initial 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-squares70.7%
+-commutative70.7%
associate-*r/70.8%
associate-/l*100.0%
*-inverses100.0%
/-rgt-identity100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 62.9%
*-commutative62.9%
Simplified62.9%
if 1.00000000000000009e25 < (*.f64 z z) Initial program 67.9%
sub-neg67.9%
+-commutative67.9%
neg-sub067.9%
associate-+l-67.9%
sub0-neg67.9%
neg-mul-167.9%
*-commutative67.9%
times-frac67.9%
associate--r+67.9%
div-sub67.9%
difference-of-squares78.1%
+-commutative78.1%
associate-*r/79.7%
associate-/l*99.3%
*-inverses99.3%
/-rgt-identity99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in z around inf 62.4%
unpow262.4%
associate-*l/64.5%
Simplified64.5%
Final simplification61.1%
NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= (* z z) 5e-274) (* 0.5 (* x (/ x y))) (if (<= (* z z) 1e+25) (* y 0.5) (/ (* z -0.5) (/ y z)))))
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-274) {
tmp = 0.5 * (x * (x / y));
} else if ((z * z) <= 1e+25) {
tmp = y * 0.5;
} else {
tmp = (z * -0.5) / (y / z);
}
return tmp;
}
NOTE: z should be positive before calling this function
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) <= 5d-274) then
tmp = 0.5d0 * (x * (x / y))
else if ((z * z) <= 1d+25) then
tmp = y * 0.5d0
else
tmp = (z * (-0.5d0)) / (y / z)
end if
code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 5e-274) {
tmp = 0.5 * (x * (x / y));
} else if ((z * z) <= 1e+25) {
tmp = y * 0.5;
} else {
tmp = (z * -0.5) / (y / z);
}
return tmp;
}
z = abs(z) def code(x, y, z): tmp = 0 if (z * z) <= 5e-274: tmp = 0.5 * (x * (x / y)) elif (z * z) <= 1e+25: tmp = y * 0.5 else: tmp = (z * -0.5) / (y / z) return tmp
z = abs(z) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 5e-274) tmp = Float64(0.5 * Float64(x * Float64(x / y))); elseif (Float64(z * z) <= 1e+25) tmp = Float64(y * 0.5); else tmp = Float64(Float64(z * -0.5) / Float64(y / z)); end return tmp end
z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 5e-274) tmp = 0.5 * (x * (x / y)); elseif ((z * z) <= 1e+25) tmp = y * 0.5; else tmp = (z * -0.5) / (y / z); end tmp_2 = tmp; end
NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 5e-274], N[(0.5 * N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[N[(z * z), $MachinePrecision], 1e+25], N[(y * 0.5), $MachinePrecision], N[(N[(z * -0.5), $MachinePrecision] / N[(y / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 5 \cdot 10^{-274}:\\
\;\;\;\;0.5 \cdot \left(x \cdot \frac{x}{y}\right)\\
\mathbf{elif}\;z \cdot z \leq 10^{+25}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{else}:\\
\;\;\;\;\frac{z \cdot -0.5}{\frac{y}{z}}\\
\end{array}
\end{array}
if (*.f64 z z) < 5e-274Initial program 75.5%
sub-neg75.5%
+-commutative75.5%
neg-sub075.5%
associate-+l-75.5%
sub0-neg75.5%
neg-mul-175.5%
*-commutative75.5%
times-frac75.5%
associate--r+75.5%
div-sub75.5%
difference-of-squares75.5%
+-commutative75.5%
associate-*l/82.4%
*-commutative82.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.7%
un-div-inv99.8%
Applied egg-rr99.8%
Taylor expanded in x around inf 47.8%
*-commutative47.8%
unpow247.8%
associate-*r/54.6%
Simplified54.6%
if 5e-274 < (*.f64 z z) < 1.00000000000000009e25Initial 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-squares70.7%
+-commutative70.7%
associate-*r/70.8%
associate-/l*100.0%
*-inverses100.0%
/-rgt-identity100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 62.9%
*-commutative62.9%
Simplified62.9%
if 1.00000000000000009e25 < (*.f64 z z) Initial program 67.9%
sub-neg67.9%
+-commutative67.9%
neg-sub067.9%
associate-+l-67.9%
sub0-neg67.9%
neg-mul-167.9%
*-commutative67.9%
times-frac67.9%
associate--r+67.9%
div-sub67.9%
difference-of-squares78.1%
+-commutative78.1%
associate-*r/79.7%
associate-/l*99.3%
*-inverses99.3%
/-rgt-identity99.3%
metadata-eval99.3%
Simplified99.3%
Taylor expanded in z around inf 62.4%
unpow262.4%
Simplified62.4%
associate-*l/64.5%
*-commutative64.5%
associate-*l/62.4%
associate-/l*64.5%
associate-*l/65.1%
Applied egg-rr65.1%
Final simplification61.4%
NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= (* x x) 5e+111) (* -0.5 (- (* z (/ z y)) y)) (* -0.5 (- (* (- z x) (/ x y)) y))))
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e+111) {
tmp = -0.5 * ((z * (z / y)) - y);
} else {
tmp = -0.5 * (((z - x) * (x / y)) - y);
}
return tmp;
}
NOTE: z should be positive before calling this function
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+111) then
tmp = (-0.5d0) * ((z * (z / y)) - y)
else
tmp = (-0.5d0) * (((z - x) * (x / y)) - y)
end if
code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 5e+111) {
tmp = -0.5 * ((z * (z / y)) - y);
} else {
tmp = -0.5 * (((z - x) * (x / y)) - y);
}
return tmp;
}
z = abs(z) def code(x, y, z): tmp = 0 if (x * x) <= 5e+111: tmp = -0.5 * ((z * (z / y)) - y) else: tmp = -0.5 * (((z - x) * (x / y)) - y) return tmp
z = abs(z) function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 5e+111) tmp = Float64(-0.5 * Float64(Float64(z * Float64(z / y)) - y)); else tmp = Float64(-0.5 * Float64(Float64(Float64(z - x) * Float64(x / y)) - y)); end return tmp end
z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 5e+111) tmp = -0.5 * ((z * (z / y)) - y); else tmp = -0.5 * (((z - x) * (x / y)) - y); end tmp_2 = tmp; end
NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 5e+111], N[(-0.5 * N[(N[(z * 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}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 5 \cdot 10^{+111}:\\
\;\;\;\;-0.5 \cdot \left(z \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) < 4.9999999999999997e111Initial program 74.3%
sub-neg74.3%
+-commutative74.3%
neg-sub074.3%
associate-+l-74.3%
sub0-neg74.3%
neg-mul-174.3%
*-commutative74.3%
times-frac74.3%
associate--r+74.3%
div-sub74.3%
difference-of-squares74.3%
+-commutative74.3%
associate-*r/76.9%
associate-/l*99.4%
*-inverses99.4%
/-rgt-identity99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 88.7%
unpow288.7%
associate-*l/93.7%
Simplified93.7%
if 4.9999999999999997e111 < (*.f64 x x) Initial program 65.7%
sub-neg65.7%
+-commutative65.7%
neg-sub065.7%
associate-+l-65.7%
sub0-neg65.7%
neg-mul-165.7%
*-commutative65.7%
times-frac65.7%
associate--r+65.7%
div-sub65.7%
difference-of-squares78.4%
+-commutative78.4%
associate-*l/82.0%
*-commutative82.0%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 87.3%
Final simplification91.1%
NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= (* x x) 1e+184) (* -0.5 (- (* z (/ z y)) y)) (* 0.5 (+ y (* x (/ x y))))))
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+184) {
tmp = -0.5 * ((z * (z / y)) - y);
} else {
tmp = 0.5 * (y + (x * (x / y)));
}
return tmp;
}
NOTE: z should be positive before calling this function
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+184) then
tmp = (-0.5d0) * ((z * (z / y)) - y)
else
tmp = 0.5d0 * (y + (x * (x / y)))
end if
code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if ((x * x) <= 1e+184) {
tmp = -0.5 * ((z * (z / y)) - y);
} else {
tmp = 0.5 * (y + (x * (x / y)));
}
return tmp;
}
z = abs(z) def code(x, y, z): tmp = 0 if (x * x) <= 1e+184: tmp = -0.5 * ((z * (z / y)) - y) else: tmp = 0.5 * (y + (x * (x / y))) return tmp
z = abs(z) function code(x, y, z) tmp = 0.0 if (Float64(x * x) <= 1e+184) tmp = Float64(-0.5 * Float64(Float64(z * Float64(z / y)) - y)); else tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))); end return tmp end
z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if ((x * x) <= 1e+184) tmp = -0.5 * ((z * (z / y)) - y); else tmp = 0.5 * (y + (x * (x / y))); end tmp_2 = tmp; end
NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[N[(x * x), $MachinePrecision], 1e+184], N[(-0.5 * N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] - y), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;x \cdot x \leq 10^{+184}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y} - y\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if (*.f64 x x) < 1.00000000000000002e184Initial program 75.3%
sub-neg75.3%
+-commutative75.3%
neg-sub075.3%
associate-+l-75.3%
sub0-neg75.3%
neg-mul-175.3%
*-commutative75.3%
times-frac75.3%
associate--r+75.3%
div-sub75.3%
difference-of-squares75.3%
+-commutative75.3%
associate-*r/77.7%
associate-/l*99.4%
*-inverses99.4%
/-rgt-identity99.4%
metadata-eval99.4%
Simplified99.4%
Taylor expanded in x around 0 87.9%
unpow287.9%
associate-*l/92.5%
Simplified92.5%
if 1.00000000000000002e184 < (*.f64 x x) Initial program 62.5%
sub-neg62.5%
+-commutative62.5%
neg-sub062.5%
associate-+l-62.5%
sub0-neg62.5%
neg-mul-162.5%
*-commutative62.5%
times-frac62.5%
associate--r+62.5%
div-sub62.5%
difference-of-squares77.3%
+-commutative77.3%
associate-*l/81.4%
*-commutative81.4%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
Taylor expanded in z around 0 70.4%
sub-neg70.4%
+-commutative70.4%
neg-mul-170.4%
distribute-lft-out70.4%
associate-*r*70.4%
metadata-eval70.4%
unpow270.4%
associate-*r/86.6%
Simplified86.6%
Final simplification90.4%
NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y -8.2e+79) (* y 0.5) (if (<= y 5.8e+44) (* -0.5 (* z (/ z y))) (* y 0.5))))
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+79) {
tmp = y * 0.5;
} else if (y <= 5.8e+44) {
tmp = -0.5 * (z * (z / y));
} else {
tmp = y * 0.5;
}
return tmp;
}
NOTE: z should be positive before calling this function
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 <= (-8.2d+79)) then
tmp = y * 0.5d0
else if (y <= 5.8d+44) then
tmp = (-0.5d0) * (z * (z / y))
else
tmp = y * 0.5d0
end if
code = tmp
end function
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+79) {
tmp = y * 0.5;
} else if (y <= 5.8e+44) {
tmp = -0.5 * (z * (z / y));
} else {
tmp = y * 0.5;
}
return tmp;
}
z = abs(z) def code(x, y, z): tmp = 0 if y <= -8.2e+79: tmp = y * 0.5 elif y <= 5.8e+44: tmp = -0.5 * (z * (z / y)) else: tmp = y * 0.5 return tmp
z = abs(z) function code(x, y, z) tmp = 0.0 if (y <= -8.2e+79) tmp = Float64(y * 0.5); elseif (y <= 5.8e+44) tmp = Float64(-0.5 * Float64(z * Float64(z / y))); else tmp = Float64(y * 0.5); end return tmp end
z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.2e+79) tmp = y * 0.5; elseif (y <= 5.8e+44) tmp = -0.5 * (z * (z / y)); else tmp = y * 0.5; end tmp_2 = tmp; end
NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, -8.2e+79], N[(y * 0.5), $MachinePrecision], If[LessEqual[y, 5.8e+44], N[(-0.5 * N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * 0.5), $MachinePrecision]]]
\begin{array}{l}
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+79}:\\
\;\;\;\;y \cdot 0.5\\
\mathbf{elif}\;y \leq 5.8 \cdot 10^{+44}:\\
\;\;\;\;-0.5 \cdot \left(z \cdot \frac{z}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;y \cdot 0.5\\
\end{array}
\end{array}
if y < -8.2e79 or 5.8000000000000004e44 < y Initial program 42.3%
sub-neg42.3%
+-commutative42.3%
neg-sub042.3%
associate-+l-42.3%
sub0-neg42.3%
neg-mul-142.3%
*-commutative42.3%
times-frac42.3%
associate--r+42.3%
div-sub42.3%
difference-of-squares44.4%
+-commutative44.4%
associate-*r/49.1%
associate-/l*99.2%
*-inverses99.2%
/-rgt-identity99.2%
metadata-eval99.2%
Simplified99.2%
Taylor expanded in y around inf 69.1%
*-commutative69.1%
Simplified69.1%
if -8.2e79 < y < 5.8000000000000004e44Initial program 90.7%
sub-neg90.7%
+-commutative90.7%
neg-sub090.7%
associate-+l-90.7%
sub0-neg90.7%
neg-mul-190.7%
*-commutative90.7%
times-frac90.7%
associate--r+90.7%
div-sub90.7%
difference-of-squares98.0%
+-commutative98.0%
associate-*r/99.8%
associate-/l*99.9%
*-inverses99.9%
/-rgt-identity99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around inf 54.0%
unpow254.0%
associate-*l/54.5%
Simplified54.5%
Final simplification60.5%
NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (* y 0.5))
z = abs(z);
double code(double x, double y, double z) {
return y * 0.5;
}
NOTE: z should be positive before calling this function
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
z = Math.abs(z);
public static double code(double x, double y, double z) {
return y * 0.5;
}
z = abs(z) def code(x, y, z): return y * 0.5
z = abs(z) function code(x, y, z) return Float64(y * 0.5) end
z = abs(z) function tmp = code(x, y, z) tmp = y * 0.5; end
NOTE: z should be positive before calling this function code[x_, y_, z_] := N[(y * 0.5), $MachinePrecision]
\begin{array}{l}
z = |z|\\
\\
y \cdot 0.5
\end{array}
Initial program 70.8%
sub-neg70.8%
+-commutative70.8%
neg-sub070.8%
associate-+l-70.8%
sub0-neg70.8%
neg-mul-170.8%
*-commutative70.8%
times-frac70.8%
associate--r+70.8%
div-sub70.8%
difference-of-squares76.0%
+-commutative76.0%
associate-*r/79.0%
associate-/l*99.6%
*-inverses99.6%
/-rgt-identity99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in y around inf 33.6%
*-commutative33.6%
Simplified33.6%
Final simplification33.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 2023199
(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)))