
(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 11 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 (or (<= y -430000.0) (not (<= y 102000.0))) (* y (- 1.0 (/ x z))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -430000.0) || !(y <= 102000.0)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - 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 <= (-430000.0d0)) .or. (.not. (y <= 102000.0d0))) then
tmp = y * (1.0d0 - (x / z))
else
tmp = (x + (y * (z - x))) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -430000.0) || !(y <= 102000.0)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x + (y * (z - x))) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -430000.0) or not (y <= 102000.0): tmp = y * (1.0 - (x / z)) else: tmp = (x + (y * (z - x))) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -430000.0) || !(y <= 102000.0)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -430000.0) || ~((y <= 102000.0))) tmp = y * (1.0 - (x / z)); else tmp = (x + (y * (z - x))) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -430000.0], N[Not[LessEqual[y, 102000.0]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -430000 \lor \neg \left(y \leq 102000\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\end{array}
\end{array}
if y < -4.3e5 or 102000 < y Initial program 76.8%
Taylor expanded in y around inf 76.5%
associate-/l*99.6%
div-sub99.6%
sub-neg99.6%
*-inverses99.6%
sub-neg99.6%
Simplified99.6%
if -4.3e5 < y < 102000Initial program 99.9%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ (- 1.0 y) z))) (t_1 (* y (- 1.0 (/ x z)))))
(if (<= y -1.45e-6)
t_1
(if (<= y -1.22e-29)
t_0
(if (<= y -2.1e-85)
t_1
(if (<= y 0.00195) (/ x z) (if (<= y 12500.0) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = x * ((1.0 - y) / z);
double t_1 = y * (1.0 - (x / z));
double tmp;
if (y <= -1.45e-6) {
tmp = t_1;
} else if (y <= -1.22e-29) {
tmp = t_0;
} else if (y <= -2.1e-85) {
tmp = t_1;
} else if (y <= 0.00195) {
tmp = x / z;
} else if (y <= 12500.0) {
tmp = t_0;
} else {
tmp = t_1;
}
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) :: t_1
real(8) :: tmp
t_0 = x * ((1.0d0 - y) / z)
t_1 = y * (1.0d0 - (x / z))
if (y <= (-1.45d-6)) then
tmp = t_1
else if (y <= (-1.22d-29)) then
tmp = t_0
else if (y <= (-2.1d-85)) then
tmp = t_1
else if (y <= 0.00195d0) then
tmp = x / z
else if (y <= 12500.0d0) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * ((1.0 - y) / z);
double t_1 = y * (1.0 - (x / z));
double tmp;
if (y <= -1.45e-6) {
tmp = t_1;
} else if (y <= -1.22e-29) {
tmp = t_0;
} else if (y <= -2.1e-85) {
tmp = t_1;
} else if (y <= 0.00195) {
tmp = x / z;
} else if (y <= 12500.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = x * ((1.0 - y) / z) t_1 = y * (1.0 - (x / z)) tmp = 0 if y <= -1.45e-6: tmp = t_1 elif y <= -1.22e-29: tmp = t_0 elif y <= -2.1e-85: tmp = t_1 elif y <= 0.00195: tmp = x / z elif y <= 12500.0: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(Float64(1.0 - y) / z)) t_1 = Float64(y * Float64(1.0 - Float64(x / z))) tmp = 0.0 if (y <= -1.45e-6) tmp = t_1; elseif (y <= -1.22e-29) tmp = t_0; elseif (y <= -2.1e-85) tmp = t_1; elseif (y <= 0.00195) tmp = Float64(x / z); elseif (y <= 12500.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * ((1.0 - y) / z); t_1 = y * (1.0 - (x / z)); tmp = 0.0; if (y <= -1.45e-6) tmp = t_1; elseif (y <= -1.22e-29) tmp = t_0; elseif (y <= -2.1e-85) tmp = t_1; elseif (y <= 0.00195) tmp = x / z; elseif (y <= 12500.0) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.45e-6], t$95$1, If[LessEqual[y, -1.22e-29], t$95$0, If[LessEqual[y, -2.1e-85], t$95$1, If[LessEqual[y, 0.00195], N[(x / z), $MachinePrecision], If[LessEqual[y, 12500.0], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{1 - y}{z}\\
t_1 := y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{if}\;y \leq -1.45 \cdot 10^{-6}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.22 \cdot 10^{-29}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{-85}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 0.00195:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 12500:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if y < -1.4500000000000001e-6 or -1.21999999999999996e-29 < y < -2.1e-85 or 12500 < y Initial program 78.3%
Taylor expanded in y around inf 77.4%
associate-/l*98.9%
div-sub99.0%
sub-neg99.0%
*-inverses99.0%
sub-neg99.0%
Simplified99.0%
if -1.4500000000000001e-6 < y < -1.21999999999999996e-29 or 0.0019499999999999999 < y < 12500Initial program 100.0%
Taylor expanded in x around inf 99.5%
associate-/l*100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
if -2.1e-85 < y < 0.0019499999999999999Initial program 99.9%
Taylor expanded in y around 0 71.4%
Final simplification87.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ y (- z)))))
(if (<= y -5.2e+182)
t_0
(if (<= y -7e-6)
y
(if (<= y 3.9e-20)
(/ x z)
(if (<= y 1.6e+81) y (if (<= y 9.2e+145) t_0 (* z (/ y z)))))))))
double code(double x, double y, double z) {
double t_0 = x * (y / -z);
double tmp;
if (y <= -5.2e+182) {
tmp = t_0;
} else if (y <= -7e-6) {
tmp = y;
} else if (y <= 3.9e-20) {
tmp = x / z;
} else if (y <= 1.6e+81) {
tmp = y;
} else if (y <= 9.2e+145) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = x * (y / -z)
if (y <= (-5.2d+182)) then
tmp = t_0
else if (y <= (-7d-6)) then
tmp = y
else if (y <= 3.9d-20) then
tmp = x / z
else if (y <= 1.6d+81) then
tmp = y
else if (y <= 9.2d+145) then
tmp = t_0
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = x * (y / -z);
double tmp;
if (y <= -5.2e+182) {
tmp = t_0;
} else if (y <= -7e-6) {
tmp = y;
} else if (y <= 3.9e-20) {
tmp = x / z;
} else if (y <= 1.6e+81) {
tmp = y;
} else if (y <= 9.2e+145) {
tmp = t_0;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): t_0 = x * (y / -z) tmp = 0 if y <= -5.2e+182: tmp = t_0 elif y <= -7e-6: tmp = y elif y <= 3.9e-20: tmp = x / z elif y <= 1.6e+81: tmp = y elif y <= 9.2e+145: tmp = t_0 else: tmp = z * (y / z) return tmp
function code(x, y, z) t_0 = Float64(x * Float64(y / Float64(-z))) tmp = 0.0 if (y <= -5.2e+182) tmp = t_0; elseif (y <= -7e-6) tmp = y; elseif (y <= 3.9e-20) tmp = Float64(x / z); elseif (y <= 1.6e+81) tmp = y; elseif (y <= 9.2e+145) tmp = t_0; else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (y / -z); tmp = 0.0; if (y <= -5.2e+182) tmp = t_0; elseif (y <= -7e-6) tmp = y; elseif (y <= 3.9e-20) tmp = x / z; elseif (y <= 1.6e+81) tmp = y; elseif (y <= 9.2e+145) tmp = t_0; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(y / (-z)), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -5.2e+182], t$95$0, If[LessEqual[y, -7e-6], y, If[LessEqual[y, 3.9e-20], N[(x / z), $MachinePrecision], If[LessEqual[y, 1.6e+81], y, If[LessEqual[y, 9.2e+145], t$95$0, N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{y}{-z}\\
\mathbf{if}\;y \leq -5.2 \cdot 10^{+182}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -7 \cdot 10^{-6}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 3.9 \cdot 10^{-20}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 1.6 \cdot 10^{+81}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 9.2 \cdot 10^{+145}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -5.2e182 or 1.6e81 < y < 9.2e145Initial program 67.7%
Taylor expanded in y around inf 67.7%
associate-/l*99.9%
div-sub99.9%
sub-neg99.9%
*-inverses99.9%
sub-neg99.9%
Simplified99.9%
Taylor expanded in x around inf 52.7%
mul-1-neg52.7%
distribute-frac-neg252.7%
associate-/l*60.3%
Simplified60.3%
if -5.2e182 < y < -6.99999999999999989e-6 or 3.90000000000000007e-20 < y < 1.6e81Initial program 88.8%
Taylor expanded in x around 0 56.0%
if -6.99999999999999989e-6 < y < 3.90000000000000007e-20Initial program 99.9%
Taylor expanded in y around 0 70.5%
if 9.2e145 < y Initial program 67.3%
Taylor expanded in x around 0 21.1%
*-commutative21.1%
associate-/l*69.8%
Applied egg-rr69.8%
Final simplification64.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ x z) (- y))))
(if (<= y -6.2e+163)
t_0
(if (<= y -8.2e-7)
y
(if (<= y 1.62e-18)
(/ x z)
(if (<= y 5.5e+80) y (if (<= y 4.2e+140) t_0 (* z (/ y z)))))))))
double code(double x, double y, double z) {
double t_0 = (x / z) * -y;
double tmp;
if (y <= -6.2e+163) {
tmp = t_0;
} else if (y <= -8.2e-7) {
tmp = y;
} else if (y <= 1.62e-18) {
tmp = x / z;
} else if (y <= 5.5e+80) {
tmp = y;
} else if (y <= 4.2e+140) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = (x / z) * -y
if (y <= (-6.2d+163)) then
tmp = t_0
else if (y <= (-8.2d-7)) then
tmp = y
else if (y <= 1.62d-18) then
tmp = x / z
else if (y <= 5.5d+80) then
tmp = y
else if (y <= 4.2d+140) then
tmp = t_0
else
tmp = z * (y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (x / z) * -y;
double tmp;
if (y <= -6.2e+163) {
tmp = t_0;
} else if (y <= -8.2e-7) {
tmp = y;
} else if (y <= 1.62e-18) {
tmp = x / z;
} else if (y <= 5.5e+80) {
tmp = y;
} else if (y <= 4.2e+140) {
tmp = t_0;
} else {
tmp = z * (y / z);
}
return tmp;
}
def code(x, y, z): t_0 = (x / z) * -y tmp = 0 if y <= -6.2e+163: tmp = t_0 elif y <= -8.2e-7: tmp = y elif y <= 1.62e-18: tmp = x / z elif y <= 5.5e+80: tmp = y elif y <= 4.2e+140: tmp = t_0 else: tmp = z * (y / z) return tmp
function code(x, y, z) t_0 = Float64(Float64(x / z) * Float64(-y)) tmp = 0.0 if (y <= -6.2e+163) tmp = t_0; elseif (y <= -8.2e-7) tmp = y; elseif (y <= 1.62e-18) tmp = Float64(x / z); elseif (y <= 5.5e+80) tmp = y; elseif (y <= 4.2e+140) tmp = t_0; else tmp = Float64(z * Float64(y / z)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x / z) * -y; tmp = 0.0; if (y <= -6.2e+163) tmp = t_0; elseif (y <= -8.2e-7) tmp = y; elseif (y <= 1.62e-18) tmp = x / z; elseif (y <= 5.5e+80) tmp = y; elseif (y <= 4.2e+140) tmp = t_0; else tmp = z * (y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x / z), $MachinePrecision] * (-y)), $MachinePrecision]}, If[LessEqual[y, -6.2e+163], t$95$0, If[LessEqual[y, -8.2e-7], y, If[LessEqual[y, 1.62e-18], N[(x / z), $MachinePrecision], If[LessEqual[y, 5.5e+80], y, If[LessEqual[y, 4.2e+140], t$95$0, N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x}{z} \cdot \left(-y\right)\\
\mathbf{if}\;y \leq -6.2 \cdot 10^{+163}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -8.2 \cdot 10^{-7}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.62 \cdot 10^{-18}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 5.5 \cdot 10^{+80}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 4.2 \cdot 10^{+140}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -6.20000000000000057e163 or 5.49999999999999967e80 < y < 4.2000000000000004e140Initial program 74.4%
Taylor expanded in y around inf 74.4%
associate-/l*99.9%
Simplified99.9%
Taylor expanded in z around 0 55.3%
associate-*r/55.3%
mul-1-neg55.3%
*-commutative55.3%
distribute-frac-neg55.3%
associate-*r/62.7%
distribute-rgt-neg-in62.7%
distribute-neg-frac262.7%
Simplified62.7%
if -6.20000000000000057e163 < y < -8.1999999999999998e-7 or 1.62000000000000005e-18 < y < 5.49999999999999967e80Initial program 88.0%
Taylor expanded in x around 0 57.2%
if -8.1999999999999998e-7 < y < 1.62000000000000005e-18Initial program 99.9%
Taylor expanded in y around 0 70.5%
if 4.2000000000000004e140 < y Initial program 61.6%
Taylor expanded in x around 0 18.6%
*-commutative18.6%
associate-/l*67.1%
Applied egg-rr67.1%
Final simplification65.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.8e-111) (not (<= x 5e-81))) (* x (/ (- 1.0 y) z)) y))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.8e-111) || !(x <= 5e-81)) {
tmp = x * ((1.0 - y) / 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 ((x <= (-2.8d-111)) .or. (.not. (x <= 5d-81))) then
tmp = x * ((1.0d0 - y) / z)
else
tmp = y
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.8e-111) || !(x <= 5e-81)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.8e-111) or not (x <= 5e-81): tmp = x * ((1.0 - y) / z) else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.8e-111) || !(x <= 5e-81)) tmp = Float64(x * Float64(Float64(1.0 - y) / z)); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.8e-111) || ~((x <= 5e-81))) tmp = x * ((1.0 - y) / z); else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.8e-111], N[Not[LessEqual[x, 5e-81]], $MachinePrecision]], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], y]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.8 \cdot 10^{-111} \lor \neg \left(x \leq 5 \cdot 10^{-81}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if x < -2.79999999999999995e-111 or 4.99999999999999981e-81 < x Initial program 89.9%
Taylor expanded in x around inf 74.9%
associate-/l*76.6%
mul-1-neg76.6%
unsub-neg76.6%
Simplified76.6%
if -2.79999999999999995e-111 < x < 4.99999999999999981e-81Initial program 84.5%
Taylor expanded in x around 0 78.2%
Final simplification77.1%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.6e-7) (not (<= y 12500.0))) (* y (- 1.0 (/ x z))) (/ (* x (- 1.0 y)) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.6e-7) || !(y <= 12500.0)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x * (1.0 - 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 <= (-7.6d-7)) .or. (.not. (y <= 12500.0d0))) then
tmp = y * (1.0d0 - (x / z))
else
tmp = (x * (1.0d0 - y)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -7.6e-7) || !(y <= 12500.0)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = (x * (1.0 - y)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.6e-7) or not (y <= 12500.0): tmp = y * (1.0 - (x / z)) else: tmp = (x * (1.0 - y)) / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.6e-7) || !(y <= 12500.0)) tmp = Float64(y * Float64(1.0 - Float64(x / z))); else tmp = Float64(Float64(x * Float64(1.0 - y)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7.6e-7) || ~((y <= 12500.0))) tmp = y * (1.0 - (x / z)); else tmp = (x * (1.0 - y)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.6e-7], N[Not[LessEqual[y, 12500.0]], $MachinePrecision]], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x * N[(1.0 - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.6 \cdot 10^{-7} \lor \neg \left(y \leq 12500\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{x \cdot \left(1 - y\right)}{z}\\
\end{array}
\end{array}
if y < -7.60000000000000029e-7 or 12500 < y Initial program 77.2%
Taylor expanded in y around inf 76.9%
associate-/l*99.6%
div-sub99.6%
sub-neg99.6%
*-inverses99.6%
sub-neg99.6%
Simplified99.6%
if -7.60000000000000029e-7 < y < 12500Initial program 99.9%
Taylor expanded in x around inf 71.5%
mul-1-neg71.5%
unsub-neg71.5%
Simplified71.5%
Final simplification86.0%
(FPCore (x y z) :precision binary64 (let* ((t_0 (* y (- 1.0 (/ x z))))) (if (<= y 76000.0) (+ (/ x z) t_0) t_0)))
double code(double x, double y, double z) {
double t_0 = y * (1.0 - (x / z));
double tmp;
if (y <= 76000.0) {
tmp = (x / z) + t_0;
} 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 = y * (1.0d0 - (x / z))
if (y <= 76000.0d0) then
tmp = (x / z) + t_0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = y * (1.0 - (x / z));
double tmp;
if (y <= 76000.0) {
tmp = (x / z) + t_0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = y * (1.0 - (x / z)) tmp = 0 if y <= 76000.0: tmp = (x / z) + t_0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(y * Float64(1.0 - Float64(x / z))) tmp = 0.0 if (y <= 76000.0) tmp = Float64(Float64(x / z) + t_0); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = y * (1.0 - (x / z)); tmp = 0.0; if (y <= 76000.0) tmp = (x / z) + t_0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, 76000.0], N[(N[(x / z), $MachinePrecision] + t$95$0), $MachinePrecision], t$95$0]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{if}\;y \leq 76000:\\
\;\;\;\;\frac{x}{z} + t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < 76000Initial program 92.7%
Taylor expanded in y around 0 98.4%
if 76000 < y Initial program 74.4%
Taylor expanded in y around inf 74.4%
associate-/l*99.8%
div-sub99.8%
sub-neg99.8%
*-inverses99.8%
sub-neg99.8%
Simplified99.8%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.4e-6) (not (<= y 2.6e-18))) (* z (/ y z)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e-6) || !(y <= 2.6e-18)) {
tmp = z * (y / z);
} else {
tmp = 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 <= (-3.4d-6)) .or. (.not. (y <= 2.6d-18))) then
tmp = z * (y / z)
else
tmp = x / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e-6) || !(y <= 2.6e-18)) {
tmp = z * (y / z);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.4e-6) or not (y <= 2.6e-18): tmp = z * (y / z) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.4e-6) || !(y <= 2.6e-18)) tmp = Float64(z * Float64(y / z)); else tmp = Float64(x / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.4e-6) || ~((y <= 2.6e-18))) tmp = z * (y / z); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e-6], N[Not[LessEqual[y, 2.6e-18]], $MachinePrecision]], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.4 \cdot 10^{-6} \lor \neg \left(y \leq 2.6 \cdot 10^{-18}\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -3.40000000000000006e-6 or 2.6e-18 < y Initial program 78.2%
Taylor expanded in x around 0 32.8%
*-commutative32.8%
associate-/l*51.3%
Applied egg-rr51.3%
if -3.40000000000000006e-6 < y < 2.6e-18Initial program 99.9%
Taylor expanded in y around 0 70.5%
Final simplification60.1%
(FPCore (x y z) :precision binary64 (if (<= y -8.5e-7) (* z (/ y z)) (if (<= y 1.15e-20) (/ x z) (/ z (/ z y)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.5e-7) {
tmp = z * (y / z);
} else if (y <= 1.15e-20) {
tmp = x / z;
} else {
tmp = z / (z / 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 <= (-8.5d-7)) then
tmp = z * (y / z)
else if (y <= 1.15d-20) then
tmp = x / z
else
tmp = z / (z / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8.5e-7) {
tmp = z * (y / z);
} else if (y <= 1.15e-20) {
tmp = x / z;
} else {
tmp = z / (z / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.5e-7: tmp = z * (y / z) elif y <= 1.15e-20: tmp = x / z else: tmp = z / (z / y) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.5e-7) tmp = Float64(z * Float64(y / z)); elseif (y <= 1.15e-20) tmp = Float64(x / z); else tmp = Float64(z / Float64(z / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.5e-7) tmp = z * (y / z); elseif (y <= 1.15e-20) tmp = x / z; else tmp = z / (z / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.5e-7], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.15e-20], N[(x / z), $MachinePrecision], N[(z / N[(z / y), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{-7}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{-20}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{z}{\frac{z}{y}}\\
\end{array}
\end{array}
if y < -8.50000000000000014e-7Initial program 79.8%
Taylor expanded in x around 0 35.9%
*-commutative35.9%
associate-/l*49.6%
Applied egg-rr49.6%
if -8.50000000000000014e-7 < y < 1.15e-20Initial program 99.9%
Taylor expanded in y around 0 70.5%
if 1.15e-20 < y Initial program 76.6%
Taylor expanded in x around 0 29.8%
*-commutative29.8%
associate-/l*52.9%
Applied egg-rr52.9%
clear-num52.8%
un-div-inv53.2%
Applied egg-rr53.2%
Final simplification60.2%
(FPCore (x y z) :precision binary64 (if (<= y -8.5e-7) y (if (<= y 8e-18) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.5e-7) {
tmp = y;
} else if (y <= 8e-18) {
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 <= (-8.5d-7)) then
tmp = y
else if (y <= 8d-18) 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 <= -8.5e-7) {
tmp = y;
} else if (y <= 8e-18) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.5e-7: tmp = y elif y <= 8e-18: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.5e-7) tmp = y; elseif (y <= 8e-18) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.5e-7) tmp = y; elseif (y <= 8e-18) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.5e-7], y, If[LessEqual[y, 8e-18], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{-7}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 8 \cdot 10^{-18}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -8.50000000000000014e-7 or 8.0000000000000006e-18 < y Initial program 78.2%
Taylor expanded in x around 0 48.6%
if -8.50000000000000014e-7 < y < 8.0000000000000006e-18Initial program 99.9%
Taylor expanded in y around 0 70.5%
Final simplification58.7%
(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.2%
Taylor expanded in x around 0 39.9%
Final simplification39.9%
(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 2024080
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:alt
(- (+ y (/ x z)) (/ y (/ z x)))
(/ (+ x (* y (- z x))) z))