
(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 (<= y -2e-210) (+ (/ y (/ z (- z x))) (/ x z)) (if (<= y 3.4e+51) (/ (fma y (- z x) x) z) (* y (/ (- z x) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e-210) {
tmp = (y / (z / (z - x))) + (x / z);
} else if (y <= 3.4e+51) {
tmp = fma(y, (z - x), x) / z;
} else {
tmp = y * ((z - x) / z);
}
return tmp;
}
function code(x, y, z) tmp = 0.0 if (y <= -2e-210) tmp = Float64(Float64(y / Float64(z / Float64(z - x))) + Float64(x / z)); elseif (y <= 3.4e+51) tmp = Float64(fma(y, Float64(z - x), x) / z); else tmp = Float64(y * Float64(Float64(z - x) / z)); end return tmp end
code[x_, y_, z_] := If[LessEqual[y, -2e-210], N[(N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.4e+51], N[(N[(y * N[(z - x), $MachinePrecision] + x), $MachinePrecision] / z), $MachinePrecision], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-210}:\\
\;\;\;\;\frac{y}{\frac{z}{z - x}} + \frac{x}{z}\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+51}:\\
\;\;\;\;\frac{\mathsf{fma}\left(y, z - x, x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\end{array}
\end{array}
if y < -2.0000000000000001e-210Initial program 83.0%
Taylor expanded in y around 0 99.9%
*-inverses99.9%
div-sub99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
if -2.0000000000000001e-210 < y < 3.39999999999999984e51Initial program 100.0%
+-commutative100.0%
fma-define100.0%
Simplified100.0%
if 3.39999999999999984e51 < y Initial program 61.0%
Taylor expanded in y around inf 61.0%
associate-/l*100.0%
Simplified100.0%
(FPCore (x y z) :precision binary64 (if (<= y -2e-210) (+ (/ y (/ z (- z x))) (/ x z)) (if (<= y 3.4e+51) (/ (+ x (* y (- z x))) z) (* y (/ (- z x) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e-210) {
tmp = (y / (z / (z - x))) + (x / z);
} else if (y <= 3.4e+51) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = 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 <= (-2d-210)) then
tmp = (y / (z / (z - x))) + (x / z)
else if (y <= 3.4d+51) then
tmp = (x + (y * (z - x))) / z
else
tmp = y * ((z - x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2e-210) {
tmp = (y / (z / (z - x))) + (x / z);
} else if (y <= 3.4e+51) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y * ((z - x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e-210: tmp = (y / (z / (z - x))) + (x / z) elif y <= 3.4e+51: tmp = (x + (y * (z - x))) / z else: tmp = y * ((z - x) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e-210) tmp = Float64(Float64(y / Float64(z / Float64(z - x))) + Float64(x / z)); elseif (y <= 3.4e+51) tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); else tmp = Float64(y * Float64(Float64(z - x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2e-210) tmp = (y / (z / (z - x))) + (x / z); elseif (y <= 3.4e+51) tmp = (x + (y * (z - x))) / z; else tmp = y * ((z - x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e-210], N[(N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.4e+51], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-210}:\\
\;\;\;\;\frac{y}{\frac{z}{z - x}} + \frac{x}{z}\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+51}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\end{array}
\end{array}
if y < -2.0000000000000001e-210Initial program 83.0%
Taylor expanded in y around 0 99.9%
*-inverses99.9%
div-sub99.9%
clear-num99.9%
un-div-inv99.9%
Applied egg-rr99.9%
if -2.0000000000000001e-210 < y < 3.39999999999999984e51Initial program 100.0%
if 3.39999999999999984e51 < y Initial program 61.0%
Taylor expanded in y around inf 61.0%
associate-/l*100.0%
Simplified100.0%
(FPCore (x y z) :precision binary64 (if (<= y -4.1e+48) (/ y (/ z (- z x))) (if (<= y 3.4e+51) (/ (+ x (* y (- z x))) z) (* y (/ (- z x) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4.1e+48) {
tmp = y / (z / (z - x));
} else if (y <= 3.4e+51) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = 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 <= (-4.1d+48)) then
tmp = y / (z / (z - x))
else if (y <= 3.4d+51) then
tmp = (x + (y * (z - x))) / z
else
tmp = y * ((z - x) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4.1e+48) {
tmp = y / (z / (z - x));
} else if (y <= 3.4e+51) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y * ((z - x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4.1e+48: tmp = y / (z / (z - x)) elif y <= 3.4e+51: tmp = (x + (y * (z - x))) / z else: tmp = y * ((z - x) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4.1e+48) tmp = Float64(y / Float64(z / Float64(z - x))); elseif (y <= 3.4e+51) tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); else tmp = Float64(y * Float64(Float64(z - x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4.1e+48) tmp = y / (z / (z - x)); elseif (y <= 3.4e+51) tmp = (x + (y * (z - x))) / z; else tmp = y * ((z - x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4.1e+48], N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.4e+51], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.1 \cdot 10^{+48}:\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+51}:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\end{array}
\end{array}
if y < -4.1000000000000003e48Initial program 59.9%
Taylor expanded in y around inf 59.9%
associate-/l*99.8%
Simplified99.8%
clear-num99.9%
associate-/r/99.6%
Applied egg-rr99.6%
associate-*r*85.9%
div-inv86.1%
associate-/r/100.0%
Applied egg-rr100.0%
if -4.1000000000000003e48 < y < 3.39999999999999984e51Initial program 99.9%
if 3.39999999999999984e51 < y Initial program 61.0%
Taylor expanded in y around inf 61.0%
associate-/l*100.0%
Simplified100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.6) (not (<= y 1.0))) (/ y (/ z (- z x))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.6) || !(y <= 1.0)) {
tmp = y / (z / (z - x));
} 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.6d0)) .or. (.not. (y <= 1.0d0))) then
tmp = y / (z / (z - x))
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.6) || !(y <= 1.0)) {
tmp = y / (z / (z - x));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.6) or not (y <= 1.0): tmp = y / (z / (z - x)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.6) || !(y <= 1.0)) tmp = Float64(y / Float64(z / Float64(z - x))); else tmp = Float64(y + Float64(x / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.6) || ~((y <= 1.0))) tmp = y / (z / (z - x)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.6], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(y / N[(z / N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;\frac{y}{\frac{z}{z - x}}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -6.5999999999999996 or 1 < y Initial program 69.4%
Taylor expanded in y around inf 68.7%
associate-/l*99.2%
Simplified99.2%
clear-num99.2%
associate-/r/99.0%
Applied egg-rr99.0%
associate-*r*88.1%
div-inv88.3%
associate-/r/99.2%
Applied egg-rr99.2%
if -6.5999999999999996 < y < 1Initial program 99.9%
Taylor expanded in y around 0 91.2%
Taylor expanded in x around 0 98.9%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.6) (not (<= y 1.0))) (* y (/ (- z x) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.6) || !(y <= 1.0)) {
tmp = y * ((z - 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.6d0)) .or. (.not. (y <= 1.0d0))) then
tmp = y * ((z - 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.6) || !(y <= 1.0)) {
tmp = y * ((z - x) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.6) or not (y <= 1.0): tmp = y * ((z - x) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.6) || !(y <= 1.0)) tmp = Float64(y * Float64(Float64(z - 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 <= -6.6) || ~((y <= 1.0))) tmp = y * ((z - x) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.6], N[Not[LessEqual[y, 1.0]], $MachinePrecision]], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.6 \lor \neg \left(y \leq 1\right):\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -6.5999999999999996 or 1 < y Initial program 69.4%
Taylor expanded in y around inf 68.7%
associate-/l*99.2%
Simplified99.2%
if -6.5999999999999996 < y < 1Initial program 99.9%
Taylor expanded in y around 0 91.2%
Taylor expanded in x around 0 98.9%
Final simplification99.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.35e+139) (not (<= x 1.7e+157))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.35e+139) || !(x <= 1.7e+157)) {
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 <= (-1.35d+139)) .or. (.not. (x <= 1.7d+157))) 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 <= -1.35e+139) || !(x <= 1.7e+157)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.35e+139) or not (x <= 1.7e+157): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.35e+139) || !(x <= 1.7e+157)) 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 <= -1.35e+139) || ~((x <= 1.7e+157))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.35e+139], N[Not[LessEqual[x, 1.7e+157]], $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 -1.35 \cdot 10^{+139} \lor \neg \left(x \leq 1.7 \cdot 10^{+157}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -1.3499999999999999e139 or 1.6999999999999999e157 < x Initial program 94.4%
Taylor expanded in x around inf 89.0%
associate-/l*93.2%
mul-1-neg93.2%
unsub-neg93.2%
Simplified93.2%
if -1.3499999999999999e139 < x < 1.6999999999999999e157Initial program 82.4%
Taylor expanded in y around 0 98.9%
Taylor expanded in x around 0 88.4%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (or (<= z 7.6e-292) (not (<= z 1.4e-228))) (+ y (/ x z)) (/ (* y x) (- z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 7.6e-292) || !(z <= 1.4e-228)) {
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 ((z <= 7.6d-292) .or. (.not. (z <= 1.4d-228))) 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 ((z <= 7.6e-292) || !(z <= 1.4e-228)) {
tmp = y + (x / z);
} else {
tmp = (y * x) / -z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 7.6e-292) or not (z <= 1.4e-228): tmp = y + (x / z) else: tmp = (y * x) / -z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 7.6e-292) || !(z <= 1.4e-228)) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(y * x) / Float64(-z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= 7.6e-292) || ~((z <= 1.4e-228))) tmp = y + (x / z); else tmp = (y * x) / -z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 7.6e-292], N[Not[LessEqual[z, 1.4e-228]], $MachinePrecision]], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(y * x), $MachinePrecision] / (-z)), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 7.6 \cdot 10^{-292} \lor \neg \left(z \leq 1.4 \cdot 10^{-228}\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{y \cdot x}{-z}\\
\end{array}
\end{array}
if z < 7.60000000000000039e-292 or 1.4000000000000001e-228 < z Initial program 84.7%
Taylor expanded in y around 0 93.3%
Taylor expanded in x around 0 85.0%
if 7.60000000000000039e-292 < z < 1.4000000000000001e-228Initial program 99.9%
Taylor expanded in x around inf 99.5%
associate-/l*81.3%
mul-1-neg81.3%
unsub-neg81.3%
Simplified81.3%
Taylor expanded in y around inf 55.2%
neg-mul-155.2%
distribute-frac-neg255.2%
Simplified55.2%
Taylor expanded in x around 0 73.3%
mul-1-neg73.3%
distribute-frac-neg273.3%
*-commutative73.3%
Simplified73.3%
Final simplification84.3%
(FPCore (x y z) :precision binary64 (if (or (<= z 9.5e-292) (not (<= z 9.6e-229))) (+ y (/ x z)) (* y (/ x (- z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= 9.5e-292) || !(z <= 9.6e-229)) {
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 ((z <= 9.5d-292) .or. (.not. (z <= 9.6d-229))) 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 ((z <= 9.5e-292) || !(z <= 9.6e-229)) {
tmp = y + (x / z);
} else {
tmp = y * (x / -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= 9.5e-292) or not (z <= 9.6e-229): tmp = y + (x / z) else: tmp = y * (x / -z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= 9.5e-292) || !(z <= 9.6e-229)) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y * Float64(x / Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= 9.5e-292) || ~((z <= 9.6e-229))) tmp = y + (x / z); else tmp = y * (x / -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, 9.5e-292], N[Not[LessEqual[z, 9.6e-229]], $MachinePrecision]], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y * N[(x / (-z)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq 9.5 \cdot 10^{-292} \lor \neg \left(z \leq 9.6 \cdot 10^{-229}\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{-z}\\
\end{array}
\end{array}
if z < 9.4999999999999994e-292 or 9.6000000000000001e-229 < z Initial program 84.7%
Taylor expanded in y around 0 93.3%
Taylor expanded in x around 0 85.0%
if 9.4999999999999994e-292 < z < 9.6000000000000001e-229Initial program 99.9%
Taylor expanded in y around inf 74.0%
associate-/l*73.9%
Simplified73.9%
Taylor expanded in z around 0 73.2%
mul-1-neg73.2%
distribute-frac-neg273.2%
Simplified73.2%
Final simplification84.3%
(FPCore (x y z) :precision binary64 (if (<= y -1.38e-21) y (if (<= y 7.5e-7) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.38e-21) {
tmp = y;
} else if (y <= 7.5e-7) {
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 <= (-1.38d-21)) then
tmp = y
else if (y <= 7.5d-7) 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 <= -1.38e-21) {
tmp = y;
} else if (y <= 7.5e-7) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.38e-21: tmp = y elif y <= 7.5e-7: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.38e-21) tmp = y; elseif (y <= 7.5e-7) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.38e-21) tmp = y; elseif (y <= 7.5e-7) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.38e-21], y, If[LessEqual[y, 7.5e-7], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.38 \cdot 10^{-21}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 7.5 \cdot 10^{-7}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -1.38e-21 or 7.5000000000000002e-7 < y Initial program 71.1%
Taylor expanded in x around 0 61.3%
if -1.38e-21 < y < 7.5000000000000002e-7Initial program 99.9%
Taylor expanded in y around 0 77.0%
(FPCore (x y z) :precision binary64 (+ y (/ x z)))
double code(double x, double y, double z) {
return y + (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 = y + (x / z)
end function
public static double code(double x, double y, double z) {
return y + (x / z);
}
def code(x, y, z): return y + (x / z)
function code(x, y, z) return Float64(y + Float64(x / z)) end
function tmp = code(x, y, z) tmp = y + (x / z); end
code[x_, y_, z_] := N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
y + \frac{x}{z}
\end{array}
Initial program 85.6%
Taylor expanded in y around 0 91.7%
Taylor expanded in x around 0 81.9%
(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 85.6%
Taylor expanded in x around 0 42.2%
(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 2024108
(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))