
(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 10 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 -1.02e+21) (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.02e+21) || !(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.02d+21)) .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.02e+21) || !(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.02e+21) 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.02e+21) || !(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.02e+21) || ~((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.02e+21], 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.02 \cdot 10^{+21} \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.02e21 or 1 < y Initial program 75.4%
Taylor expanded in y around inf 74.4%
associate-/l*98.9%
div-sub99.0%
*-inverses99.0%
Simplified99.0%
if -1.02e21 < y < 1Initial program 100.0%
Taylor expanded in y around inf 87.5%
Taylor expanded in y around 0 96.9%
sub-neg96.9%
distribute-frac-neg96.9%
distribute-rgt-in96.9%
*-lft-identity96.9%
associate-+l+96.9%
distribute-frac-neg96.9%
mul-1-neg96.9%
*-commutative96.9%
associate-*l*96.9%
neg-mul-196.9%
*-rgt-identity96.9%
distribute-lft-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l/100.0%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in y around 0 99.0%
Taylor expanded in y around 0 99.3%
+-commutative99.3%
Simplified99.3%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.2e+46) (not (<= x 7.5e+50))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.2e+46) || !(x <= 7.5e+50)) {
tmp = x * ((1.0 - y) / 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 ((x <= (-3.2d+46)) .or. (.not. (x <= 7.5d+50))) then
tmp = x * ((1.0d0 - y) / 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 ((x <= -3.2e+46) || !(x <= 7.5e+50)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.2e+46) or not (x <= 7.5e+50): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.2e+46) || !(x <= 7.5e+50)) tmp = Float64(x * Float64(Float64(1.0 - y) / z)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.2e+46) || ~((x <= 7.5e+50))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.2e+46], N[Not[LessEqual[x, 7.5e+50]], $MachinePrecision]], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.2 \cdot 10^{+46} \lor \neg \left(x \leq 7.5 \cdot 10^{+50}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -3.1999999999999998e46 or 7.4999999999999999e50 < x Initial program 87.8%
Taylor expanded in x around inf 83.1%
associate-/l*90.5%
mul-1-neg90.5%
unsub-neg90.5%
Simplified90.5%
if -3.1999999999999998e46 < x < 7.4999999999999999e50Initial program 88.1%
Taylor expanded in y around inf 88.1%
Taylor expanded in y around 0 100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-rgt-in100.0%
*-lft-identity100.0%
associate-+l+100.0%
distribute-frac-neg100.0%
mul-1-neg100.0%
*-commutative100.0%
associate-*l*100.0%
neg-mul-1100.0%
*-rgt-identity100.0%
distribute-lft-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l/100.0%
associate-*r/94.7%
Simplified94.7%
Taylor expanded in y around 0 85.9%
Taylor expanded in y around 0 86.0%
+-commutative86.0%
Simplified86.0%
Final simplification87.9%
(FPCore (x y z) :precision binary64 (if (or (<= y -2.15e+171) (not (<= y 1.0))) (* z (/ y z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2.15e+171) || !(y <= 1.0)) {
tmp = z * (y / 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 <= (-2.15d+171)) .or. (.not. (y <= 1.0d0))) then
tmp = z * (y / 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 <= -2.15e+171) || !(y <= 1.0)) {
tmp = z * (y / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2.15e+171) or not (y <= 1.0): tmp = z * (y / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2.15e+171) || !(y <= 1.0)) tmp = Float64(z * Float64(y / z)); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -2.15e+171) || ~((y <= 1.0))) tmp = z * (y / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2.15e+171], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.15 \cdot 10^{+171} \lor \neg \left(y \leq 1\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -2.15000000000000004e171 or 1 < y Initial program 76.5%
Taylor expanded in y around inf 76.5%
Taylor expanded in z around inf 30.4%
*-commutative30.4%
associate-/l*57.7%
Applied egg-rr57.7%
if -2.15000000000000004e171 < y < 1Initial program 94.6%
Taylor expanded in y around inf 84.5%
Taylor expanded in y around 0 97.5%
sub-neg97.5%
distribute-frac-neg97.5%
distribute-rgt-in97.5%
*-lft-identity97.5%
associate-+l+97.5%
distribute-frac-neg97.5%
mul-1-neg97.5%
*-commutative97.5%
associate-*l*97.5%
neg-mul-197.5%
*-rgt-identity97.5%
distribute-lft-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l/98.8%
associate-*r/99.2%
Simplified99.2%
Taylor expanded in y around 0 91.1%
Taylor expanded in y around 0 91.4%
+-commutative91.4%
Simplified91.4%
Final simplification79.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.25e-67) (not (<= y 2.3e-17))) (* z (/ y z)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.25e-67) || !(y <= 2.3e-17)) {
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 <= (-1.25d-67)) .or. (.not. (y <= 2.3d-17))) 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 <= -1.25e-67) || !(y <= 2.3e-17)) {
tmp = z * (y / z);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.25e-67) or not (y <= 2.3e-17): tmp = z * (y / z) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.25e-67) || !(y <= 2.3e-17)) 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 <= -1.25e-67) || ~((y <= 2.3e-17))) tmp = z * (y / z); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.25e-67], N[Not[LessEqual[y, 2.3e-17]], $MachinePrecision]], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{-67} \lor \neg \left(y \leq 2.3 \cdot 10^{-17}\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -1.25e-67 or 2.30000000000000009e-17 < y Initial program 79.4%
Taylor expanded in y around inf 79.4%
Taylor expanded in z around inf 34.8%
*-commutative34.8%
associate-/l*55.8%
Applied egg-rr55.8%
if -1.25e-67 < y < 2.30000000000000009e-17Initial program 99.9%
Taylor expanded in y around 0 76.4%
Final simplification64.4%
(FPCore (x y z) :precision binary64 (if (<= y -2.1e+121) (* y (/ x (- z))) (if (<= y 1.0) (+ y (/ x z)) (- y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.1e+121) {
tmp = y * (x / -z);
} else 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 <= (-2.1d+121)) then
tmp = y * (x / -z)
else 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 <= -2.1e+121) {
tmp = y * (x / -z);
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.1e+121: tmp = y * (x / -z) elif y <= 1.0: tmp = y + (x / z) else: tmp = y - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.1e+121) tmp = Float64(y * Float64(x / Float64(-z))); elseif (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 <= -2.1e+121) tmp = y * (x / -z); elseif (y <= 1.0) tmp = y + (x / z); else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.1e+121], N[(y * N[(x / (-z)), $MachinePrecision]), $MachinePrecision], 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 -2.1 \cdot 10^{+121}:\\
\;\;\;\;y \cdot \frac{x}{-z}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < -2.1000000000000002e121Initial program 69.5%
Taylor expanded in y around inf 69.5%
associate-/l*99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
Taylor expanded in x around inf 66.3%
mul-1-neg66.3%
distribute-frac-neg66.3%
Simplified66.3%
if -2.1000000000000002e121 < y < 1Initial program 96.8%
Taylor expanded in y around inf 85.8%
Taylor expanded in y around 0 97.3%
sub-neg97.3%
distribute-frac-neg97.3%
distribute-rgt-in97.3%
*-lft-identity97.3%
associate-+l+97.3%
distribute-frac-neg97.3%
mul-1-neg97.3%
*-commutative97.3%
associate-*l*97.3%
neg-mul-197.3%
*-rgt-identity97.3%
distribute-lft-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l/99.4%
associate-*r/99.7%
Simplified99.7%
Taylor expanded in y around 0 94.2%
Taylor expanded in y around 0 94.4%
+-commutative94.4%
Simplified94.4%
if 1 < y Initial program 79.5%
Taylor expanded in y around inf 79.5%
Taylor expanded in y around 0 89.0%
sub-neg89.0%
distribute-frac-neg89.0%
distribute-rgt-in89.0%
*-lft-identity89.0%
associate-+l+89.0%
distribute-frac-neg89.0%
mul-1-neg89.0%
*-commutative89.0%
associate-*l*89.0%
neg-mul-189.0%
*-rgt-identity89.0%
distribute-lft-in99.9%
+-commutative99.9%
sub-neg99.9%
associate-*l/94.1%
associate-*r/90.9%
Simplified90.9%
Taylor expanded in y around 0 46.5%
add-sqr-sqrt14.8%
sqrt-unprod53.9%
sqr-neg53.9%
sqrt-unprod37.2%
add-sqr-sqrt58.9%
cancel-sign-sub-inv58.9%
un-div-inv58.9%
Applied egg-rr58.9%
Final simplification80.9%
(FPCore (x y z) :precision binary64 (if (<= y -1.55e+147) (* x (/ y (- z))) (if (<= y 1.0) (+ y (/ x z)) (- y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.55e+147) {
tmp = x * (y / -z);
} else 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.55d+147)) then
tmp = x * (y / -z)
else 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.55e+147) {
tmp = x * (y / -z);
} else 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.55e+147: tmp = x * (y / -z) elif 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.55e+147) tmp = Float64(x * Float64(y / Float64(-z))); elseif (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.55e+147) tmp = x * (y / -z); elseif (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.55e+147], N[(x * N[(y / (-z)), $MachinePrecision]), $MachinePrecision], 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.55 \cdot 10^{+147}:\\
\;\;\;\;x \cdot \frac{y}{-z}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < -1.55e147Initial program 70.7%
Taylor expanded in x around inf 57.1%
associate-/l*67.4%
mul-1-neg67.4%
unsub-neg67.4%
Simplified67.4%
Taylor expanded in y around inf 57.1%
mul-1-neg57.1%
associate-/l*67.4%
distribute-rgt-neg-in67.4%
distribute-neg-frac67.4%
Simplified67.4%
if -1.55e147 < y < 1Initial program 95.1%
Taylor expanded in y around inf 84.7%
Taylor expanded in y around 0 97.5%
sub-neg97.5%
distribute-frac-neg97.5%
distribute-rgt-in97.5%
*-lft-identity97.5%
associate-+l+97.5%
distribute-frac-neg97.5%
mul-1-neg97.5%
*-commutative97.5%
associate-*l*97.5%
neg-mul-197.5%
*-rgt-identity97.5%
distribute-lft-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l/98.8%
associate-*r/99.1%
Simplified99.1%
Taylor expanded in y around 0 92.1%
Taylor expanded in y around 0 92.4%
+-commutative92.4%
Simplified92.4%
if 1 < y Initial program 79.5%
Taylor expanded in y around inf 79.5%
Taylor expanded in y around 0 89.0%
sub-neg89.0%
distribute-frac-neg89.0%
distribute-rgt-in89.0%
*-lft-identity89.0%
associate-+l+89.0%
distribute-frac-neg89.0%
mul-1-neg89.0%
*-commutative89.0%
associate-*l*89.0%
neg-mul-189.0%
*-rgt-identity89.0%
distribute-lft-in99.9%
+-commutative99.9%
sub-neg99.9%
associate-*l/94.1%
associate-*r/90.9%
Simplified90.9%
Taylor expanded in y around 0 46.5%
add-sqr-sqrt14.8%
sqrt-unprod53.9%
sqr-neg53.9%
sqrt-unprod37.2%
add-sqr-sqrt58.9%
cancel-sign-sub-inv58.9%
un-div-inv58.9%
Applied egg-rr58.9%
Final simplification80.7%
(FPCore (x y z) :precision binary64 (if (<= y -4e+170) (* z (/ y z)) (if (<= y 1.0) (+ y (/ x z)) (- y (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4e+170) {
tmp = z * (y / z);
} else 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 <= (-4d+170)) then
tmp = z * (y / z)
else 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 <= -4e+170) {
tmp = z * (y / z);
} else if (y <= 1.0) {
tmp = y + (x / z);
} else {
tmp = y - (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4e+170: tmp = z * (y / z) elif y <= 1.0: tmp = y + (x / z) else: tmp = y - (x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4e+170) tmp = Float64(z * Float64(y / z)); elseif (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 <= -4e+170) tmp = z * (y / z); elseif (y <= 1.0) tmp = y + (x / z); else tmp = y - (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4e+170], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], 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 -4 \cdot 10^{+170}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{elif}\;y \leq 1:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - \frac{x}{z}\\
\end{array}
\end{array}
if y < -4.00000000000000014e170Initial program 70.1%
Taylor expanded in y around inf 70.1%
Taylor expanded in z around inf 20.0%
*-commutative20.0%
associate-/l*65.8%
Applied egg-rr65.8%
if -4.00000000000000014e170 < y < 1Initial program 94.6%
Taylor expanded in y around inf 84.5%
Taylor expanded in y around 0 97.5%
sub-neg97.5%
distribute-frac-neg97.5%
distribute-rgt-in97.5%
*-lft-identity97.5%
associate-+l+97.5%
distribute-frac-neg97.5%
mul-1-neg97.5%
*-commutative97.5%
associate-*l*97.5%
neg-mul-197.5%
*-rgt-identity97.5%
distribute-lft-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l/98.8%
associate-*r/99.2%
Simplified99.2%
Taylor expanded in y around 0 91.1%
Taylor expanded in y around 0 91.4%
+-commutative91.4%
Simplified91.4%
if 1 < y Initial program 79.5%
Taylor expanded in y around inf 79.5%
Taylor expanded in y around 0 89.0%
sub-neg89.0%
distribute-frac-neg89.0%
distribute-rgt-in89.0%
*-lft-identity89.0%
associate-+l+89.0%
distribute-frac-neg89.0%
mul-1-neg89.0%
*-commutative89.0%
associate-*l*89.0%
neg-mul-189.0%
*-rgt-identity89.0%
distribute-lft-in99.9%
+-commutative99.9%
sub-neg99.9%
associate-*l/94.1%
associate-*r/90.9%
Simplified90.9%
Taylor expanded in y around 0 46.5%
add-sqr-sqrt14.8%
sqrt-unprod53.9%
sqr-neg53.9%
sqrt-unprod37.2%
add-sqr-sqrt58.9%
cancel-sign-sub-inv58.9%
un-div-inv58.9%
Applied egg-rr58.9%
Final simplification80.3%
(FPCore (x y z) :precision binary64 (if (<= y 430000.0) (+ y (* x (/ (- 1.0 y) z))) (* y (- 1.0 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 430000.0) {
tmp = y + (x * ((1.0 - y) / z));
} else {
tmp = y * (1.0 - (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) then
tmp = y + (x * ((1.0d0 - y) / z))
else
tmp = y * (1.0d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 430000.0) {
tmp = y + (x * ((1.0 - y) / z));
} else {
tmp = y * (1.0 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 430000.0: tmp = y + (x * ((1.0 - y) / z)) else: tmp = y * (1.0 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 430000.0) tmp = Float64(y + Float64(x * Float64(Float64(1.0 - y) / z))); else tmp = Float64(y * Float64(1.0 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 430000.0) tmp = y + (x * ((1.0 - y) / z)); else tmp = y * (1.0 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 430000.0], N[(y + N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 430000:\\
\;\;\;\;y + x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < 4.3e5Initial program 90.9%
Taylor expanded in y around inf 82.4%
Taylor expanded in y around 0 97.9%
sub-neg97.9%
distribute-frac-neg97.9%
distribute-rgt-in97.9%
*-lft-identity97.9%
associate-+l+97.9%
distribute-frac-neg97.9%
mul-1-neg97.9%
*-commutative97.9%
associate-*l*97.9%
neg-mul-197.9%
*-rgt-identity97.9%
distribute-lft-in100.0%
+-commutative100.0%
sub-neg100.0%
associate-*l/96.7%
associate-*r/98.8%
Simplified98.8%
if 4.3e5 < y Initial program 78.8%
Taylor expanded in y around inf 78.8%
associate-/l*99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
(FPCore (x y z) :precision binary64 (if (<= y -6e-68) y (if (<= y 1.05e-13) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -6e-68) {
tmp = y;
} else if (y <= 1.05e-13) {
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 <= (-6d-68)) then
tmp = y
else if (y <= 1.05d-13) 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 <= -6e-68) {
tmp = y;
} else if (y <= 1.05e-13) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6e-68: tmp = y elif y <= 1.05e-13: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6e-68) tmp = y; elseif (y <= 1.05e-13) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -6e-68) tmp = y; elseif (y <= 1.05e-13) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6e-68], y, If[LessEqual[y, 1.05e-13], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6 \cdot 10^{-68}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.05 \cdot 10^{-13}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -6e-68 or 1.04999999999999994e-13 < y Initial program 79.4%
Taylor expanded in x around 0 47.6%
if -6e-68 < y < 1.04999999999999994e-13Initial program 99.9%
Taylor expanded in y around 0 76.4%
(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.0%
Taylor expanded in x around 0 38.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 2024185
(FPCore (x y z)
:name "Diagrams.Backend.Rasterific:rasterificRadialGradient from diagrams-rasterific-1.3.1.3"
:precision binary64
:alt
(! :herbie-platform default (- (+ y (/ x z)) (/ y (/ z x))))
(/ (+ x (* y (- z x))) z))