
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 10 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0 + ((4.0d0 * ((x + (y * 0.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ 4.0 (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
return 4.0 + (4.0 * ((x - z) / y));
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 4.0d0 + (4.0d0 * ((x - z) / y))
end function
public static double code(double x, double y, double z) {
return 4.0 + (4.0 * ((x - z) / y));
}
def code(x, y, z): return 4.0 + (4.0 * ((x - z) / y))
function code(x, y, z) return Float64(4.0 + Float64(4.0 * Float64(Float64(x - z) / y))) end
function tmp = code(x, y, z) tmp = 4.0 + (4.0 * ((x - z) / y)); end
code[x_, y_, z_] := N[(4.0 + N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 + 4 \cdot \frac{x - z}{y}
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ z y))))
(if (<= z -1.25e+84)
t_0
(if (<= z -2.8e+58)
4.0
(if (<= z -1.95e-31)
t_0
(if (<= z -2.4e-137)
4.0
(if (<= z -7.2e-253)
(* x (/ 4.0 y))
(if (<= z 3.2e+18) 4.0 t_0))))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (z / y);
double tmp;
if (z <= -1.25e+84) {
tmp = t_0;
} else if (z <= -2.8e+58) {
tmp = 4.0;
} else if (z <= -1.95e-31) {
tmp = t_0;
} else if (z <= -2.4e-137) {
tmp = 4.0;
} else if (z <= -7.2e-253) {
tmp = x * (4.0 / y);
} else if (z <= 3.2e+18) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (-4.0d0) * (z / y)
if (z <= (-1.25d+84)) then
tmp = t_0
else if (z <= (-2.8d+58)) then
tmp = 4.0d0
else if (z <= (-1.95d-31)) then
tmp = t_0
else if (z <= (-2.4d-137)) then
tmp = 4.0d0
else if (z <= (-7.2d-253)) then
tmp = x * (4.0d0 / y)
else if (z <= 3.2d+18) then
tmp = 4.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -4.0 * (z / y);
double tmp;
if (z <= -1.25e+84) {
tmp = t_0;
} else if (z <= -2.8e+58) {
tmp = 4.0;
} else if (z <= -1.95e-31) {
tmp = t_0;
} else if (z <= -2.4e-137) {
tmp = 4.0;
} else if (z <= -7.2e-253) {
tmp = x * (4.0 / y);
} else if (z <= 3.2e+18) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (z / y) tmp = 0 if z <= -1.25e+84: tmp = t_0 elif z <= -2.8e+58: tmp = 4.0 elif z <= -1.95e-31: tmp = t_0 elif z <= -2.4e-137: tmp = 4.0 elif z <= -7.2e-253: tmp = x * (4.0 / y) elif z <= 3.2e+18: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(z / y)) tmp = 0.0 if (z <= -1.25e+84) tmp = t_0; elseif (z <= -2.8e+58) tmp = 4.0; elseif (z <= -1.95e-31) tmp = t_0; elseif (z <= -2.4e-137) tmp = 4.0; elseif (z <= -7.2e-253) tmp = Float64(x * Float64(4.0 / y)); elseif (z <= 3.2e+18) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (z / y); tmp = 0.0; if (z <= -1.25e+84) tmp = t_0; elseif (z <= -2.8e+58) tmp = 4.0; elseif (z <= -1.95e-31) tmp = t_0; elseif (z <= -2.4e-137) tmp = 4.0; elseif (z <= -7.2e-253) tmp = x * (4.0 / y); elseif (z <= 3.2e+18) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.25e+84], t$95$0, If[LessEqual[z, -2.8e+58], 4.0, If[LessEqual[z, -1.95e-31], t$95$0, If[LessEqual[z, -2.4e-137], 4.0, If[LessEqual[z, -7.2e-253], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 3.2e+18], 4.0, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -1.25 \cdot 10^{+84}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2.8 \cdot 10^{+58}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq -1.95 \cdot 10^{-31}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2.4 \cdot 10^{-137}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq -7.2 \cdot 10^{-253}:\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{+18}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -1.25e84 or -2.7999999999999998e58 < z < -1.9500000000000001e-31 or 3.2e18 < z Initial program 99.9%
Taylor expanded in y around 0 100.0%
Taylor expanded in z around inf 73.3%
if -1.25e84 < z < -2.7999999999999998e58 or -1.9500000000000001e-31 < z < -2.4e-137 or -7.2e-253 < z < 3.2e18Initial program 99.9%
Taylor expanded in y around inf 54.0%
if -2.4e-137 < z < -7.2e-253Initial program 99.9%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 72.9%
associate-*r/72.9%
associate-*l/72.7%
*-commutative72.7%
Simplified72.7%
Final simplification65.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ z y))))
(if (<= z -2.1e+85)
t_0
(if (<= z -3.1e+58)
4.0
(if (<= z -9.8e-33)
t_0
(if (<= z -2e-137)
4.0
(if (<= z -6.5e-253)
(/ (* 4.0 x) y)
(if (<= z 4e+18) 4.0 t_0))))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (z / y);
double tmp;
if (z <= -2.1e+85) {
tmp = t_0;
} else if (z <= -3.1e+58) {
tmp = 4.0;
} else if (z <= -9.8e-33) {
tmp = t_0;
} else if (z <= -2e-137) {
tmp = 4.0;
} else if (z <= -6.5e-253) {
tmp = (4.0 * x) / y;
} else if (z <= 4e+18) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: tmp
t_0 = (-4.0d0) * (z / y)
if (z <= (-2.1d+85)) then
tmp = t_0
else if (z <= (-3.1d+58)) then
tmp = 4.0d0
else if (z <= (-9.8d-33)) then
tmp = t_0
else if (z <= (-2d-137)) then
tmp = 4.0d0
else if (z <= (-6.5d-253)) then
tmp = (4.0d0 * x) / y
else if (z <= 4d+18) then
tmp = 4.0d0
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -4.0 * (z / y);
double tmp;
if (z <= -2.1e+85) {
tmp = t_0;
} else if (z <= -3.1e+58) {
tmp = 4.0;
} else if (z <= -9.8e-33) {
tmp = t_0;
} else if (z <= -2e-137) {
tmp = 4.0;
} else if (z <= -6.5e-253) {
tmp = (4.0 * x) / y;
} else if (z <= 4e+18) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (z / y) tmp = 0 if z <= -2.1e+85: tmp = t_0 elif z <= -3.1e+58: tmp = 4.0 elif z <= -9.8e-33: tmp = t_0 elif z <= -2e-137: tmp = 4.0 elif z <= -6.5e-253: tmp = (4.0 * x) / y elif z <= 4e+18: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(z / y)) tmp = 0.0 if (z <= -2.1e+85) tmp = t_0; elseif (z <= -3.1e+58) tmp = 4.0; elseif (z <= -9.8e-33) tmp = t_0; elseif (z <= -2e-137) tmp = 4.0; elseif (z <= -6.5e-253) tmp = Float64(Float64(4.0 * x) / y); elseif (z <= 4e+18) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (z / y); tmp = 0.0; if (z <= -2.1e+85) tmp = t_0; elseif (z <= -3.1e+58) tmp = 4.0; elseif (z <= -9.8e-33) tmp = t_0; elseif (z <= -2e-137) tmp = 4.0; elseif (z <= -6.5e-253) tmp = (4.0 * x) / y; elseif (z <= 4e+18) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.1e+85], t$95$0, If[LessEqual[z, -3.1e+58], 4.0, If[LessEqual[z, -9.8e-33], t$95$0, If[LessEqual[z, -2e-137], 4.0, If[LessEqual[z, -6.5e-253], N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision], If[LessEqual[z, 4e+18], 4.0, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y}\\
\mathbf{if}\;z \leq -2.1 \cdot 10^{+85}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -3.1 \cdot 10^{+58}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq -9.8 \cdot 10^{-33}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -2 \cdot 10^{-137}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq -6.5 \cdot 10^{-253}:\\
\;\;\;\;\frac{4 \cdot x}{y}\\
\mathbf{elif}\;z \leq 4 \cdot 10^{+18}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -2.1000000000000001e85 or -3.0999999999999999e58 < z < -9.7999999999999996e-33 or 4e18 < z Initial program 99.9%
Taylor expanded in y around 0 100.0%
Taylor expanded in z around inf 73.3%
if -2.1000000000000001e85 < z < -3.0999999999999999e58 or -9.7999999999999996e-33 < z < -1.99999999999999996e-137 or -6.4999999999999998e-253 < z < 4e18Initial program 99.9%
Taylor expanded in y around inf 54.0%
if -1.99999999999999996e-137 < z < -6.4999999999999998e-253Initial program 99.9%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 72.9%
associate-*r/72.9%
*-commutative72.9%
Simplified72.9%
Final simplification65.1%
(FPCore (x y z)
:precision binary64
(if (or (<= z -2.35e+85)
(and (not (<= z -4.4e+57)) (or (<= z -1.2e-31) (not (<= z 1.2e+22)))))
(* -4.0 (/ z y))
4.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.35e+85) || (!(z <= -4.4e+57) && ((z <= -1.2e-31) || !(z <= 1.2e+22)))) {
tmp = -4.0 * (z / y);
} else {
tmp = 4.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) :: tmp
if ((z <= (-2.35d+85)) .or. (.not. (z <= (-4.4d+57))) .and. (z <= (-1.2d-31)) .or. (.not. (z <= 1.2d+22))) then
tmp = (-4.0d0) * (z / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.35e+85) || (!(z <= -4.4e+57) && ((z <= -1.2e-31) || !(z <= 1.2e+22)))) {
tmp = -4.0 * (z / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.35e+85) or (not (z <= -4.4e+57) and ((z <= -1.2e-31) or not (z <= 1.2e+22))): tmp = -4.0 * (z / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.35e+85) || (!(z <= -4.4e+57) && ((z <= -1.2e-31) || !(z <= 1.2e+22)))) tmp = Float64(-4.0 * Float64(z / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.35e+85) || (~((z <= -4.4e+57)) && ((z <= -1.2e-31) || ~((z <= 1.2e+22))))) tmp = -4.0 * (z / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.35e+85], And[N[Not[LessEqual[z, -4.4e+57]], $MachinePrecision], Or[LessEqual[z, -1.2e-31], N[Not[LessEqual[z, 1.2e+22]], $MachinePrecision]]]], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.35 \cdot 10^{+85} \lor \neg \left(z \leq -4.4 \cdot 10^{+57}\right) \land \left(z \leq -1.2 \cdot 10^{-31} \lor \neg \left(z \leq 1.2 \cdot 10^{+22}\right)\right):\\
\;\;\;\;-4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if z < -2.3500000000000001e85 or -4.4000000000000001e57 < z < -1.2e-31 or 1.2e22 < z Initial program 99.9%
Taylor expanded in y around 0 100.0%
Taylor expanded in z around inf 73.3%
if -2.3500000000000001e85 < z < -4.4000000000000001e57 or -1.2e-31 < z < 1.2e22Initial program 99.9%
Taylor expanded in y around inf 49.1%
Final simplification60.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.05e+52) (not (<= y 2.4e+66))) (+ 4.0 (/ (* z -4.0) y)) (+ 1.0 (* (- x z) (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.05e+52) || !(y <= 2.4e+66)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 1.0 + ((x - z) * (4.0 / 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.05d+52)) .or. (.not. (y <= 2.4d+66))) then
tmp = 4.0d0 + ((z * (-4.0d0)) / y)
else
tmp = 1.0d0 + ((x - z) * (4.0d0 / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.05e+52) || !(y <= 2.4e+66)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 1.0 + ((x - z) * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.05e+52) or not (y <= 2.4e+66): tmp = 4.0 + ((z * -4.0) / y) else: tmp = 1.0 + ((x - z) * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.05e+52) || !(y <= 2.4e+66)) tmp = Float64(4.0 + Float64(Float64(z * -4.0) / y)); else tmp = Float64(1.0 + Float64(Float64(x - z) * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.05e+52) || ~((y <= 2.4e+66))) tmp = 4.0 + ((z * -4.0) / y); else tmp = 1.0 + ((x - z) * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.05e+52], N[Not[LessEqual[y, 2.4e+66]], $MachinePrecision]], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.05 \cdot 10^{+52} \lor \neg \left(y \leq 2.4 \cdot 10^{+66}\right):\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x - z\right) \cdot \frac{4}{y}\\
\end{array}
\end{array}
if y < -1.05e52 or 2.4000000000000002e66 < y Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub100.0%
sub-neg100.0%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 87.5%
sub-neg87.5%
distribute-lft-in87.5%
metadata-eval87.5%
associate-+r+87.5%
metadata-eval87.5%
neg-mul-187.5%
associate-*r*87.5%
metadata-eval87.5%
*-commutative87.5%
associate-*l/87.5%
Simplified87.5%
if -1.05e52 < y < 2.4000000000000002e66Initial program 100.0%
Taylor expanded in y around 0 92.2%
*-commutative92.2%
*-rgt-identity92.2%
associate-*r/92.0%
associate-*l*92.0%
associate-*l/92.0%
metadata-eval92.0%
Simplified92.0%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -5e+83) (not (<= z 4400000000000.0))) (* 4.0 (/ (- x z) y)) (+ 4.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5e+83) || !(z <= 4400000000000.0)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (4.0 * (x / 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 <= (-5d+83)) .or. (.not. (z <= 4400000000000.0d0))) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 4.0d0 + (4.0d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -5e+83) || !(z <= 4400000000000.0)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5e+83) or not (z <= 4400000000000.0): tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -5e+83) || !(z <= 4400000000000.0)) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5e+83) || ~((z <= 4400000000000.0))) tmp = 4.0 * ((x - z) / y); else tmp = 4.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5e+83], N[Not[LessEqual[z, 4400000000000.0]], $MachinePrecision]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5 \cdot 10^{+83} \lor \neg \left(z \leq 4400000000000\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -5.00000000000000029e83 or 4.4e12 < z Initial program 99.9%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 88.5%
if -5.00000000000000029e83 < z < 4.4e12Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub100.0%
sub-neg100.0%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 84.6%
distribute-lft-in84.6%
metadata-eval84.6%
associate-+r+84.6%
metadata-eval84.6%
Simplified84.6%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.2e-84) (not (<= y 1.3e+26))) (+ 4.0 (/ (* z -4.0) y)) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.2e-84) || !(y <= 1.3e+26)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-8.2d-84)) .or. (.not. (y <= 1.3d+26))) then
tmp = 4.0d0 + ((z * (-4.0d0)) / y)
else
tmp = 4.0d0 * ((x - z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -8.2e-84) || !(y <= 1.3e+26)) {
tmp = 4.0 + ((z * -4.0) / y);
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.2e-84) or not (y <= 1.3e+26): tmp = 4.0 + ((z * -4.0) / y) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.2e-84) || !(y <= 1.3e+26)) tmp = Float64(4.0 + Float64(Float64(z * -4.0) / y)); else tmp = Float64(4.0 * Float64(Float64(x - z) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -8.2e-84) || ~((y <= 1.3e+26))) tmp = 4.0 + ((z * -4.0) / y); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -8.2e-84], N[Not[LessEqual[y, 1.3e+26]], $MachinePrecision]], N[(4.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{-84} \lor \neg \left(y \leq 1.3 \cdot 10^{+26}\right):\\
\;\;\;\;4 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -8.2000000000000001e-84 or 1.30000000000000001e26 < y Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub100.0%
sub-neg100.0%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 84.2%
sub-neg84.2%
distribute-lft-in84.2%
metadata-eval84.2%
associate-+r+84.2%
metadata-eval84.2%
neg-mul-184.2%
associate-*r*84.2%
metadata-eval84.2%
*-commutative84.2%
associate-*l/84.2%
Simplified84.2%
if -8.2000000000000001e-84 < y < 1.30000000000000001e26Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 95.5%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (<= y -1.15e+108) 4.0 (if (<= y 3.25e+69) (* 4.0 (/ (- x z) y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.15e+108) {
tmp = 4.0;
} else if (y <= 3.25e+69) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.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) :: tmp
if (y <= (-1.15d+108)) then
tmp = 4.0d0
else if (y <= 3.25d+69) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.15e+108) {
tmp = 4.0;
} else if (y <= 3.25e+69) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.15e+108: tmp = 4.0 elif y <= 3.25e+69: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.15e+108) tmp = 4.0; elseif (y <= 3.25e+69) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.15e+108) tmp = 4.0; elseif (y <= 3.25e+69) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.15e+108], 4.0, If[LessEqual[y, 3.25e+69], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.15 \cdot 10^{+108}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 3.25 \cdot 10^{+69}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -1.1499999999999999e108 or 3.25e69 < y Initial program 99.9%
Taylor expanded in y around inf 69.3%
if -1.1499999999999999e108 < y < 3.25e69Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 89.2%
Final simplification82.3%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 73.0%
*-commutative73.0%
*-rgt-identity73.0%
associate-*r/72.9%
associate-*l*72.9%
associate-*l/72.9%
metadata-eval72.9%
Simplified72.9%
Taylor expanded in y around inf 7.3%
Final simplification7.3%
(FPCore (x y z) :precision binary64 4.0)
double code(double x, double y, double z) {
return 4.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 4.0d0
end function
public static double code(double x, double y, double z) {
return 4.0;
}
def code(x, y, z): return 4.0
function code(x, y, z) return 4.0 end
function tmp = code(x, y, z) tmp = 4.0; end
code[x_, y_, z_] := 4.0
\begin{array}{l}
\\
4
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 31.9%
Final simplification31.9%
herbie shell --seed 2024043
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, A"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))