
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + (y * (z - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 13 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (+ x (* y (- z x))) z))
double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (x + (y * (z - x))) / z
end function
public static double code(double x, double y, double z) {
return (x + (y * (z - x))) / z;
}
def code(x, y, z): return (x + (y * (z - x))) / z
function code(x, y, z) return Float64(Float64(x + Float64(y * Float64(z - x))) / z) end
function tmp = code(x, y, z) tmp = (x + (y * (z - x))) / z; end
code[x_, y_, z_] := N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{x + y \cdot \left(z - x\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (if (<= y -2e-209) (+ (/ x z) (* y (- 1.0 (/ x z)))) (if (<= y 840000000000.0) (/ (+ x (* y (- z x))) z) (/ y (/ z (- z x))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e-209) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else if (y <= 840000000000.0) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y / (z / (z - 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 (y <= (-2d-209)) then
tmp = (x / z) + (y * (1.0d0 - (x / z)))
else if (y <= 840000000000.0d0) then
tmp = (x + (y * (z - x))) / z
else
tmp = y / (z / (z - x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2e-209) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else if (y <= 840000000000.0) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y / (z / (z - x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e-209: tmp = (x / z) + (y * (1.0 - (x / z))) elif y <= 840000000000.0: tmp = (x + (y * (z - x))) / z else: tmp = y / (z / (z - x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e-209) tmp = Float64(Float64(x / z) + Float64(y * Float64(1.0 - Float64(x / z)))); elseif (y <= 840000000000.0) tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); else tmp = Float64(y / Float64(z / Float64(z - x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e-209) tmp = (x / z) + (y * (1.0 - (x / z))); elseif (y <= 840000000000.0) tmp = (x + (y * (z - x))) / z; else tmp = y / (z / (z - x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e-209], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 840000000000.0], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-209}:\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{elif}\;y \leq 840000000000:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\end{array}
\end{array}
if y < -2.0000000000000001e-209Initial program 85.9%
Taylor expanded in y around 0 100.0%
if -2.0000000000000001e-209 < y < 8.4e11Initial program 99.9%
if 8.4e11 < y Initial program 74.3%
Taylor expanded in y around inf 74.3%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(if (<= y -6.5e+155)
y
(if (<= y -1.9e+79)
(/ x z)
(if (<= y -1.85e-13) y (if (<= y 0.00058) (/ x z) (* z (/ y z)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e+155) {
tmp = y;
} else if (y <= -1.9e+79) {
tmp = x / z;
} else if (y <= -1.85e-13) {
tmp = y;
} else if (y <= 0.00058) {
tmp = x / z;
} else {
tmp = z * (y / z);
}
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 (y <= (-6.5d+155)) then
tmp = y
else if (y <= (-1.9d+79)) then
tmp = x / z
else if (y <= (-1.85d-13)) then
tmp = y
else if (y <= 0.00058d0) then
tmp = x / z
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e+155) {
tmp = y;
} else if (y <= -1.9e+79) {
tmp = x / z;
} else if (y <= -1.85e-13) {
tmp = y;
} else if (y <= 0.00058) {
tmp = x / z;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.5e+155: tmp = y elif y <= -1.9e+79: tmp = x / z elif y <= -1.85e-13: tmp = y elif y <= 0.00058: tmp = x / z else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.5e+155) tmp = y; elseif (y <= -1.9e+79) tmp = Float64(x / z); elseif (y <= -1.85e-13) tmp = y; elseif (y <= 0.00058) tmp = Float64(x / z); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.5e+155) tmp = y; elseif (y <= -1.9e+79) tmp = x / z; elseif (y <= -1.85e-13) tmp = y; elseif (y <= 0.00058) tmp = x / z; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.5e+155], y, If[LessEqual[y, -1.9e+79], N[(x / z), $MachinePrecision], If[LessEqual[y, -1.85e-13], y, If[LessEqual[y, 0.00058], N[(x / z), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+155}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq -1.9 \cdot 10^{+79}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq -1.85 \cdot 10^{-13}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 0.00058:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -6.50000000000000046e155 or -1.9000000000000001e79 < y < -1.84999999999999994e-13Initial program 65.9%
Taylor expanded in x around 0 75.7%
if -6.50000000000000046e155 < y < -1.9000000000000001e79 or -1.84999999999999994e-13 < y < 5.8e-4Initial program 99.9%
Taylor expanded in y around 0 76.7%
if 5.8e-4 < y Initial program 75.6%
Taylor expanded in x around 0 28.2%
associate-/l*44.4%
associate-/r/49.2%
Applied egg-rr49.2%
Final simplification70.4%
(FPCore (x y z) :precision binary64 (if (<= y -3.4e+19) (* y (- 1.0 (/ x z))) (if (<= y 840000000000.0) (/ (+ x (* y (- z x))) z) (/ y (/ z (- z x))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e+19) {
tmp = y * (1.0 - (x / z));
} else if (y <= 840000000000.0) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y / (z / (z - 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 (y <= (-3.4d+19)) then
tmp = y * (1.0d0 - (x / z))
else if (y <= 840000000000.0d0) then
tmp = (x + (y * (z - x))) / z
else
tmp = y / (z / (z - x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.4e+19) {
tmp = y * (1.0 - (x / z));
} else if (y <= 840000000000.0) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y / (z / (z - x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.4e+19: tmp = y * (1.0 - (x / z)) elif y <= 840000000000.0: tmp = (x + (y * (z - x))) / z else: tmp = y / (z / (z - x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.4e+19) tmp = Float64(y * Float64(1.0 - Float64(x / z))); elseif (y <= 840000000000.0) tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); else tmp = Float64(y / Float64(z / Float64(z - x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.4e+19) tmp = y * (1.0 - (x / z)); elseif (y <= 840000000000.0) tmp = (x + (y * (z - x))) / z; else tmp = y / (z / (z - x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.4e+19], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 840000000000.0], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{+19}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{elif}\;y \leq 840000000000:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\end{array}
\end{array}
if y < -3.4e19Initial program 68.7%
Taylor expanded in y around 0 99.9%
Taylor expanded in y around inf 99.9%
if -3.4e19 < y < 8.4e11Initial program 99.9%
if 8.4e11 < y Initial program 74.3%
Taylor expanded in y around inf 74.3%
associate-/l*99.9%
Simplified99.9%
Final simplification99.9%
(FPCore (x y z) :precision binary64 (if (<= y -1e-309) (+ (/ x z) (* y (- 1.0 (/ x z)))) (+ y (* x (- (/ 1.0 z) (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1e-309) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else {
tmp = y + (x * ((1.0 / z) - (y / z)));
}
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 (y <= (-1d-309)) then
tmp = (x / z) + (y * (1.0d0 - (x / z)))
else
tmp = y + (x * ((1.0d0 / z) - (y / z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1e-309) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else {
tmp = y + (x * ((1.0 / z) - (y / z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1e-309: tmp = (x / z) + (y * (1.0 - (x / z))) else: tmp = y + (x * ((1.0 / z) - (y / z))) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1e-309) tmp = Float64(Float64(x / z) + Float64(y * Float64(1.0 - Float64(x / z)))); else tmp = Float64(y + Float64(x * Float64(Float64(1.0 / z) - Float64(y / z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1e-309) tmp = (x / z) + (y * (1.0 - (x / z))); else tmp = y + (x * ((1.0 / z) - (y / z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1e-309], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x * N[(N[(1.0 / z), $MachinePrecision] - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1 \cdot 10^{-309}:\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + x \cdot \left(\frac{1}{z} - \frac{y}{z}\right)\\
\end{array}
\end{array}
if y < -1.000000000000002e-309Initial program 88.6%
Taylor expanded in y around 0 100.0%
if -1.000000000000002e-309 < y Initial program 88.7%
Taylor expanded in x around 0 98.2%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.2e+156) (and (not (<= y -3.8e+87)) (<= y 1.65e+122))) (+ y (/ x z)) (* y (/ (- x) z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.2e+156) || (!(y <= -3.8e+87) && (y <= 1.65e+122))) {
tmp = y + (x / z);
} else {
tmp = y * (-x / z);
}
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 ((y <= (-6.2d+156)) .or. (.not. (y <= (-3.8d+87))) .and. (y <= 1.65d+122)) then
tmp = y + (x / z)
else
tmp = y * (-x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.2e+156) || (!(y <= -3.8e+87) && (y <= 1.65e+122))) {
tmp = y + (x / z);
} else {
tmp = y * (-x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.2e+156) or (not (y <= -3.8e+87) and (y <= 1.65e+122)): tmp = y + (x / z) else: tmp = y * (-x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.2e+156) || (!(y <= -3.8e+87) && (y <= 1.65e+122))) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y * Float64(Float64(-x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.2e+156) || (~((y <= -3.8e+87)) && (y <= 1.65e+122))) tmp = y + (x / z); else tmp = y * (-x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.2e+156], And[N[Not[LessEqual[y, -3.8e+87]], $MachinePrecision], LessEqual[y, 1.65e+122]]], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.2 \cdot 10^{+156} \lor \neg \left(y \leq -3.8 \cdot 10^{+87}\right) \land y \leq 1.65 \cdot 10^{+122}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\end{array}
\end{array}
if y < -6.2000000000000004e156 or -3.80000000000000011e87 < y < 1.6499999999999999e122Initial program 91.8%
Taylor expanded in x around 0 98.3%
Taylor expanded in y around 0 91.1%
if -6.2000000000000004e156 < y < -3.80000000000000011e87 or 1.6499999999999999e122 < y Initial program 75.6%
Taylor expanded in y around inf 75.6%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around 0 68.9%
neg-mul-168.9%
distribute-neg-frac68.9%
Simplified68.9%
Taylor expanded in y around 0 61.4%
mul-1-neg61.4%
associate-*r/68.9%
distribute-rgt-neg-in68.9%
distribute-frac-neg68.9%
Simplified68.9%
Final simplification86.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ y (/ x z))))
(if (<= y -2.1e+157)
t_0
(if (<= y -1.95e+89)
(* y (/ (- x) z))
(if (<= y 1.12e+121) t_0 (/ y (/ (- z) x)))))))
double code(double x, double y, double z) {
double t_0 = y + (x / z);
double tmp;
if (y <= -2.1e+157) {
tmp = t_0;
} else if (y <= -1.95e+89) {
tmp = y * (-x / z);
} else if (y <= 1.12e+121) {
tmp = t_0;
} else {
tmp = y / (-z / 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) :: t_0
real(8) :: tmp
t_0 = y + (x / z)
if (y <= (-2.1d+157)) then
tmp = t_0
else if (y <= (-1.95d+89)) then
tmp = y * (-x / z)
else if (y <= 1.12d+121) then
tmp = t_0
else
tmp = y / (-z / x)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y + (x / z);
double tmp;
if (y <= -2.1e+157) {
tmp = t_0;
} else if (y <= -1.95e+89) {
tmp = y * (-x / z);
} else if (y <= 1.12e+121) {
tmp = t_0;
} else {
tmp = y / (-z / x);
}
return tmp;
}
def code(x, y, z): t_0 = y + (x / z) tmp = 0 if y <= -2.1e+157: tmp = t_0 elif y <= -1.95e+89: tmp = y * (-x / z) elif y <= 1.12e+121: tmp = t_0 else: tmp = y / (-z / x) return tmp
function code(x, y, z) t_0 = Float64(y + Float64(x / z)) tmp = 0.0 if (y <= -2.1e+157) tmp = t_0; elseif (y <= -1.95e+89) tmp = Float64(y * Float64(Float64(-x) / z)); elseif (y <= 1.12e+121) tmp = t_0; else tmp = Float64(y / Float64(Float64(-z) / x)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = y + (x / z); tmp = 0.0; if (y <= -2.1e+157) tmp = t_0; elseif (y <= -1.95e+89) tmp = y * (-x / z); elseif (y <= 1.12e+121) tmp = t_0; else tmp = y / (-z / x); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.1e+157], t$95$0, If[LessEqual[y, -1.95e+89], N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.12e+121], t$95$0, N[(y / N[((-z) / x), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y + \frac{x}{z}\\
\mathbf{if}\;y \leq -2.1 \cdot 10^{+157}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -1.95 \cdot 10^{+89}:\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\mathbf{elif}\;y \leq 1.12 \cdot 10^{+121}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{-z}{x}}\\
\end{array}
\end{array}
if y < -2.1e157 or -1.95000000000000005e89 < y < 1.12e121Initial program 91.8%
Taylor expanded in x around 0 98.3%
Taylor expanded in y around 0 91.1%
if -2.1e157 < y < -1.95000000000000005e89Initial program 99.7%
Taylor expanded in y around inf 99.7%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in z around 0 85.6%
neg-mul-185.6%
distribute-neg-frac85.6%
Simplified85.6%
Taylor expanded in y around 0 85.4%
mul-1-neg85.4%
associate-*r/85.7%
distribute-rgt-neg-in85.7%
distribute-frac-neg85.7%
Simplified85.7%
if 1.12e121 < y Initial program 67.7%
Taylor expanded in y around inf 67.7%
associate-/l*100.0%
Simplified100.0%
Taylor expanded in z around 0 63.5%
neg-mul-163.5%
distribute-neg-frac63.5%
Simplified63.5%
Final simplification86.9%
(FPCore (x y z)
:precision binary64
(if (<= y -6.5e+155)
y
(if (<= y -2.1e+78)
(/ x z)
(if (<= y -5.2e-13) y (if (<= y 0.00075) (/ x z) y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e+155) {
tmp = y;
} else if (y <= -2.1e+78) {
tmp = x / z;
} else if (y <= -5.2e-13) {
tmp = y;
} else if (y <= 0.00075) {
tmp = x / z;
} else {
tmp = 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 (y <= (-6.5d+155)) then
tmp = y
else if (y <= (-2.1d+78)) then
tmp = x / z
else if (y <= (-5.2d-13)) then
tmp = y
else if (y <= 0.00075d0) then
tmp = x / z
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e+155) {
tmp = y;
} else if (y <= -2.1e+78) {
tmp = x / z;
} else if (y <= -5.2e-13) {
tmp = y;
} else if (y <= 0.00075) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.5e+155: tmp = y elif y <= -2.1e+78: tmp = x / z elif y <= -5.2e-13: tmp = y elif y <= 0.00075: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.5e+155) tmp = y; elseif (y <= -2.1e+78) tmp = Float64(x / z); elseif (y <= -5.2e-13) tmp = y; elseif (y <= 0.00075) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6.5e+155) tmp = y; elseif (y <= -2.1e+78) tmp = x / z; elseif (y <= -5.2e-13) tmp = y; elseif (y <= 0.00075) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.5e+155], y, If[LessEqual[y, -2.1e+78], N[(x / z), $MachinePrecision], If[LessEqual[y, -5.2e-13], y, If[LessEqual[y, 0.00075], N[(x / z), $MachinePrecision], y]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{+155}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{+78}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq -5.2 \cdot 10^{-13}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 0.00075:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -6.50000000000000046e155 or -2.1000000000000001e78 < y < -5.2000000000000001e-13 or 7.5000000000000002e-4 < y Initial program 71.4%
Taylor expanded in x around 0 58.0%
if -6.50000000000000046e155 < y < -2.1000000000000001e78 or -5.2000000000000001e-13 < y < 7.5000000000000002e-4Initial program 99.9%
Taylor expanded in y around 0 76.7%
Final simplification69.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.7e+145) (not (<= x 3.1e+68))) (* (/ x z) (- 1.0 y)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.7e+145) || !(x <= 3.1e+68)) {
tmp = (x / z) * (1.0 - y);
} else {
tmp = y + (x / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-1.7d+145)) .or. (.not. (x <= 3.1d+68))) then
tmp = (x / z) * (1.0d0 - y)
else
tmp = y + (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.7e+145) || !(x <= 3.1e+68)) {
tmp = (x / z) * (1.0 - y);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.7e+145) or not (x <= 3.1e+68): tmp = (x / z) * (1.0 - y) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.7e+145) || !(x <= 3.1e+68)) tmp = Float64(Float64(x / z) * Float64(1.0 - y)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.7e+145) || ~((x <= 3.1e+68))) tmp = (x / z) * (1.0 - y); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.7e+145], N[Not[LessEqual[x, 3.1e+68]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] * N[(1.0 - y), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.7 \cdot 10^{+145} \lor \neg \left(x \leq 3.1 \cdot 10^{+68}\right):\\
\;\;\;\;\frac{x}{z} \cdot \left(1 - y\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -1.7e145 or 3.0999999999999998e68 < x Initial program 87.5%
Taylor expanded in x around inf 85.4%
associate-/l*93.1%
mul-1-neg93.1%
unsub-neg93.1%
Simplified93.1%
div-inv93.1%
clear-num93.2%
Applied egg-rr93.2%
if -1.7e145 < x < 3.0999999999999998e68Initial program 89.2%
Taylor expanded in x around 0 96.5%
Taylor expanded in y around 0 88.7%
Final simplification90.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.52) (not (<= y 1.0))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.52) || !(y <= 1.0)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
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 ((y <= (-1.52d0)) .or. (.not. (y <= 1.0d0))) then
tmp = y * (1.0d0 - (x / z))
else
tmp = y + (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.52) || !(y <= 1.0)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.52) or not (y <= 1.0): tmp = y * (1.0 - (x / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.52) || !(y <= 1.0)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.52) || ~((y <= 1.0))) tmp = y * (1.0 - (x / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.52], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.52 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -1.52 or 1 < y Initial program 73.5%
Taylor expanded in y around 0 93.5%
Taylor expanded in y around inf 99.0%
if -1.52 < y < 1Initial program 99.9%
Taylor expanded in x around 0 99.7%
Taylor expanded in y around 0 98.8%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (<= y -1.52) (* y (- 1.0 (/ x z))) (if (<= y 1.0) (+ y (/ x z)) (/ y (/ z (- z x))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.52) {
tmp = y * (1.0 - (x / z));
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y / (z / (z - 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 (y <= (-1.52d0)) then
tmp = y * (1.0d0 - (x / z))
else if (y <= 1.0d0) then
tmp = y + (x / z)
else
tmp = y / (z / (z - x))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.52) {
tmp = y * (1.0 - (x / z));
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y / (z / (z - x));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.52: tmp = y * (1.0 - (x / z)) elif y <= 1.0: tmp = y + (x / z) else: tmp = y / (z / (z - x)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.52) tmp = Float64(y * Float64(1.0 - Float64(x / z))); elseif (y <= 1.0) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y / Float64(z / Float64(z - x))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.52) tmp = y * (1.0 - (x / z)); elseif (y <= 1.0) tmp = y + (x / z); else tmp = y / (z / (z - x)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.52], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.52:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\end{array}
\end{array}
if y < -1.52Initial program 72.2%
Taylor expanded in y around 0 99.9%
Taylor expanded in y around inf 99.0%
if -1.52 < y < 1Initial program 99.9%
Taylor expanded in x around 0 99.7%
Taylor expanded in y around 0 98.8%
if 1 < y Initial program 74.7%
Taylor expanded in y around inf 73.8%
associate-/l*99.0%
Simplified99.0%
Final simplification98.9%
(FPCore (x y z) :precision binary64 (if (<= y 6.4e+146) (+ y (/ x z)) (* z (/ y z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 6.4e+146) {
tmp = y + (x / z);
} else {
tmp = z * (y / z);
}
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 (y <= 6.4d+146) then
tmp = y + (x / z)
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 6.4e+146) {
tmp = y + (x / z);
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 6.4e+146: tmp = y + (x / z) else: tmp = z * (y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 6.4e+146) tmp = Float64(y + Float64(x / z)); else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 6.4e+146) tmp = y + (x / z); else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 6.4e+146], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 6.4 \cdot 10^{+146}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < 6.3999999999999999e146Initial program 91.3%
Taylor expanded in x around 0 97.6%
Taylor expanded in y around 0 86.8%
if 6.3999999999999999e146 < y Initial program 67.3%
Taylor expanded in x around 0 15.3%
associate-/l*41.3%
associate-/r/54.7%
Applied egg-rr54.7%
Final simplification83.3%
(FPCore (x y z) :precision binary64 (if (<= y 1.0) (+ y (/ x z)) (- y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y - (x / z);
}
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 (y <= 1.0d0) then
tmp = y + (x / z)
else
tmp = y - (x / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.0: tmp = y + (x / z) else: tmp = y - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.0) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y - Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.0) tmp = y + (x / z); else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.0], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < 1Initial program 92.5%
Taylor expanded in x around 0 97.8%
Taylor expanded in y around 0 92.2%
if 1 < y Initial program 74.7%
Taylor expanded in x around 0 96.3%
Taylor expanded in y around 0 43.3%
+-commutative43.3%
*-un-lft-identity43.3%
fma-def43.3%
frac-2neg43.3%
distribute-frac-neg43.3%
add-sqr-sqrt28.6%
sqrt-unprod52.7%
sqr-neg52.7%
sqrt-unprod21.0%
add-sqr-sqrt57.8%
fma-neg57.8%
*-un-lft-identity57.8%
Applied egg-rr57.8%
Final simplification84.8%
(FPCore (x y z) :precision binary64 y)
double code(double x, double y, double z) {
return y;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = y
end function
public static double code(double x, double y, double z) {
return y;
}
def code(x, y, z): return y
function code(x, y, z) return y end
function tmp = code(x, y, z) tmp = y; end
code[x_, y_, z_] := y
\begin{array}{l}
\\
y
\end{array}
Initial program 88.7%
Taylor expanded in x around 0 35.4%
Final simplification35.4%
(FPCore (x y z) :precision binary64 (- (+ y (/ x z)) (/ y (/ z x))))
double code(double x, double y, double z) {
return (y + (x / z)) - (y / (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 + (x / z)) - (y / (z / x))
end function
public static double code(double x, double y, double z) {
return (y + (x / z)) - (y / (z / x));
}
def code(x, y, z): return (y + (x / z)) - (y / (z / x))
function code(x, y, z) return Float64(Float64(y + Float64(x / z)) - Float64(y / Float64(z / x))) end
function tmp = code(x, y, z) tmp = (y + (x / z)) - (y / (z / x)); end
code[x_, y_, z_] := N[(N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(y / N[(z / x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\left(y + \frac{x}{z}\right) - \frac{y}{\frac{z}{x}}
\end{array}
herbie shell --seed 2023240
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:herbie-target
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))