
(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 -4.2e+46) (not (<= y 1850000000000.0))) (* y (- 1.0 (/ x z))) (/ (+ x (* y (- z x))) z)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.2e+46) || !(y <= 1850000000000.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 <= (-4.2d+46)) .or. (.not. (y <= 1850000000000.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 <= -4.2e+46) || !(y <= 1850000000000.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 <= -4.2e+46) or not (y <= 1850000000000.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 <= -4.2e+46) || !(y <= 1850000000000.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 <= -4.2e+46) || ~((y <= 1850000000000.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, -4.2e+46], N[Not[LessEqual[y, 1850000000000.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 -4.2 \cdot 10^{+46} \lor \neg \left(y \leq 1850000000000\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.2e46 or 1.85e12 < y Initial program 72.5%
Taylor expanded in y around inf 72.5%
associate-/l*99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
if -4.2e46 < y < 1.85e12Initial program 99.9%
Final simplification99.9%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ y z))))
(if (<= y -1.75e-51)
t_0
(if (<= y 7e-154)
(/ x z)
(if (<= y 2.3e-125) y (if (<= y 2.35e-43) (/ x z) t_0))))))
double code(double x, double y, double z) {
double t_0 = z * (y / z);
double tmp;
if (y <= -1.75e-51) {
tmp = t_0;
} else if (y <= 7e-154) {
tmp = x / z;
} else if (y <= 2.3e-125) {
tmp = y;
} else if (y <= 2.35e-43) {
tmp = x / z;
} 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 = z * (y / z)
if (y <= (-1.75d-51)) then
tmp = t_0
else if (y <= 7d-154) then
tmp = x / z
else if (y <= 2.3d-125) then
tmp = y
else if (y <= 2.35d-43) then
tmp = x / z
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (y / z);
double tmp;
if (y <= -1.75e-51) {
tmp = t_0;
} else if (y <= 7e-154) {
tmp = x / z;
} else if (y <= 2.3e-125) {
tmp = y;
} else if (y <= 2.35e-43) {
tmp = x / z;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (y / z) tmp = 0 if y <= -1.75e-51: tmp = t_0 elif y <= 7e-154: tmp = x / z elif y <= 2.3e-125: tmp = y elif y <= 2.35e-43: tmp = x / z else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(y / z)) tmp = 0.0 if (y <= -1.75e-51) tmp = t_0; elseif (y <= 7e-154) tmp = Float64(x / z); elseif (y <= 2.3e-125) tmp = y; elseif (y <= 2.35e-43) tmp = Float64(x / z); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (y / z); tmp = 0.0; if (y <= -1.75e-51) tmp = t_0; elseif (y <= 7e-154) tmp = x / z; elseif (y <= 2.3e-125) tmp = y; elseif (y <= 2.35e-43) tmp = x / z; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1.75e-51], t$95$0, If[LessEqual[y, 7e-154], N[(x / z), $MachinePrecision], If[LessEqual[y, 2.3e-125], y, If[LessEqual[y, 2.35e-43], N[(x / z), $MachinePrecision], t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{y}{z}\\
\mathbf{if}\;y \leq -1.75 \cdot 10^{-51}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 7 \cdot 10^{-154}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{elif}\;y \leq 2.3 \cdot 10^{-125}:\\
\;\;\;\;y\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{-43}:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.7499999999999999e-51 or 2.35e-43 < y Initial program 78.0%
Taylor expanded in z around inf 46.0%
Taylor expanded in x around 0 33.1%
*-commutative33.1%
Simplified33.1%
associate-/l*59.7%
*-commutative59.7%
Applied egg-rr59.7%
if -1.7499999999999999e-51 < y < 7.0000000000000001e-154 or 2.2999999999999999e-125 < y < 2.35e-43Initial program 99.9%
Taylor expanded in y around 0 78.9%
if 7.0000000000000001e-154 < y < 2.2999999999999999e-125Initial program 100.0%
Taylor expanded in x around 0 86.0%
Final simplification68.1%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.65e-58) (not (<= z 2.7e-6))) (+ y (/ x z)) (* x (/ (- 1.0 y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.65e-58) || !(z <= 2.7e-6)) {
tmp = y + (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 ((z <= (-2.65d-58)) .or. (.not. (z <= 2.7d-6))) then
tmp = y + (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 ((z <= -2.65e-58) || !(z <= 2.7e-6)) {
tmp = y + (x / z);
} else {
tmp = x * ((1.0 - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.65e-58) or not (z <= 2.7e-6): tmp = y + (x / z) else: tmp = x * ((1.0 - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.65e-58) || !(z <= 2.7e-6)) tmp = Float64(y + Float64(x / z)); else tmp = Float64(x * Float64(Float64(1.0 - y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.65e-58) || ~((z <= 2.7e-6))) tmp = y + (x / z); else tmp = x * ((1.0 - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.65e-58], N[Not[LessEqual[z, 2.7e-6]], $MachinePrecision]], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(N[(1.0 - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.65 \cdot 10^{-58} \lor \neg \left(z \leq 2.7 \cdot 10^{-6}\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{1 - y}{z}\\
\end{array}
\end{array}
if z < -2.6500000000000002e-58 or 2.69999999999999998e-6 < z Initial program 77.8%
Taylor expanded in z around inf 71.4%
Taylor expanded in x around 0 89.9%
+-commutative89.9%
Simplified89.9%
if -2.6500000000000002e-58 < z < 2.69999999999999998e-6Initial program 99.9%
Taylor expanded in x around inf 91.7%
associate-/l*87.7%
mul-1-neg87.7%
unsub-neg87.7%
Simplified87.7%
Final simplification89.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -480000.0) (not (<= y 7.6e-6))) (* y (- 1.0 (/ x z))) (+ y (/ x z))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -480000.0) || !(y <= 7.6e-6)) {
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 <= (-480000.0d0)) .or. (.not. (y <= 7.6d-6))) 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 <= -480000.0) || !(y <= 7.6e-6)) {
tmp = y * (1.0 - (x / z));
} else {
tmp = y + (x / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -480000.0) or not (y <= 7.6e-6): tmp = y * (1.0 - (x / z)) else: tmp = y + (x / z) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -480000.0) || !(y <= 7.6e-6)) 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 <= -480000.0) || ~((y <= 7.6e-6))) tmp = y * (1.0 - (x / z)); else tmp = y + (x / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -480000.0], N[Not[LessEqual[y, 7.6e-6]], $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 -480000 \lor \neg \left(y \leq 7.6 \cdot 10^{-6}\right):\\
\;\;\;\;y \cdot \left(1 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;y + \frac{x}{z}\\
\end{array}
\end{array}
if y < -4.8e5 or 7.6000000000000001e-6 < y Initial program 74.9%
Taylor expanded in y around inf 74.7%
associate-/l*99.7%
div-sub99.7%
*-inverses99.7%
Simplified99.7%
if -4.8e5 < y < 7.6000000000000001e-6Initial program 99.9%
Taylor expanded in z around inf 99.1%
Taylor expanded in x around 0 99.2%
+-commutative99.2%
Simplified99.2%
Final simplification99.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.5e-140) (not (<= z -1.16e-200))) (+ y (/ x z)) (* y (/ x (- z)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.5e-140) || !(z <= -1.16e-200)) {
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 <= (-8.5d-140)) .or. (.not. (z <= (-1.16d-200)))) 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 <= -8.5e-140) || !(z <= -1.16e-200)) {
tmp = y + (x / z);
} else {
tmp = y * (x / -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8.5e-140) or not (z <= -1.16e-200): tmp = y + (x / z) else: tmp = y * (x / -z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8.5e-140) || !(z <= -1.16e-200)) 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 <= -8.5e-140) || ~((z <= -1.16e-200))) tmp = y + (x / z); else tmp = y * (x / -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.5e-140], N[Not[LessEqual[z, -1.16e-200]], $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 -8.5 \cdot 10^{-140} \lor \neg \left(z \leq -1.16 \cdot 10^{-200}\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y \cdot \frac{x}{-z}\\
\end{array}
\end{array}
if z < -8.49999999999999997e-140 or -1.1600000000000001e-200 < z Initial program 86.8%
Taylor expanded in z around inf 71.2%
Taylor expanded in x around 0 82.2%
+-commutative82.2%
Simplified82.2%
if -8.49999999999999997e-140 < z < -1.1600000000000001e-200Initial program 100.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
mul-1-neg100.0%
distribute-rgt-neg-out100.0%
Simplified100.0%
Taylor expanded in x around 0 100.0%
mul-1-neg100.0%
*-commutative100.0%
associate-*r/99.9%
distribute-rgt-neg-in99.9%
distribute-neg-frac299.9%
Simplified99.9%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (or (<= z -8.5e-140) (not (<= z -2.3e-200))) (+ y (/ x z)) (/ (- (* y x)) z)))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8.5e-140) || !(z <= -2.3e-200)) {
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 <= (-8.5d-140)) .or. (.not. (z <= (-2.3d-200)))) 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 <= -8.5e-140) || !(z <= -2.3e-200)) {
tmp = y + (x / z);
} else {
tmp = -(y * x) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8.5e-140) or not (z <= -2.3e-200): tmp = y + (x / z) else: tmp = -(y * x) / z return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8.5e-140) || !(z <= -2.3e-200)) tmp = Float64(y + Float64(x / z)); else tmp = Float64(Float64(-Float64(y * x)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -8.5e-140) || ~((z <= -2.3e-200))) tmp = y + (x / z); else tmp = -(y * x) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8.5e-140], N[Not[LessEqual[z, -2.3e-200]], $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 -8.5 \cdot 10^{-140} \lor \neg \left(z \leq -2.3 \cdot 10^{-200}\right):\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;\frac{-y \cdot x}{z}\\
\end{array}
\end{array}
if z < -8.49999999999999997e-140 or -2.30000000000000007e-200 < z Initial program 86.8%
Taylor expanded in z around inf 71.2%
Taylor expanded in x around 0 82.2%
+-commutative82.2%
Simplified82.2%
if -8.49999999999999997e-140 < z < -2.30000000000000007e-200Initial program 100.0%
Taylor expanded in x around inf 100.0%
mul-1-neg100.0%
unsub-neg100.0%
Simplified100.0%
Taylor expanded in y around inf 100.0%
mul-1-neg100.0%
distribute-rgt-neg-out100.0%
Simplified100.0%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (<= y -2e+52) (* y (- 1.0 (/ x z))) (+ y (* x (- (/ 1.0 z) (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+52) {
tmp = 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 <= (-2d+52)) then
tmp = 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 <= -2e+52) {
tmp = 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 <= -2e+52: tmp = 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 <= -2e+52) tmp = 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 <= -2e+52) tmp = 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, -2e+52], N[(y * N[(1.0 - N[(x / z), $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 -2 \cdot 10^{+52}:\\
\;\;\;\;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 < -2e52Initial program 72.7%
Taylor expanded in y around inf 72.7%
associate-/l*99.9%
div-sub99.9%
*-inverses99.9%
Simplified99.9%
if -2e52 < y Initial program 92.5%
Taylor expanded in x around 0 98.8%
Final simplification99.1%
(FPCore (x y z) :precision binary64 (if (<= z -1.4e-6) y (if (<= z 38000000000.0) (/ x z) y)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.4e-6) {
tmp = y;
} else if (z <= 38000000000.0) {
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 (z <= (-1.4d-6)) then
tmp = y
else if (z <= 38000000000.0d0) 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 (z <= -1.4e-6) {
tmp = y;
} else if (z <= 38000000000.0) {
tmp = x / z;
} else {
tmp = y;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.4e-6: tmp = y elif z <= 38000000000.0: tmp = x / z else: tmp = y return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.4e-6) tmp = y; elseif (z <= 38000000000.0) tmp = Float64(x / z); else tmp = y; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.4e-6) tmp = y; elseif (z <= 38000000000.0) tmp = x / z; else tmp = y; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.4e-6], y, If[LessEqual[z, 38000000000.0], N[(x / z), $MachinePrecision], y]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.4 \cdot 10^{-6}:\\
\;\;\;\;y\\
\mathbf{elif}\;z \leq 38000000000:\\
\;\;\;\;\frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;y\\
\end{array}
\end{array}
if z < -1.39999999999999994e-6 or 3.8e10 < z Initial program 76.1%
Taylor expanded in x around 0 67.7%
if -1.39999999999999994e-6 < z < 3.8e10Initial program 99.9%
Taylor expanded in y around 0 57.7%
Final simplification63.0%
(FPCore (x y z) :precision binary64 (if (<= y 1.6e+208) (+ y (/ x z)) (* x (/ y (- z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= 1.6e+208) {
tmp = y + (x / 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.6d+208) then
tmp = y + (x / 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.6e+208) {
tmp = y + (x / z);
} else {
tmp = x * (y / -z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= 1.6e+208: tmp = y + (x / z) else: tmp = x * (y / -z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= 1.6e+208) tmp = Float64(y + Float64(x / z)); else tmp = Float64(x * Float64(y / Float64(-z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= 1.6e+208) tmp = y + (x / z); else tmp = x * (y / -z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, 1.6e+208], N[(y + N[(x / z), $MachinePrecision]), $MachinePrecision], N[(x * N[(y / (-z)), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq 1.6 \cdot 10^{+208}:\\
\;\;\;\;y + \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;x \cdot \frac{y}{-z}\\
\end{array}
\end{array}
if y < 1.6000000000000001e208Initial program 87.8%
Taylor expanded in z around inf 71.7%
Taylor expanded in x around 0 82.7%
+-commutative82.7%
Simplified82.7%
if 1.6000000000000001e208 < y Initial program 78.1%
Taylor expanded in x around inf 68.9%
mul-1-neg68.9%
unsub-neg68.9%
Simplified68.9%
Taylor expanded in y around inf 68.9%
mul-1-neg68.9%
distribute-rgt-neg-out68.9%
Simplified68.9%
Taylor expanded in x around 0 68.9%
mul-1-neg68.9%
associate-*r/81.5%
distribute-rgt-neg-in81.5%
Simplified81.5%
Final simplification82.6%
(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 87.4%
Taylor expanded in z around inf 69.1%
Taylor expanded in x around 0 79.6%
+-commutative79.6%
Simplified79.6%
Final simplification79.6%
(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 87.4%
Taylor expanded in x around 0 41.4%
Final simplification41.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 2024043
(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))