
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
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 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
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 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (+ (* (/ 4.0 z) (- x y)) -2.0))
double code(double x, double y, double z) {
return ((4.0 / z) * (x - y)) + -2.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 / z) * (x - y)) + (-2.0d0)
end function
public static double code(double x, double y, double z) {
return ((4.0 / z) * (x - y)) + -2.0;
}
def code(x, y, z): return ((4.0 / z) * (x - y)) + -2.0
function code(x, y, z) return Float64(Float64(Float64(4.0 / z) * Float64(x - y)) + -2.0) end
function tmp = code(x, y, z) tmp = ((4.0 / z) * (x - y)) + -2.0; end
code[x_, y_, z_] := N[(N[(N[(4.0 / z), $MachinePrecision] * N[(x - y), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{4}{z} \cdot \left(x - y\right) + -2
\end{array}
Initial program 99.6%
*-commutative99.6%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.8%
fma-neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate-/r/99.8%
distribute-rgt-neg-in99.8%
Simplified99.8%
fma-udef99.8%
*-commutative99.8%
Applied egg-rr99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ y z))) (t_1 (/ (* 4.0 x) z)))
(if (<= z -8200000000.0)
-2.0
(if (<= z -1.2e-144)
t_1
(if (<= z -5.5e-305)
t_0
(if (<= z 4.3e-172)
t_1
(if (<= z 8.8e-122)
t_0
(if (<= z 4.2e-15)
t_1
(if (<= z 8.5e+61) t_0 (if (<= z 2.2e+140) t_1 -2.0))))))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double t_1 = (4.0 * x) / z;
double tmp;
if (z <= -8200000000.0) {
tmp = -2.0;
} else if (z <= -1.2e-144) {
tmp = t_1;
} else if (z <= -5.5e-305) {
tmp = t_0;
} else if (z <= 4.3e-172) {
tmp = t_1;
} else if (z <= 8.8e-122) {
tmp = t_0;
} else if (z <= 4.2e-15) {
tmp = t_1;
} else if (z <= 8.5e+61) {
tmp = t_0;
} else if (z <= 2.2e+140) {
tmp = t_1;
} else {
tmp = -2.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) :: t_1
real(8) :: tmp
t_0 = (-4.0d0) * (y / z)
t_1 = (4.0d0 * x) / z
if (z <= (-8200000000.0d0)) then
tmp = -2.0d0
else if (z <= (-1.2d-144)) then
tmp = t_1
else if (z <= (-5.5d-305)) then
tmp = t_0
else if (z <= 4.3d-172) then
tmp = t_1
else if (z <= 8.8d-122) then
tmp = t_0
else if (z <= 4.2d-15) then
tmp = t_1
else if (z <= 8.5d+61) then
tmp = t_0
else if (z <= 2.2d+140) then
tmp = t_1
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double t_1 = (4.0 * x) / z;
double tmp;
if (z <= -8200000000.0) {
tmp = -2.0;
} else if (z <= -1.2e-144) {
tmp = t_1;
} else if (z <= -5.5e-305) {
tmp = t_0;
} else if (z <= 4.3e-172) {
tmp = t_1;
} else if (z <= 8.8e-122) {
tmp = t_0;
} else if (z <= 4.2e-15) {
tmp = t_1;
} else if (z <= 8.5e+61) {
tmp = t_0;
} else if (z <= 2.2e+140) {
tmp = t_1;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) t_1 = (4.0 * x) / z tmp = 0 if z <= -8200000000.0: tmp = -2.0 elif z <= -1.2e-144: tmp = t_1 elif z <= -5.5e-305: tmp = t_0 elif z <= 4.3e-172: tmp = t_1 elif z <= 8.8e-122: tmp = t_0 elif z <= 4.2e-15: tmp = t_1 elif z <= 8.5e+61: tmp = t_0 elif z <= 2.2e+140: tmp = t_1 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) t_1 = Float64(Float64(4.0 * x) / z) tmp = 0.0 if (z <= -8200000000.0) tmp = -2.0; elseif (z <= -1.2e-144) tmp = t_1; elseif (z <= -5.5e-305) tmp = t_0; elseif (z <= 4.3e-172) tmp = t_1; elseif (z <= 8.8e-122) tmp = t_0; elseif (z <= 4.2e-15) tmp = t_1; elseif (z <= 8.5e+61) tmp = t_0; elseif (z <= 2.2e+140) tmp = t_1; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); t_1 = (4.0 * x) / z; tmp = 0.0; if (z <= -8200000000.0) tmp = -2.0; elseif (z <= -1.2e-144) tmp = t_1; elseif (z <= -5.5e-305) tmp = t_0; elseif (z <= 4.3e-172) tmp = t_1; elseif (z <= 8.8e-122) tmp = t_0; elseif (z <= 4.2e-15) tmp = t_1; elseif (z <= 8.5e+61) tmp = t_0; elseif (z <= 2.2e+140) tmp = t_1; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(4.0 * x), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -8200000000.0], -2.0, If[LessEqual[z, -1.2e-144], t$95$1, If[LessEqual[z, -5.5e-305], t$95$0, If[LessEqual[z, 4.3e-172], t$95$1, If[LessEqual[z, 8.8e-122], t$95$0, If[LessEqual[z, 4.2e-15], t$95$1, If[LessEqual[z, 8.5e+61], t$95$0, If[LessEqual[z, 2.2e+140], t$95$1, -2.0]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
t_1 := \frac{4 \cdot x}{z}\\
\mathbf{if}\;z \leq -8200000000:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -1.2 \cdot 10^{-144}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -5.5 \cdot 10^{-305}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{-172}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{-122}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 4.2 \cdot 10^{-15}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 8.5 \cdot 10^{+61}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{+140}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -8.2e9 or 2.1999999999999998e140 < z Initial program 98.9%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 69.4%
if -8.2e9 < z < -1.19999999999999997e-144 or -5.5e-305 < z < 4.2999999999999997e-172 or 8.8e-122 < z < 4.19999999999999962e-15 or 8.50000000000000035e61 < z < 2.1999999999999998e140Initial program 100.0%
associate--l-100.0%
Simplified100.0%
Taylor expanded in x around inf 58.9%
if -1.19999999999999997e-144 < z < -5.5e-305 or 4.2999999999999997e-172 < z < 8.8e-122 or 4.19999999999999962e-15 < z < 8.50000000000000035e61Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 71.8%
Final simplification66.0%
(FPCore (x y z)
:precision binary64
(if (or (<= x -4.6e+91)
(not (or (<= x 6.6e+61) (and (not (<= x 3e+84)) (<= x 6.8e+196)))))
(/ (* 4.0 x) z)
(- (* -4.0 (/ y z)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4.6e+91) || !((x <= 6.6e+61) || (!(x <= 3e+84) && (x <= 6.8e+196)))) {
tmp = (4.0 * x) / z;
} else {
tmp = (-4.0 * (y / z)) - 2.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 ((x <= (-4.6d+91)) .or. (.not. (x <= 6.6d+61) .or. (.not. (x <= 3d+84)) .and. (x <= 6.8d+196))) then
tmp = (4.0d0 * x) / z
else
tmp = ((-4.0d0) * (y / z)) - 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -4.6e+91) || !((x <= 6.6e+61) || (!(x <= 3e+84) && (x <= 6.8e+196)))) {
tmp = (4.0 * x) / z;
} else {
tmp = (-4.0 * (y / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4.6e+91) or not ((x <= 6.6e+61) or (not (x <= 3e+84) and (x <= 6.8e+196))): tmp = (4.0 * x) / z else: tmp = (-4.0 * (y / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4.6e+91) || !((x <= 6.6e+61) || (!(x <= 3e+84) && (x <= 6.8e+196)))) tmp = Float64(Float64(4.0 * x) / z); else tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -4.6e+91) || ~(((x <= 6.6e+61) || (~((x <= 3e+84)) && (x <= 6.8e+196))))) tmp = (4.0 * x) / z; else tmp = (-4.0 * (y / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4.6e+91], N[Not[Or[LessEqual[x, 6.6e+61], And[N[Not[LessEqual[x, 3e+84]], $MachinePrecision], LessEqual[x, 6.8e+196]]]], $MachinePrecision]], N[(N[(4.0 * x), $MachinePrecision] / z), $MachinePrecision], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.6 \cdot 10^{+91} \lor \neg \left(x \leq 6.6 \cdot 10^{+61} \lor \neg \left(x \leq 3 \cdot 10^{+84}\right) \land x \leq 6.8 \cdot 10^{+196}\right):\\
\;\;\;\;\frac{4 \cdot x}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\end{array}
\end{array}
if x < -4.59999999999999982e91 or 6.5999999999999995e61 < x < 2.99999999999999996e84 or 6.8e196 < x Initial program 100.0%
associate--l-100.0%
Simplified100.0%
Taylor expanded in x around inf 81.9%
if -4.59999999999999982e91 < x < 6.5999999999999995e61 or 2.99999999999999996e84 < x < 6.8e196Initial program 99.4%
*-commutative99.4%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.9%
fma-neg99.9%
metadata-eval99.9%
/-rgt-identity99.9%
associate-/r/99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
Taylor expanded in x around 0 87.2%
Final simplification85.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -7.4e+87) (not (<= x 1.05e+34))) (- (* 4.0 (/ x z)) 2.0) (- (* -4.0 (/ y z)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7.4e+87) || !(x <= 1.05e+34)) {
tmp = (4.0 * (x / z)) - 2.0;
} else {
tmp = (-4.0 * (y / z)) - 2.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 ((x <= (-7.4d+87)) .or. (.not. (x <= 1.05d+34))) then
tmp = (4.0d0 * (x / z)) - 2.0d0
else
tmp = ((-4.0d0) * (y / z)) - 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -7.4e+87) || !(x <= 1.05e+34)) {
tmp = (4.0 * (x / z)) - 2.0;
} else {
tmp = (-4.0 * (y / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -7.4e+87) or not (x <= 1.05e+34): tmp = (4.0 * (x / z)) - 2.0 else: tmp = (-4.0 * (y / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -7.4e+87) || !(x <= 1.05e+34)) tmp = Float64(Float64(4.0 * Float64(x / z)) - 2.0); else tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -7.4e+87) || ~((x <= 1.05e+34))) tmp = (4.0 * (x / z)) - 2.0; else tmp = (-4.0 * (y / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -7.4e+87], N[Not[LessEqual[x, 1.05e+34]], $MachinePrecision]], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7.4 \cdot 10^{+87} \lor \neg \left(x \leq 1.05 \cdot 10^{+34}\right):\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\end{array}
\end{array}
if x < -7.40000000000000005e87 or 1.05000000000000009e34 < x Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.7%
fma-neg99.7%
metadata-eval99.7%
/-rgt-identity99.7%
associate-/r/99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in y around 0 87.6%
if -7.40000000000000005e87 < x < 1.05000000000000009e34Initial program 99.3%
*-commutative99.3%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.9%
fma-neg99.9%
metadata-eval99.9%
/-rgt-identity99.9%
associate-/r/99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
Taylor expanded in x around 0 89.0%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (<= x -8.6e+67) (/ (* 4.0 (- x y)) z) (if (<= x 2.6e+33) (- (* -4.0 (/ y z)) 2.0) (- (* 4.0 (/ x z)) 2.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -8.6e+67) {
tmp = (4.0 * (x - y)) / z;
} else if (x <= 2.6e+33) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (4.0 * (x / z)) - 2.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 (x <= (-8.6d+67)) then
tmp = (4.0d0 * (x - y)) / z
else if (x <= 2.6d+33) then
tmp = ((-4.0d0) * (y / z)) - 2.0d0
else
tmp = (4.0d0 * (x / z)) - 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -8.6e+67) {
tmp = (4.0 * (x - y)) / z;
} else if (x <= 2.6e+33) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (4.0 * (x / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -8.6e+67: tmp = (4.0 * (x - y)) / z elif x <= 2.6e+33: tmp = (-4.0 * (y / z)) - 2.0 else: tmp = (4.0 * (x / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -8.6e+67) tmp = Float64(Float64(4.0 * Float64(x - y)) / z); elseif (x <= 2.6e+33) tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); else tmp = Float64(Float64(4.0 * Float64(x / z)) - 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -8.6e+67) tmp = (4.0 * (x - y)) / z; elseif (x <= 2.6e+33) tmp = (-4.0 * (y / z)) - 2.0; else tmp = (4.0 * (x / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -8.6e+67], N[(N[(4.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[x, 2.6e+33], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.6 \cdot 10^{+67}:\\
\;\;\;\;\frac{4 \cdot \left(x - y\right)}{z}\\
\mathbf{elif}\;x \leq 2.6 \cdot 10^{+33}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\end{array}
\end{array}
if x < -8.6000000000000002e67Initial program 100.0%
associate--l-100.0%
Simplified100.0%
Taylor expanded in z around 0 87.6%
if -8.6000000000000002e67 < x < 2.5999999999999997e33Initial program 99.3%
*-commutative99.3%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.9%
fma-neg99.9%
metadata-eval99.9%
/-rgt-identity99.9%
associate-/r/99.9%
distribute-rgt-neg-in99.9%
Simplified99.9%
Taylor expanded in x around 0 89.9%
if 2.5999999999999997e33 < x Initial program 99.9%
*-commutative99.9%
associate-/l*99.9%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.7%
fma-neg99.7%
metadata-eval99.7%
/-rgt-identity99.7%
associate-/r/99.7%
distribute-rgt-neg-in99.7%
Simplified99.7%
Taylor expanded in y around 0 85.8%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (<= z -9.5e+37) -2.0 (if (<= z 3.4e+59) (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -9.5e+37) {
tmp = -2.0;
} else if (z <= 3.4e+59) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.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 <= (-9.5d+37)) then
tmp = -2.0d0
else if (z <= 3.4d+59) then
tmp = (-4.0d0) * (y / z)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -9.5e+37) {
tmp = -2.0;
} else if (z <= 3.4e+59) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -9.5e+37: tmp = -2.0 elif z <= 3.4e+59: tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -9.5e+37) tmp = -2.0; elseif (z <= 3.4e+59) tmp = Float64(-4.0 * Float64(y / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -9.5e+37) tmp = -2.0; elseif (z <= 3.4e+59) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -9.5e+37], -2.0, If[LessEqual[z, 3.4e+59], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9.5 \cdot 10^{+37}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 3.4 \cdot 10^{+59}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -9.4999999999999995e37 or 3.40000000000000006e59 < z Initial program 99.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 64.8%
if -9.4999999999999995e37 < z < 3.40000000000000006e59Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 52.2%
Final simplification57.5%
(FPCore (x y z) :precision binary64 -2.0)
double code(double x, double y, double z) {
return -2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -2.0d0
end function
public static double code(double x, double y, double z) {
return -2.0;
}
def code(x, y, z): return -2.0
function code(x, y, z) return -2.0 end
function tmp = code(x, y, z) tmp = -2.0; end
code[x_, y_, z_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 99.6%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 33.6%
Final simplification33.6%
(FPCore (x y z) :precision binary64 (- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z)))))
double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
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 * (x / z)) - (2.0d0 + (4.0d0 * (y / z)))
end function
public static double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
def code(x, y, z): return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)))
function code(x, y, z) return Float64(Float64(4.0 * Float64(x / z)) - Float64(2.0 + Float64(4.0 * Float64(y / z)))) end
function tmp = code(x, y, z) tmp = (4.0 * (x / z)) - (2.0 + (4.0 * (y / z))); end
code[x_, y_, z_] := N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(2.0 + N[(4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \frac{x}{z} - \left(2 + 4 \cdot \frac{y}{z}\right)
\end{array}
herbie shell --seed 2023320
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:herbie-target
(- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))