
(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}
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (* 0.5 (+ y (* (/ (+ z x) y) (- x z)))))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
return 0.5 * (y + (((z + x) / y) * (x - z)));
}
NOTE: x should be positive before calling this function
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 = 0.5d0 * (y + (((z + x) / y) * (x - z)))
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
return 0.5 * (y + (((z + x) / y) * (x - z)));
}
x = abs(x) z = abs(z) def code(x, y, z): return 0.5 * (y + (((z + x) / y) * (x - z)))
x = abs(x) z = abs(z) function code(x, y, z) return Float64(0.5 * Float64(y + Float64(Float64(Float64(z + x) / y) * Float64(x - z)))) end
x = abs(x) z = abs(z) function tmp = code(x, y, z) tmp = 0.5 * (y + (((z + x) / y) * (x - z))); end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := N[(0.5 * N[(y + N[(N[(N[(z + x), $MachinePrecision] / y), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
0.5 \cdot \left(y + \frac{z + x}{y} \cdot \left(x - z\right)\right)
\end{array}
Initial program 66.8%
Taylor expanded in y around 0 82.2%
distribute-lft-out82.2%
unpow282.2%
unpow282.2%
difference-of-squares87.8%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
associate-/r/99.9%
Applied egg-rr99.9%
Final simplification99.9%
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 0.5 (/ x (/ y x)))))
(if (<= y -1200000000000.0)
(* 0.5 y)
(if (<= y 3.2e-129)
t_0
(if (<= y 8e-93)
(* (* z (/ z y)) -0.5)
(if (<= y 1.8e+25) t_0 (* 0.5 y)))))))x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double t_0 = 0.5 * (x / (y / x));
double tmp;
if (y <= -1200000000000.0) {
tmp = 0.5 * y;
} else if (y <= 3.2e-129) {
tmp = t_0;
} else if (y <= 8e-93) {
tmp = (z * (z / y)) * -0.5;
} else if (y <= 1.8e+25) {
tmp = t_0;
} else {
tmp = 0.5 * y;
}
return tmp;
}
NOTE: x should be positive before calling this function
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 * (x / (y / x))
if (y <= (-1200000000000.0d0)) then
tmp = 0.5d0 * y
else if (y <= 3.2d-129) then
tmp = t_0
else if (y <= 8d-93) then
tmp = (z * (z / y)) * (-0.5d0)
else if (y <= 1.8d+25) then
tmp = t_0
else
tmp = 0.5d0 * y
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double t_0 = 0.5 * (x / (y / x));
double tmp;
if (y <= -1200000000000.0) {
tmp = 0.5 * y;
} else if (y <= 3.2e-129) {
tmp = t_0;
} else if (y <= 8e-93) {
tmp = (z * (z / y)) * -0.5;
} else if (y <= 1.8e+25) {
tmp = t_0;
} else {
tmp = 0.5 * y;
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): t_0 = 0.5 * (x / (y / x)) tmp = 0 if y <= -1200000000000.0: tmp = 0.5 * y elif y <= 3.2e-129: tmp = t_0 elif y <= 8e-93: tmp = (z * (z / y)) * -0.5 elif y <= 1.8e+25: tmp = t_0 else: tmp = 0.5 * y return tmp
x = abs(x) z = abs(z) function code(x, y, z) t_0 = Float64(0.5 * Float64(x / Float64(y / x))) tmp = 0.0 if (y <= -1200000000000.0) tmp = Float64(0.5 * y); elseif (y <= 3.2e-129) tmp = t_0; elseif (y <= 8e-93) tmp = Float64(Float64(z * Float64(z / y)) * -0.5); elseif (y <= 1.8e+25) tmp = t_0; else tmp = Float64(0.5 * y); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) t_0 = 0.5 * (x / (y / x)); tmp = 0.0; if (y <= -1200000000000.0) tmp = 0.5 * y; elseif (y <= 3.2e-129) tmp = t_0; elseif (y <= 8e-93) tmp = (z * (z / y)) * -0.5; elseif (y <= 1.8e+25) tmp = t_0; else tmp = 0.5 * y; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
code[x_, y_, z_] := Block[{t$95$0 = N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1200000000000.0], N[(0.5 * y), $MachinePrecision], If[LessEqual[y, 3.2e-129], t$95$0, If[LessEqual[y, 8e-93], N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[y, 1.8e+25], t$95$0, N[(0.5 * y), $MachinePrecision]]]]]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
t_0 := 0.5 \cdot \frac{x}{\frac{y}{x}}\\
\mathbf{if}\;y \leq -1200000000000:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{-129}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-93}:\\
\;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\
\mathbf{elif}\;y \leq 1.8 \cdot 10^{+25}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < -1.2e12 or 1.80000000000000008e25 < y Initial program 45.5%
Taylor expanded in y around inf 68.8%
if -1.2e12 < y < 3.2000000000000003e-129 or 7.9999999999999992e-93 < y < 1.80000000000000008e25Initial program 89.7%
Taylor expanded in x around inf 54.6%
unpow254.6%
associate-/l*56.2%
Simplified56.2%
if 3.2000000000000003e-129 < y < 7.9999999999999992e-93Initial program 99.4%
Taylor expanded in z around inf 83.2%
*-commutative83.2%
unpow283.2%
Simplified83.2%
Taylor expanded in z around 0 83.2%
unpow283.2%
associate-*r/83.2%
Simplified83.2%
Final simplification63.3%
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
(FPCore (x y z)
:precision binary64
(if (<= y -175000000000.0)
(* 0.5 y)
(if (<= y 9e-130)
(* x (/ x (* y 2.0)))
(if (<= y 9e-98)
(* (* z (/ z y)) -0.5)
(if (<= y 1.85e+25) (* 0.5 (/ x (/ y x))) (* 0.5 y))))))x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if (y <= -175000000000.0) {
tmp = 0.5 * y;
} else if (y <= 9e-130) {
tmp = x * (x / (y * 2.0));
} else if (y <= 9e-98) {
tmp = (z * (z / y)) * -0.5;
} else if (y <= 1.85e+25) {
tmp = 0.5 * (x / (y / x));
} else {
tmp = 0.5 * y;
}
return tmp;
}
NOTE: x should be positive before calling this function
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 <= (-175000000000.0d0)) then
tmp = 0.5d0 * y
else if (y <= 9d-130) then
tmp = x * (x / (y * 2.0d0))
else if (y <= 9d-98) then
tmp = (z * (z / y)) * (-0.5d0)
else if (y <= 1.85d+25) then
tmp = 0.5d0 * (x / (y / x))
else
tmp = 0.5d0 * y
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if (y <= -175000000000.0) {
tmp = 0.5 * y;
} else if (y <= 9e-130) {
tmp = x * (x / (y * 2.0));
} else if (y <= 9e-98) {
tmp = (z * (z / y)) * -0.5;
} else if (y <= 1.85e+25) {
tmp = 0.5 * (x / (y / x));
} else {
tmp = 0.5 * y;
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if y <= -175000000000.0: tmp = 0.5 * y elif y <= 9e-130: tmp = x * (x / (y * 2.0)) elif y <= 9e-98: tmp = (z * (z / y)) * -0.5 elif y <= 1.85e+25: tmp = 0.5 * (x / (y / x)) else: tmp = 0.5 * y return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (y <= -175000000000.0) tmp = Float64(0.5 * y); elseif (y <= 9e-130) tmp = Float64(x * Float64(x / Float64(y * 2.0))); elseif (y <= 9e-98) tmp = Float64(Float64(z * Float64(z / y)) * -0.5); elseif (y <= 1.85e+25) tmp = Float64(0.5 * Float64(x / Float64(y / x))); else tmp = Float64(0.5 * y); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -175000000000.0) tmp = 0.5 * y; elseif (y <= 9e-130) tmp = x * (x / (y * 2.0)); elseif (y <= 9e-98) tmp = (z * (z / y)) * -0.5; elseif (y <= 1.85e+25) tmp = 0.5 * (x / (y / x)); else tmp = 0.5 * y; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, -175000000000.0], N[(0.5 * y), $MachinePrecision], If[LessEqual[y, 9e-130], N[(x * N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 9e-98], N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision], If[LessEqual[y, 1.85e+25], N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -175000000000:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-130}:\\
\;\;\;\;x \cdot \frac{x}{y \cdot 2}\\
\mathbf{elif}\;y \leq 9 \cdot 10^{-98}:\\
\;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\
\mathbf{elif}\;y \leq 1.85 \cdot 10^{+25}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < -1.75e11 or 1.8499999999999999e25 < y Initial program 45.5%
Taylor expanded in y around inf 68.8%
if -1.75e11 < y < 9e-130Initial program 88.9%
Taylor expanded in x around inf 52.7%
unpow252.7%
Simplified52.7%
associate-/l*54.6%
associate-/r/54.6%
Applied egg-rr54.6%
if 9e-130 < y < 8.99999999999999994e-98Initial program 99.4%
Taylor expanded in z around inf 83.2%
*-commutative83.2%
unpow283.2%
Simplified83.2%
Taylor expanded in z around 0 83.2%
unpow283.2%
associate-*r/83.2%
Simplified83.2%
if 8.99999999999999994e-98 < y < 1.8499999999999999e25Initial program 94.4%
Taylor expanded in x around inf 64.9%
unpow264.9%
associate-/l*64.9%
Simplified64.9%
Final simplification63.3%
NOTE: x should be positive before calling this function
NOTE: z should be positive before calling this function
(FPCore (x y z)
:precision binary64
(if (<= y -56000000000000.0)
(* 0.5 y)
(if (<= y 1.7e-128)
(* x (/ x (* y 2.0)))
(if (<= y 1.15e-95)
(* -0.5 (/ z (/ y z)))
(if (<= y 1.65e+25) (* 0.5 (/ x (/ y x))) (* 0.5 y))))))x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if (y <= -56000000000000.0) {
tmp = 0.5 * y;
} else if (y <= 1.7e-128) {
tmp = x * (x / (y * 2.0));
} else if (y <= 1.15e-95) {
tmp = -0.5 * (z / (y / z));
} else if (y <= 1.65e+25) {
tmp = 0.5 * (x / (y / x));
} else {
tmp = 0.5 * y;
}
return tmp;
}
NOTE: x should be positive before calling this function
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 <= (-56000000000000.0d0)) then
tmp = 0.5d0 * y
else if (y <= 1.7d-128) then
tmp = x * (x / (y * 2.0d0))
else if (y <= 1.15d-95) then
tmp = (-0.5d0) * (z / (y / z))
else if (y <= 1.65d+25) then
tmp = 0.5d0 * (x / (y / x))
else
tmp = 0.5d0 * y
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if (y <= -56000000000000.0) {
tmp = 0.5 * y;
} else if (y <= 1.7e-128) {
tmp = x * (x / (y * 2.0));
} else if (y <= 1.15e-95) {
tmp = -0.5 * (z / (y / z));
} else if (y <= 1.65e+25) {
tmp = 0.5 * (x / (y / x));
} else {
tmp = 0.5 * y;
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if y <= -56000000000000.0: tmp = 0.5 * y elif y <= 1.7e-128: tmp = x * (x / (y * 2.0)) elif y <= 1.15e-95: tmp = -0.5 * (z / (y / z)) elif y <= 1.65e+25: tmp = 0.5 * (x / (y / x)) else: tmp = 0.5 * y return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (y <= -56000000000000.0) tmp = Float64(0.5 * y); elseif (y <= 1.7e-128) tmp = Float64(x * Float64(x / Float64(y * 2.0))); elseif (y <= 1.15e-95) tmp = Float64(-0.5 * Float64(z / Float64(y / z))); elseif (y <= 1.65e+25) tmp = Float64(0.5 * Float64(x / Float64(y / x))); else tmp = Float64(0.5 * y); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -56000000000000.0) tmp = 0.5 * y; elseif (y <= 1.7e-128) tmp = x * (x / (y * 2.0)); elseif (y <= 1.15e-95) tmp = -0.5 * (z / (y / z)); elseif (y <= 1.65e+25) tmp = 0.5 * (x / (y / x)); else tmp = 0.5 * y; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, -56000000000000.0], N[(0.5 * y), $MachinePrecision], If[LessEqual[y, 1.7e-128], N[(x * N[(x / N[(y * 2.0), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.15e-95], N[(-0.5 * N[(z / N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.65e+25], N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -56000000000000:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;y \leq 1.7 \cdot 10^{-128}:\\
\;\;\;\;x \cdot \frac{x}{y \cdot 2}\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{-95}:\\
\;\;\;\;-0.5 \cdot \frac{z}{\frac{y}{z}}\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{+25}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < -5.6e13 or 1.6500000000000001e25 < y Initial program 45.5%
Taylor expanded in y around inf 68.8%
if -5.6e13 < y < 1.69999999999999987e-128Initial program 88.9%
Taylor expanded in x around inf 52.7%
unpow252.7%
Simplified52.7%
associate-/l*54.6%
associate-/r/54.6%
Applied egg-rr54.6%
if 1.69999999999999987e-128 < y < 1.15e-95Initial program 99.4%
Taylor expanded in z around inf 83.2%
*-commutative83.2%
unpow283.2%
associate-/l*83.5%
Simplified83.5%
if 1.15e-95 < y < 1.6500000000000001e25Initial program 94.4%
Taylor expanded in x around inf 64.9%
unpow264.9%
associate-/l*64.9%
Simplified64.9%
Final simplification63.3%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e+196) (* 0.5 (+ y (* x (/ x y)))) (* 0.5 (* (/ (+ y z) y) (- y z)))))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+196) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = 0.5 * (((y + z) / y) * (y - z));
}
return tmp;
}
NOTE: x should be positive before calling this function
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) <= 2d+196) then
tmp = 0.5d0 * (y + (x * (x / y)))
else
tmp = 0.5d0 * (((y + z) / y) * (y - z))
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+196) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = 0.5 * (((y + z) / y) * (y - z));
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if (z * z) <= 2e+196: tmp = 0.5 * (y + (x * (x / y))) else: tmp = 0.5 * (((y + z) / y) * (y - z)) return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+196) tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))); else tmp = Float64(0.5 * Float64(Float64(Float64(y + z) / y) * Float64(y - z))); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 2e+196) tmp = 0.5 * (y + (x * (x / y))); else tmp = 0.5 * (((y + z) / y) * (y - z)); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+196], N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(N[(N[(y + z), $MachinePrecision] / y), $MachinePrecision] * N[(y - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+196}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(\frac{y + z}{y} \cdot \left(y - z\right)\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1.9999999999999999e196Initial program 73.3%
Taylor expanded in y around 0 91.6%
distribute-lft-out91.6%
unpow291.6%
unpow291.6%
difference-of-squares91.6%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 81.0%
unpow281.0%
associate-/l*88.7%
Simplified88.7%
associate-/r/88.7%
Applied egg-rr88.7%
if 1.9999999999999999e196 < (*.f64 z z) Initial program 51.5%
Taylor expanded in x around 0 59.3%
unpow259.3%
unpow259.3%
difference-of-squares62.1%
associate-/l*88.3%
associate-/r/88.3%
Simplified88.3%
Final simplification88.6%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= (* z z) 2e+196) (* 0.5 (+ y (* x (/ x y)))) (* 0.5 (- y (* z (/ z y))))))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+196) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
NOTE: x should be positive before calling this function
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) <= 2d+196) then
tmp = 0.5d0 * (y + (x * (x / y)))
else
tmp = 0.5d0 * (y - (z * (z / y)))
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if ((z * z) <= 2e+196) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = 0.5 * (y - (z * (z / y)));
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if (z * z) <= 2e+196: tmp = 0.5 * (y + (x * (x / y))) else: tmp = 0.5 * (y - (z * (z / y))) return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (Float64(z * z) <= 2e+196) tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))); else tmp = Float64(0.5 * Float64(y - Float64(z * Float64(z / y)))); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if ((z * z) <= 2e+196) tmp = 0.5 * (y + (x * (x / y))); else tmp = 0.5 * (y - (z * (z / y))); end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[N[(z * z), $MachinePrecision], 2e+196], N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * N[(y - N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;z \cdot z \leq 2 \cdot 10^{+196}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot \left(y - z \cdot \frac{z}{y}\right)\\
\end{array}
\end{array}
if (*.f64 z z) < 1.9999999999999999e196Initial program 73.3%
Taylor expanded in y around 0 91.6%
distribute-lft-out91.6%
unpow291.6%
unpow291.6%
difference-of-squares91.6%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 81.0%
unpow281.0%
associate-/l*88.7%
Simplified88.7%
associate-/r/88.7%
Applied egg-rr88.7%
if 1.9999999999999999e196 < (*.f64 z z) Initial program 51.5%
Taylor expanded in y around 0 60.3%
distribute-lft-out60.3%
unpow260.3%
unpow260.3%
difference-of-squares78.8%
associate-/l*100.0%
+-commutative100.0%
Simplified100.0%
Taylor expanded in x around 0 70.6%
mul-1-neg70.6%
sub-neg70.6%
unpow270.6%
associate-*r/88.3%
Simplified88.3%
Final simplification88.6%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= y -30000000000000.0) (* 0.5 y) (if (<= y 4.8e+24) (* 0.5 (/ x (/ y x))) (* 0.5 y))))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if (y <= -30000000000000.0) {
tmp = 0.5 * y;
} else if (y <= 4.8e+24) {
tmp = 0.5 * (x / (y / x));
} else {
tmp = 0.5 * y;
}
return tmp;
}
NOTE: x should be positive before calling this function
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 <= (-30000000000000.0d0)) then
tmp = 0.5d0 * y
else if (y <= 4.8d+24) then
tmp = 0.5d0 * (x / (y / x))
else
tmp = 0.5d0 * y
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if (y <= -30000000000000.0) {
tmp = 0.5 * y;
} else if (y <= 4.8e+24) {
tmp = 0.5 * (x / (y / x));
} else {
tmp = 0.5 * y;
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if y <= -30000000000000.0: tmp = 0.5 * y elif y <= 4.8e+24: tmp = 0.5 * (x / (y / x)) else: tmp = 0.5 * y return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (y <= -30000000000000.0) tmp = Float64(0.5 * y); elseif (y <= 4.8e+24) tmp = Float64(0.5 * Float64(x / Float64(y / x))); else tmp = Float64(0.5 * y); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -30000000000000.0) tmp = 0.5 * y; elseif (y <= 4.8e+24) tmp = 0.5 * (x / (y / x)); else tmp = 0.5 * y; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[y, -30000000000000.0], N[(0.5 * y), $MachinePrecision], If[LessEqual[y, 4.8e+24], N[(0.5 * N[(x / N[(y / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(0.5 * y), $MachinePrecision]]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;y \leq -30000000000000:\\
\;\;\;\;0.5 \cdot y\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+24}:\\
\;\;\;\;0.5 \cdot \frac{x}{\frac{y}{x}}\\
\mathbf{else}:\\
\;\;\;\;0.5 \cdot y\\
\end{array}
\end{array}
if y < -3e13 or 4.8000000000000001e24 < y Initial program 45.5%
Taylor expanded in y around inf 68.8%
if -3e13 < y < 4.8000000000000001e24Initial program 90.1%
Taylor expanded in x around inf 52.4%
unpow252.4%
associate-/l*54.0%
Simplified54.0%
Final simplification61.7%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (if (<= z 2.4e+194) (* 0.5 (+ y (* x (/ x y)))) (* (* z (/ z y)) -0.5)))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
double tmp;
if (z <= 2.4e+194) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = (z * (z / y)) * -0.5;
}
return tmp;
}
NOTE: x should be positive before calling this function
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 <= 2.4d+194) then
tmp = 0.5d0 * (y + (x * (x / y)))
else
tmp = (z * (z / y)) * (-0.5d0)
end if
code = tmp
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
double tmp;
if (z <= 2.4e+194) {
tmp = 0.5 * (y + (x * (x / y)));
} else {
tmp = (z * (z / y)) * -0.5;
}
return tmp;
}
x = abs(x) z = abs(z) def code(x, y, z): tmp = 0 if z <= 2.4e+194: tmp = 0.5 * (y + (x * (x / y))) else: tmp = (z * (z / y)) * -0.5 return tmp
x = abs(x) z = abs(z) function code(x, y, z) tmp = 0.0 if (z <= 2.4e+194) tmp = Float64(0.5 * Float64(y + Float64(x * Float64(x / y)))); else tmp = Float64(Float64(z * Float64(z / y)) * -0.5); end return tmp end
x = abs(x) z = abs(z) function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= 2.4e+194) tmp = 0.5 * (y + (x * (x / y))); else tmp = (z * (z / y)) * -0.5; end tmp_2 = tmp; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := If[LessEqual[z, 2.4e+194], N[(0.5 * N[(y + N[(x * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(z * N[(z / y), $MachinePrecision]), $MachinePrecision] * -0.5), $MachinePrecision]]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
\begin{array}{l}
\mathbf{if}\;z \leq 2.4 \cdot 10^{+194}:\\
\;\;\;\;0.5 \cdot \left(y + x \cdot \frac{x}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(z \cdot \frac{z}{y}\right) \cdot -0.5\\
\end{array}
\end{array}
if z < 2.4e194Initial program 68.1%
Taylor expanded in y around 0 85.0%
distribute-lft-out85.0%
unpow285.0%
unpow285.0%
difference-of-squares88.5%
associate-/l*99.9%
+-commutative99.9%
Simplified99.9%
Taylor expanded in z around 0 71.3%
unpow271.3%
associate-/l*78.6%
Simplified78.6%
associate-/r/78.6%
Applied egg-rr78.6%
if 2.4e194 < z Initial program 54.2%
Taylor expanded in z around inf 76.2%
*-commutative76.2%
unpow276.2%
Simplified76.2%
Taylor expanded in z around 0 76.2%
unpow276.2%
associate-*r/84.3%
Simplified84.3%
Final simplification79.1%
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function (FPCore (x y z) :precision binary64 (* 0.5 y))
x = abs(x);
z = abs(z);
double code(double x, double y, double z) {
return 0.5 * y;
}
NOTE: x should be positive before calling this function
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 = 0.5d0 * y
end function
x = Math.abs(x);
z = Math.abs(z);
public static double code(double x, double y, double z) {
return 0.5 * y;
}
x = abs(x) z = abs(z) def code(x, y, z): return 0.5 * y
x = abs(x) z = abs(z) function code(x, y, z) return Float64(0.5 * y) end
x = abs(x) z = abs(z) function tmp = code(x, y, z) tmp = 0.5 * y; end
NOTE: x should be positive before calling this function NOTE: z should be positive before calling this function code[x_, y_, z_] := N[(0.5 * y), $MachinePrecision]
\begin{array}{l}
x = |x|\\
z = |z|\\
\\
0.5 \cdot y
\end{array}
Initial program 66.8%
Taylor expanded in y around inf 39.4%
Final simplification39.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 2023290
(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)))