
(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 12 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 -4e-223) (+ (/ x z) (* y (- 1.0 (/ x z)))) (if (<= y 0.00078) (/ (+ x (* y (- z x))) z) (- y (* y (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4e-223) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else if (y <= 0.00078) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y - (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-223)) then
tmp = (x / z) + (y * (1.0d0 - (x / z)))
else if (y <= 0.00078d0) then
tmp = (x + (y * (z - x))) / z
else
tmp = y - (y * (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4e-223) {
tmp = (x / z) + (y * (1.0 - (x / z)));
} else if (y <= 0.00078) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y - (y * (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4e-223: tmp = (x / z) + (y * (1.0 - (x / z))) elif y <= 0.00078: tmp = (x + (y * (z - x))) / z else: tmp = y - (y * (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4e-223) tmp = Float64(Float64(x / z) + Float64(y * Float64(1.0 - Float64(x / z)))); elseif (y <= 0.00078) tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); else tmp = Float64(y - Float64(y * Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4e-223) tmp = (x / z) + (y * (1.0 - (x / z))); elseif (y <= 0.00078) tmp = (x + (y * (z - x))) / z; else tmp = y - (y * (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4e-223], N[(N[(x / z), $MachinePrecision] + N[(y * N[(1.0 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.00078], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{-223}:\\
\;\;\;\;\frac{x}{z} + y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{elif}\;y \leq 0.00078:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -3.9999999999999999e-223Initial program 80.6%
Taylor expanded in y around 0 99.9%
if -3.9999999999999999e-223 < y < 7.79999999999999986e-4Initial program 100.0%
if 7.79999999999999986e-4 < y Initial program 81.2%
Taylor expanded in x around 0 95.7%
Taylor expanded in y around inf 91.8%
associate-*r/95.7%
neg-mul-195.7%
distribute-rgt-neg-in95.7%
distribute-frac-neg295.7%
Simplified95.7%
*-commutative95.7%
add-sqr-sqrt46.3%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-unprod25.2%
add-sqr-sqrt45.7%
cancel-sign-sub45.7%
distribute-frac-neg245.7%
associate-*l/43.3%
*-commutative43.3%
add-sqr-sqrt20.4%
sqrt-unprod62.8%
sqr-neg62.8%
sqrt-unprod46.7%
add-sqr-sqrt91.8%
associate-*l/100.0%
*-commutative100.0%
Applied egg-rr100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= y 1.7e+26)
(+ y (/ x z))
(if (<= y 3.7e+112)
(* y (/ (- x) z))
(if (<= y 8.2e+275) (* z (/ y z)) (* x (- (/ y z)))))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.7e+26) {
tmp = y + (x / z);
} else if (y <= 3.7e+112) {
tmp = y * (-x / z);
} else if (y <= 8.2e+275) {
tmp = z * (y / z);
} else {
tmp = x * -(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 <= 1.7d+26) then
tmp = y + (x / z)
else if (y <= 3.7d+112) then
tmp = y * (-x / z)
else if (y <= 8.2d+275) then
tmp = z * (y / z)
else
tmp = x * -(y / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= 1.7e+26) {
tmp = y + (x / z);
} else if (y <= 3.7e+112) {
tmp = y * (-x / z);
} else if (y <= 8.2e+275) {
tmp = z * (y / z);
} else {
tmp = x * -(y / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.7e+26: tmp = y + (x / z) elif y <= 3.7e+112: tmp = y * (-x / z) elif y <= 8.2e+275: tmp = z * (y / z) else: tmp = x * -(y / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.7e+26) tmp = Float64(y + Float64(x / z)); elseif (y <= 3.7e+112) tmp = Float64(y * Float64(Float64(-x) / z)); elseif (y <= 8.2e+275) tmp = Float64(z * Float64(y / z)); else tmp = Float64(x * Float64(-Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.7e+26) tmp = y + (x / z); elseif (y <= 3.7e+112) tmp = y * (-x / z); elseif (y <= 8.2e+275) tmp = z * (y / z); else tmp = x * -(y / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.7e+26], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.7e+112], N[(y * N[((-x) / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 8.2e+275], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x * (-N[(y / z), $MachinePrecision])), $MachinePrecision]]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.7 \cdot 10^{+26}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+112}:\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\mathbf{elif}\;y \leq 8.2 \cdot 10^{+275}:\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \left(-\frac{y}{z}\right)\\
\end{array}
\end{array}
if y < 1.7000000000000001e26Initial program 88.6%
Taylor expanded in z around inf 77.2%
Taylor expanded in x around 0 87.6%
+-commutative87.6%
Simplified87.6%
if 1.7000000000000001e26 < y < 3.70000000000000004e112Initial program 95.1%
Taylor expanded in x around inf 64.6%
associate-/l*64.3%
mul-1-neg64.3%
unsub-neg64.3%
Simplified64.3%
Taylor expanded in y around inf 64.3%
neg-mul-164.3%
Simplified64.3%
distribute-frac-neg64.3%
distribute-frac-neg264.3%
associate-*r/64.6%
distribute-frac-neg264.6%
associate-*l/69.0%
*-commutative69.0%
Applied egg-rr69.0%
if 3.70000000000000004e112 < y < 8.1999999999999994e275Initial program 70.8%
Taylor expanded in z around inf 32.7%
Taylor expanded in x around 0 33.4%
*-commutative33.4%
Simplified33.4%
associate-/l*64.4%
*-commutative64.4%
Applied egg-rr64.4%
if 8.1999999999999994e275 < y Initial program 75.9%
Taylor expanded in x around inf 65.5%
associate-/l*73.2%
mul-1-neg73.2%
unsub-neg73.2%
Simplified73.2%
Taylor expanded in y around inf 73.2%
neg-mul-173.2%
Simplified73.2%
Final simplification82.6%
(FPCore (x y z) :precision binary64 (if (<= y -4e+14) (* y (/ (- z x) z)) (if (<= y 0.00078) (/ (+ x (* y (- z x))) z) (- y (* y (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -4e+14) {
tmp = y * ((z - x) / z);
} else if (y <= 0.00078) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y - (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+14)) then
tmp = y * ((z - x) / z)
else if (y <= 0.00078d0) then
tmp = (x + (y * (z - x))) / z
else
tmp = y - (y * (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -4e+14) {
tmp = y * ((z - x) / z);
} else if (y <= 0.00078) {
tmp = (x + (y * (z - x))) / z;
} else {
tmp = y - (y * (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -4e+14: tmp = y * ((z - x) / z) elif y <= 0.00078: tmp = (x + (y * (z - x))) / z else: tmp = y - (y * (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -4e+14) tmp = Float64(y * Float64(Float64(z - x) / z)); elseif (y <= 0.00078) tmp = Float64(Float64(x + Float64(y * Float64(z - x))) / z); else tmp = Float64(y - Float64(y * Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -4e+14) tmp = y * ((z - x) / z); elseif (y <= 0.00078) tmp = (x + (y * (z - x))) / z; else tmp = y - (y * (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -4e+14], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.00078], N[(N[(x + N[(y * N[(z - x), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4 \cdot 10^{+14}:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\mathbf{elif}\;y \leq 0.00078:\\
\;\;\;\;\frac{x + y \cdot \left(z - x\right)}{z}\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -4e14Initial program 66.9%
Taylor expanded in y around inf 66.9%
associate-/l*99.9%
Simplified99.9%
if -4e14 < y < 7.79999999999999986e-4Initial program 99.9%
if 7.79999999999999986e-4 < y Initial program 81.2%
Taylor expanded in x around 0 95.7%
Taylor expanded in y around inf 91.8%
associate-*r/95.7%
neg-mul-195.7%
distribute-rgt-neg-in95.7%
distribute-frac-neg295.7%
Simplified95.7%
*-commutative95.7%
add-sqr-sqrt46.3%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-unprod25.2%
add-sqr-sqrt45.7%
cancel-sign-sub45.7%
distribute-frac-neg245.7%
associate-*l/43.3%
*-commutative43.3%
add-sqr-sqrt20.4%
sqrt-unprod62.8%
sqr-neg62.8%
sqrt-unprod46.7%
add-sqr-sqrt91.8%
associate-*l/100.0%
*-commutative100.0%
Applied egg-rr100.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -370000000000.0) (not (<= y 0.00078))) (* y (/ (- z x) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -370000000000.0) || !(y <= 0.00078)) {
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 <= (-370000000000.0d0)) .or. (.not. (y <= 0.00078d0))) 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 <= -370000000000.0) || !(y <= 0.00078)) {
tmp = y * ((z - x) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -370000000000.0) or not (y <= 0.00078): tmp = y * ((z - x) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -370000000000.0) || !(y <= 0.00078)) 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 <= -370000000000.0) || ~((y <= 0.00078))) tmp = y * ((z - x) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -370000000000.0], N[Not[LessEqual[y, 0.00078]], $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 -370000000000 \lor \neg \left(y \leq 0.00078\right):\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -3.7e11 or 7.79999999999999986e-4 < y Initial program 74.2%
Taylor expanded in y around inf 74.2%
associate-/l*99.9%
Simplified99.9%
if -3.7e11 < y < 7.79999999999999986e-4Initial program 99.9%
Taylor expanded in z around inf 99.1%
Taylor expanded in x around 0 99.1%
+-commutative99.1%
Simplified99.1%
Final simplification99.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.65e+101) (not (<= x 2.05e-19))) (* x (/ (- 1.0 y) z)) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.65e+101) || !(x <= 2.05e-19)) {
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 <= (-2.65d+101)) .or. (.not. (x <= 2.05d-19))) 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 <= -2.65e+101) || !(x <= 2.05e-19)) {
tmp = x * ((1.0 - y) / z);
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.65e+101) or not (x <= 2.05e-19): tmp = x * ((1.0 - y) / z) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.65e+101) || !(x <= 2.05e-19)) 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 <= -2.65e+101) || ~((x <= 2.05e-19))) tmp = x * ((1.0 - y) / z); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.65e+101], N[Not[LessEqual[x, 2.05e-19]], $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 -2.65 \cdot 10^{+101} \lor \neg \left(x \leq 2.05 \cdot 10^{-19}\right):\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if x < -2.65000000000000003e101 or 2.04999999999999993e-19 < x Initial program 87.6%
Taylor expanded in x around inf 82.6%
associate-/l*85.7%
mul-1-neg85.7%
unsub-neg85.7%
Simplified85.7%
if -2.65000000000000003e101 < x < 2.04999999999999993e-19Initial program 85.3%
Taylor expanded in z around inf 72.1%
Taylor expanded in x around 0 86.7%
+-commutative86.7%
Simplified86.7%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (<= y -370000000000.0) (* y (/ (- z x) z)) (if (<= y 0.00078) (+ y (/ x z)) (- y (* y (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -370000000000.0) {
tmp = y * ((z - x) / z);
} else if (y <= 0.00078) {
tmp = y + (x / z);
} else {
tmp = y - (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 <= (-370000000000.0d0)) then
tmp = y * ((z - x) / z)
else if (y <= 0.00078d0) then
tmp = y + (x / z)
else
tmp = y - (y * (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -370000000000.0) {
tmp = y * ((z - x) / z);
} else if (y <= 0.00078) {
tmp = y + (x / z);
} else {
tmp = y - (y * (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -370000000000.0: tmp = y * ((z - x) / z) elif y <= 0.00078: tmp = y + (x / z) else: tmp = y - (y * (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -370000000000.0) tmp = Float64(y * Float64(Float64(z - x) / z)); elseif (y <= 0.00078) tmp = Float64(y + Float64(x / z)); else tmp = Float64(y - Float64(y * Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -370000000000.0) tmp = y * ((z - x) / z); elseif (y <= 0.00078) tmp = y + (x / z); else tmp = y - (y * (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -370000000000.0], N[(y * N[(N[(z - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 0.00078], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(y - N[(y * N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -370000000000:\\
\;\;\;\;y \cdot \frac{z - x}{z}\\
\mathbf{elif}\;y \leq 0.00078:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y - y \cdot \frac{x}{z}\\
\end{array}
\end{array}
if y < -3.7e11Initial program 66.9%
Taylor expanded in y around inf 66.9%
associate-/l*99.9%
Simplified99.9%
if -3.7e11 < y < 7.79999999999999986e-4Initial program 99.9%
Taylor expanded in z around inf 99.1%
Taylor expanded in x around 0 99.1%
+-commutative99.1%
Simplified99.1%
if 7.79999999999999986e-4 < y Initial program 81.2%
Taylor expanded in x around 0 95.7%
Taylor expanded in y around inf 91.8%
associate-*r/95.7%
neg-mul-195.7%
distribute-rgt-neg-in95.7%
distribute-frac-neg295.7%
Simplified95.7%
*-commutative95.7%
add-sqr-sqrt46.3%
sqrt-unprod65.0%
sqr-neg65.0%
sqrt-unprod25.2%
add-sqr-sqrt45.7%
cancel-sign-sub45.7%
distribute-frac-neg245.7%
associate-*l/43.3%
*-commutative43.3%
add-sqr-sqrt20.4%
sqrt-unprod62.8%
sqr-neg62.8%
sqrt-unprod46.7%
add-sqr-sqrt91.8%
associate-*l/100.0%
*-commutative100.0%
Applied egg-rr100.0%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (if (<= y 5.2e-286) (+ (/ 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 <= 5.2e-286) {
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 <= 5.2d-286) 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 <= 5.2e-286) {
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 <= 5.2e-286: 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 <= 5.2e-286) 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 <= 5.2e-286) 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, 5.2e-286], 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 5.2 \cdot 10^{-286}:\\
\;\;\;\;\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 < 5.1999999999999999e-286Initial program 83.9%
Taylor expanded in y around 0 100.0%
if 5.1999999999999999e-286 < y Initial program 89.2%
Taylor expanded in x around 0 97.5%
Final simplification98.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -3e-106) (not (<= y 4.8e-21))) (* z (/ y z)) (/ x z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3e-106) || !(y <= 4.8e-21)) {
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 <= (-3d-106)) .or. (.not. (y <= 4.8d-21))) 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 <= -3e-106) || !(y <= 4.8e-21)) {
tmp = z * (y / z);
} else {
tmp = x / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3e-106) or not (y <= 4.8e-21): tmp = z * (y / z) else: tmp = x / z return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3e-106) || !(y <= 4.8e-21)) 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 <= -3e-106) || ~((y <= 4.8e-21))) tmp = z * (y / z); else tmp = x / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3e-106], N[Not[LessEqual[y, 4.8e-21]], $MachinePrecision]], N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(x / z), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{-106} \lor \neg \left(y \leq 4.8 \cdot 10^{-21}\right):\\
\;\;\;\;z \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{x}{z}\\
\end{array}
\end{array}
if y < -3.00000000000000019e-106 or 4.7999999999999999e-21 < y Initial program 78.5%
Taylor expanded in z around inf 46.4%
Taylor expanded in x around 0 36.8%
*-commutative36.8%
Simplified36.8%
associate-/l*55.1%
*-commutative55.1%
Applied egg-rr55.1%
if -3.00000000000000019e-106 < y < 4.7999999999999999e-21Initial program 100.0%
Taylor expanded in y around 0 74.2%
Final simplification62.1%
(FPCore (x y z) :precision binary64 (if (<= y -3e-106) y (if (<= y 1.4e-19) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3e-106) {
tmp = y;
} else if (y <= 1.4e-19) {
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 <= (-3d-106)) then
tmp = y
else if (y <= 1.4d-19) 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 <= -3e-106) {
tmp = y;
} else if (y <= 1.4e-19) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3e-106: tmp = y elif y <= 1.4e-19: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3e-106) tmp = y; elseif (y <= 1.4e-19) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3e-106) tmp = y; elseif (y <= 1.4e-19) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3e-106], y, If[LessEqual[y, 1.4e-19], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3 \cdot 10^{-106}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-19}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if y < -3.00000000000000019e-106 or 1.40000000000000001e-19 < y Initial program 78.5%
Taylor expanded in x around 0 54.3%
if -3.00000000000000019e-106 < y < 1.40000000000000001e-19Initial program 100.0%
Taylor expanded in y around 0 74.2%
(FPCore (x y z) :precision binary64 (if (<= y 1.25e+31) (+ y (/ x z)) (* y (/ (- x) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.25e+31) {
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.25d+31) 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.25e+31) {
tmp = y + (x / z);
} else {
tmp = y * (-x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.25e+31: tmp = y + (x / z) else: tmp = y * (-x / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.25e+31) 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 <= 1.25e+31) tmp = y + (x / z); else tmp = y * (-x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.25e+31], 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.25 \cdot 10^{+31}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{-x}{z}\\
\end{array}
\end{array}
if y < 1.25000000000000007e31Initial program 88.6%
Taylor expanded in z around inf 77.2%
Taylor expanded in x around 0 87.6%
+-commutative87.6%
Simplified87.6%
if 1.25000000000000007e31 < y Initial program 79.4%
Taylor expanded in x around inf 50.6%
associate-/l*53.3%
mul-1-neg53.3%
unsub-neg53.3%
Simplified53.3%
Taylor expanded in y around inf 53.3%
neg-mul-153.3%
Simplified53.3%
distribute-frac-neg53.3%
distribute-frac-neg253.3%
associate-*r/50.6%
distribute-frac-neg250.6%
associate-*l/54.7%
*-commutative54.7%
Applied egg-rr54.7%
Final simplification79.5%
(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 86.4%
Taylor expanded in z around inf 66.1%
Taylor expanded in x around 0 77.2%
+-commutative77.2%
Simplified77.2%
Final simplification77.2%
(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 86.4%
Taylor expanded in x around 0 44.6%
(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 2024170
(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))