
(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 8 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 (/ (- x y) z)) 2.0))
double code(double x, double y, double z) {
return (4.0 * ((x - y) / z)) - 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 * ((x - y) / z)) - 2.0d0
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) / z)) - 2.0;
}
def code(x, y, z): return (4.0 * ((x - y) / z)) - 2.0
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) / z)) - 2.0) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) / z)) - 2.0; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \frac{x - y}{z} - 2
\end{array}
Initial program 99.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around 0 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* y -4.0) z)) (t_1 (* 4.0 (/ x z))))
(if (<= y -2.15e+80)
t_0
(if (<= y -4.2e-169)
t_1
(if (<= y -8.2e-232)
-2.0
(if (<= y -1e-277)
t_1
(if (<= y 1.75e-267)
-2.0
(if (<= y 3.8e-196)
t_1
(if (<= y 3.95e-115) -2.0 (if (<= y 1.35e+110) t_1 t_0))))))))))
double code(double x, double y, double z) {
double t_0 = (y * -4.0) / z;
double t_1 = 4.0 * (x / z);
double tmp;
if (y <= -2.15e+80) {
tmp = t_0;
} else if (y <= -4.2e-169) {
tmp = t_1;
} else if (y <= -8.2e-232) {
tmp = -2.0;
} else if (y <= -1e-277) {
tmp = t_1;
} else if (y <= 1.75e-267) {
tmp = -2.0;
} else if (y <= 3.8e-196) {
tmp = t_1;
} else if (y <= 3.95e-115) {
tmp = -2.0;
} else if (y <= 1.35e+110) {
tmp = t_1;
} 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) :: t_1
real(8) :: tmp
t_0 = (y * (-4.0d0)) / z
t_1 = 4.0d0 * (x / z)
if (y <= (-2.15d+80)) then
tmp = t_0
else if (y <= (-4.2d-169)) then
tmp = t_1
else if (y <= (-8.2d-232)) then
tmp = -2.0d0
else if (y <= (-1d-277)) then
tmp = t_1
else if (y <= 1.75d-267) then
tmp = -2.0d0
else if (y <= 3.8d-196) then
tmp = t_1
else if (y <= 3.95d-115) then
tmp = -2.0d0
else if (y <= 1.35d+110) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (y * -4.0) / z;
double t_1 = 4.0 * (x / z);
double tmp;
if (y <= -2.15e+80) {
tmp = t_0;
} else if (y <= -4.2e-169) {
tmp = t_1;
} else if (y <= -8.2e-232) {
tmp = -2.0;
} else if (y <= -1e-277) {
tmp = t_1;
} else if (y <= 1.75e-267) {
tmp = -2.0;
} else if (y <= 3.8e-196) {
tmp = t_1;
} else if (y <= 3.95e-115) {
tmp = -2.0;
} else if (y <= 1.35e+110) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (y * -4.0) / z t_1 = 4.0 * (x / z) tmp = 0 if y <= -2.15e+80: tmp = t_0 elif y <= -4.2e-169: tmp = t_1 elif y <= -8.2e-232: tmp = -2.0 elif y <= -1e-277: tmp = t_1 elif y <= 1.75e-267: tmp = -2.0 elif y <= 3.8e-196: tmp = t_1 elif y <= 3.95e-115: tmp = -2.0 elif y <= 1.35e+110: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y * -4.0) / z) t_1 = Float64(4.0 * Float64(x / z)) tmp = 0.0 if (y <= -2.15e+80) tmp = t_0; elseif (y <= -4.2e-169) tmp = t_1; elseif (y <= -8.2e-232) tmp = -2.0; elseif (y <= -1e-277) tmp = t_1; elseif (y <= 1.75e-267) tmp = -2.0; elseif (y <= 3.8e-196) tmp = t_1; elseif (y <= 3.95e-115) tmp = -2.0; elseif (y <= 1.35e+110) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y * -4.0) / z; t_1 = 4.0 * (x / z); tmp = 0.0; if (y <= -2.15e+80) tmp = t_0; elseif (y <= -4.2e-169) tmp = t_1; elseif (y <= -8.2e-232) tmp = -2.0; elseif (y <= -1e-277) tmp = t_1; elseif (y <= 1.75e-267) tmp = -2.0; elseif (y <= 3.8e-196) tmp = t_1; elseif (y <= 3.95e-115) tmp = -2.0; elseif (y <= 1.35e+110) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y * -4.0), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -2.15e+80], t$95$0, If[LessEqual[y, -4.2e-169], t$95$1, If[LessEqual[y, -8.2e-232], -2.0, If[LessEqual[y, -1e-277], t$95$1, If[LessEqual[y, 1.75e-267], -2.0, If[LessEqual[y, 3.8e-196], t$95$1, If[LessEqual[y, 3.95e-115], -2.0, If[LessEqual[y, 1.35e+110], t$95$1, t$95$0]]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y \cdot -4}{z}\\
t_1 := 4 \cdot \frac{x}{z}\\
\mathbf{if}\;y \leq -2.15 \cdot 10^{+80}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -4.2 \cdot 10^{-169}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -8.2 \cdot 10^{-232}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq -1 \cdot 10^{-277}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 1.75 \cdot 10^{-267}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-196}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 3.95 \cdot 10^{-115}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+110}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if y < -2.15000000000000002e80 or 1.35000000000000005e110 < y Initial program 98.8%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around inf 72.8%
*-commutative72.8%
associate-*l/72.8%
Simplified72.8%
if -2.15000000000000002e80 < y < -4.2000000000000001e-169 or -8.19999999999999945e-232 < y < -9.99999999999999969e-278 or 1.75e-267 < y < 3.8000000000000001e-196 or 3.95000000000000002e-115 < y < 1.35000000000000005e110Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 62.1%
if -4.2000000000000001e-169 < y < -8.19999999999999945e-232 or -9.99999999999999969e-278 < y < 1.75e-267 or 3.8000000000000001e-196 < y < 3.95000000000000002e-115Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around inf 68.5%
Final simplification66.9%
(FPCore (x y z)
:precision binary64
(if (or (<= x -2.75e+85)
(and (not (<= x 1.22e+67))
(or (<= x 8.5e+206) (not (<= x 4.5e+219)))))
(* 4.0 (/ x z))
(- (* -4.0 (/ y z)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.75e+85) || (!(x <= 1.22e+67) && ((x <= 8.5e+206) || !(x <= 4.5e+219)))) {
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 <= (-2.75d+85)) .or. (.not. (x <= 1.22d+67)) .and. (x <= 8.5d+206) .or. (.not. (x <= 4.5d+219))) 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 <= -2.75e+85) || (!(x <= 1.22e+67) && ((x <= 8.5e+206) || !(x <= 4.5e+219)))) {
tmp = 4.0 * (x / z);
} else {
tmp = (-4.0 * (y / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.75e+85) or (not (x <= 1.22e+67) and ((x <= 8.5e+206) or not (x <= 4.5e+219))): 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 <= -2.75e+85) || (!(x <= 1.22e+67) && ((x <= 8.5e+206) || !(x <= 4.5e+219)))) tmp = Float64(4.0 * Float64(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 <= -2.75e+85) || (~((x <= 1.22e+67)) && ((x <= 8.5e+206) || ~((x <= 4.5e+219))))) 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, -2.75e+85], And[N[Not[LessEqual[x, 1.22e+67]], $MachinePrecision], Or[LessEqual[x, 8.5e+206], N[Not[LessEqual[x, 4.5e+219]], $MachinePrecision]]]], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.75 \cdot 10^{+85} \lor \neg \left(x \leq 1.22 \cdot 10^{+67}\right) \land \left(x \leq 8.5 \cdot 10^{+206} \lor \neg \left(x \leq 4.5 \cdot 10^{+219}\right)\right):\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\end{array}
\end{array}
if x < -2.75000000000000004e85 or 1.22000000000000004e67 < x < 8.4999999999999996e206 or 4.50000000000000023e219 < x Initial program 99.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 82.5%
if -2.75000000000000004e85 < x < 1.22000000000000004e67 or 8.4999999999999996e206 < x < 4.50000000000000023e219Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-lft-in99.7%
associate-*l/99.9%
associate-*r/99.9%
fma-def99.9%
associate-*l/100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
associate-*r*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 87.3%
Final simplification85.4%
(FPCore (x y z)
:precision binary64
(if (<= y -3.1e+26)
(/ 4.0 (/ z (- x y)))
(if (<= y 2.06e+111)
(- (* 4.0 (/ x z)) 2.0)
(* -4.0 (/ (+ y (* z 0.5)) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.1e+26) {
tmp = 4.0 / (z / (x - y));
} else if (y <= 2.06e+111) {
tmp = (4.0 * (x / z)) - 2.0;
} else {
tmp = -4.0 * ((y + (z * 0.5)) / 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 <= (-3.1d+26)) then
tmp = 4.0d0 / (z / (x - y))
else if (y <= 2.06d+111) then
tmp = (4.0d0 * (x / z)) - 2.0d0
else
tmp = (-4.0d0) * ((y + (z * 0.5d0)) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.1e+26) {
tmp = 4.0 / (z / (x - y));
} else if (y <= 2.06e+111) {
tmp = (4.0 * (x / z)) - 2.0;
} else {
tmp = -4.0 * ((y + (z * 0.5)) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.1e+26: tmp = 4.0 / (z / (x - y)) elif y <= 2.06e+111: tmp = (4.0 * (x / z)) - 2.0 else: tmp = -4.0 * ((y + (z * 0.5)) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.1e+26) tmp = Float64(4.0 / Float64(z / Float64(x - y))); elseif (y <= 2.06e+111) tmp = Float64(Float64(4.0 * Float64(x / z)) - 2.0); else tmp = Float64(-4.0 * Float64(Float64(y + Float64(z * 0.5)) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.1e+26) tmp = 4.0 / (z / (x - y)); elseif (y <= 2.06e+111) tmp = (4.0 * (x / z)) - 2.0; else tmp = -4.0 * ((y + (z * 0.5)) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.1e+26], N[(4.0 / N[(z / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.06e+111], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(-4.0 * N[(N[(y + N[(z * 0.5), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.1 \cdot 10^{+26}:\\
\;\;\;\;\frac{4}{\frac{z}{x - y}}\\
\mathbf{elif}\;y \leq 2.06 \cdot 10^{+111}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y + z \cdot 0.5}{z}\\
\end{array}
\end{array}
if y < -3.1e26Initial program 100.0%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in z around 0 90.7%
if -3.1e26 < y < 2.06000000000000004e111Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-lft-in99.7%
associate-*l/99.9%
associate-*r/99.9%
fma-def99.9%
associate-*l/100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
associate-*r*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 91.0%
if 2.06000000000000004e111 < y Initial program 97.6%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around 0 93.8%
Final simplification91.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.8e+81) (not (<= y 2.75e+110))) (- (* -4.0 (/ y z)) 2.0) (- (* 4.0 (/ x z)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.8e+81) || !(y <= 2.75e+110)) {
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 ((y <= (-4.8d+81)) .or. (.not. (y <= 2.75d+110))) 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 ((y <= -4.8e+81) || !(y <= 2.75e+110)) {
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 (y <= -4.8e+81) or not (y <= 2.75e+110): 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 ((y <= -4.8e+81) || !(y <= 2.75e+110)) 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 ((y <= -4.8e+81) || ~((y <= 2.75e+110))) 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[Or[LessEqual[y, -4.8e+81], N[Not[LessEqual[y, 2.75e+110]], $MachinePrecision]], 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}\;y \leq -4.8 \cdot 10^{+81} \lor \neg \left(y \leq 2.75 \cdot 10^{+110}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\end{array}
\end{array}
if y < -4.79999999999999979e81 or 2.74999999999999998e110 < y Initial program 98.8%
associate-*l/99.8%
sub-neg99.8%
distribute-lft-in99.8%
associate-*l/98.8%
associate-*r/100.0%
fma-def100.0%
associate-*l/100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
associate-*r*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 86.6%
if -4.79999999999999979e81 < y < 2.74999999999999998e110Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-lft-in99.7%
associate-*l/99.9%
associate-*r/99.9%
fma-def99.9%
associate-*l/100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
associate-*r*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 89.5%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (<= y -3.5e+26) (/ 4.0 (/ z (- x y))) (if (<= y 5.9e+110) (- (* 4.0 (/ x z)) 2.0) (- (* -4.0 (/ y z)) 2.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.5e+26) {
tmp = 4.0 / (z / (x - y));
} else if (y <= 5.9e+110) {
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 (y <= (-3.5d+26)) then
tmp = 4.0d0 / (z / (x - y))
else if (y <= 5.9d+110) 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 (y <= -3.5e+26) {
tmp = 4.0 / (z / (x - y));
} else if (y <= 5.9e+110) {
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 y <= -3.5e+26: tmp = 4.0 / (z / (x - y)) elif y <= 5.9e+110: 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 (y <= -3.5e+26) tmp = Float64(4.0 / Float64(z / Float64(x - y))); elseif (y <= 5.9e+110) 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 (y <= -3.5e+26) tmp = 4.0 / (z / (x - y)); elseif (y <= 5.9e+110) 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[LessEqual[y, -3.5e+26], N[(4.0 / N[(z / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 5.9e+110], 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}\;y \leq -3.5 \cdot 10^{+26}:\\
\;\;\;\;\frac{4}{\frac{z}{x - y}}\\
\mathbf{elif}\;y \leq 5.9 \cdot 10^{+110}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\end{array}
\end{array}
if y < -3.4999999999999999e26Initial program 100.0%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in z around 0 90.7%
if -3.4999999999999999e26 < y < 5.8999999999999997e110Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-lft-in99.7%
associate-*l/99.9%
associate-*r/99.9%
fma-def99.9%
associate-*l/100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
associate-*r*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 91.0%
if 5.8999999999999997e110 < y Initial program 97.6%
associate-*l/99.8%
sub-neg99.8%
distribute-lft-in99.8%
associate-*l/97.6%
associate-*r/100.0%
fma-def100.0%
associate-*l/100.0%
*-commutative100.0%
distribute-rgt-neg-in100.0%
associate-*r*100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in x around 0 93.8%
Final simplification91.4%
(FPCore (x y z) :precision binary64 (if (<= z -1.8e-18) -2.0 (if (<= z 1.18e+67) (* 4.0 (/ x z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.8e-18) {
tmp = -2.0;
} else if (z <= 1.18e+67) {
tmp = 4.0 * (x / 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 <= (-1.8d-18)) then
tmp = -2.0d0
else if (z <= 1.18d+67) then
tmp = 4.0d0 * (x / 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 <= -1.8e-18) {
tmp = -2.0;
} else if (z <= 1.18e+67) {
tmp = 4.0 * (x / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.8e-18: tmp = -2.0 elif z <= 1.18e+67: tmp = 4.0 * (x / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.8e-18) tmp = -2.0; elseif (z <= 1.18e+67) tmp = Float64(4.0 * Float64(x / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1.8e-18) tmp = -2.0; elseif (z <= 1.18e+67) tmp = 4.0 * (x / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.8e-18], -2.0, If[LessEqual[z, 1.18e+67], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.8 \cdot 10^{-18}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 1.18 \cdot 10^{+67}:\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.80000000000000005e-18 or 1.17999999999999998e67 < z Initial program 99.1%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in z around inf 58.4%
if -1.80000000000000005e-18 < z < 1.17999999999999998e67Initial program 100.0%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in x around inf 55.5%
Final simplification56.8%
(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.8%
Simplified99.8%
Taylor expanded in z around inf 32.3%
Final simplification32.3%
(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 2023200
(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))