
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - 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.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\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.25)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - 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.25d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.25)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.25)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.25), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.25\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (/ (+ (* 2.0 y) (* 4.0 (- x z))) y))
double code(double x, double y, double z) {
return ((2.0 * y) + (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 = ((2.0d0 * y) + (4.0d0 * (x - z))) / y
end function
public static double code(double x, double y, double z) {
return ((2.0 * y) + (4.0 * (x - z))) / y;
}
def code(x, y, z): return ((2.0 * y) + (4.0 * (x - z))) / y
function code(x, y, z) return Float64(Float64(Float64(2.0 * y) + Float64(4.0 * Float64(x - z))) / y) end
function tmp = code(x, y, z) tmp = ((2.0 * y) + (4.0 * (x - z))) / y; end
code[x_, y_, z_] := N[(N[(N[(2.0 * y), $MachinePrecision] + N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{2 \cdot y + 4 \cdot \left(x - z\right)}{y}
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ z y) -4.0)) (t_1 (/ (* 4.0 x) y)))
(if (<= x -4.1e+18)
t_1
(if (<= x -5.4e-184)
2.0
(if (<= x 3.9e-162)
t_0
(if (<= x 7.5e+41) 2.0 (if (<= x 3.2e+133) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = (z / y) * -4.0;
double t_1 = (4.0 * x) / y;
double tmp;
if (x <= -4.1e+18) {
tmp = t_1;
} else if (x <= -5.4e-184) {
tmp = 2.0;
} else if (x <= 3.9e-162) {
tmp = t_0;
} else if (x <= 7.5e+41) {
tmp = 2.0;
} else if (x <= 3.2e+133) {
tmp = t_0;
} else {
tmp = t_1;
}
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 = (z / y) * (-4.0d0)
t_1 = (4.0d0 * x) / y
if (x <= (-4.1d+18)) then
tmp = t_1
else if (x <= (-5.4d-184)) then
tmp = 2.0d0
else if (x <= 3.9d-162) then
tmp = t_0
else if (x <= 7.5d+41) then
tmp = 2.0d0
else if (x <= 3.2d+133) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z / y) * -4.0;
double t_1 = (4.0 * x) / y;
double tmp;
if (x <= -4.1e+18) {
tmp = t_1;
} else if (x <= -5.4e-184) {
tmp = 2.0;
} else if (x <= 3.9e-162) {
tmp = t_0;
} else if (x <= 7.5e+41) {
tmp = 2.0;
} else if (x <= 3.2e+133) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (z / y) * -4.0 t_1 = (4.0 * x) / y tmp = 0 if x <= -4.1e+18: tmp = t_1 elif x <= -5.4e-184: tmp = 2.0 elif x <= 3.9e-162: tmp = t_0 elif x <= 7.5e+41: tmp = 2.0 elif x <= 3.2e+133: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(z / y) * -4.0) t_1 = Float64(Float64(4.0 * x) / y) tmp = 0.0 if (x <= -4.1e+18) tmp = t_1; elseif (x <= -5.4e-184) tmp = 2.0; elseif (x <= 3.9e-162) tmp = t_0; elseif (x <= 7.5e+41) tmp = 2.0; elseif (x <= 3.2e+133) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z / y) * -4.0; t_1 = (4.0 * x) / y; tmp = 0.0; if (x <= -4.1e+18) tmp = t_1; elseif (x <= -5.4e-184) tmp = 2.0; elseif (x <= 3.9e-162) tmp = t_0; elseif (x <= 7.5e+41) tmp = 2.0; elseif (x <= 3.2e+133) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]}, Block[{t$95$1 = N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[x, -4.1e+18], t$95$1, If[LessEqual[x, -5.4e-184], 2.0, If[LessEqual[x, 3.9e-162], t$95$0, If[LessEqual[x, 7.5e+41], 2.0, If[LessEqual[x, 3.2e+133], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z}{y} \cdot -4\\
t_1 := \frac{4 \cdot x}{y}\\
\mathbf{if}\;x \leq -4.1 \cdot 10^{+18}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -5.4 \cdot 10^{-184}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 3.9 \cdot 10^{-162}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.5 \cdot 10^{+41}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 3.2 \cdot 10^{+133}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -4.1e18 or 3.19999999999999997e133 < x Initial program 100.0%
Taylor expanded in x around inf 67.8%
associate-*r/67.8%
Simplified67.8%
if -4.1e18 < x < -5.4000000000000002e-184 or 3.8999999999999999e-162 < x < 7.50000000000000072e41Initial program 100.0%
Taylor expanded in y around inf 54.6%
if -5.4000000000000002e-184 < x < 3.8999999999999999e-162 or 7.50000000000000072e41 < x < 3.19999999999999997e133Initial program 99.9%
Taylor expanded in z around inf 65.8%
*-commutative65.8%
Simplified65.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ z y) -4.0)) (t_1 (* x (/ 4.0 y))))
(if (<= x -1.3e+19)
t_1
(if (<= x -3.6e-185)
2.0
(if (<= x 5.4e-162)
t_0
(if (<= x 4.8e+42) 2.0 (if (<= x 3.8e+132) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = (z / y) * -4.0;
double t_1 = x * (4.0 / y);
double tmp;
if (x <= -1.3e+19) {
tmp = t_1;
} else if (x <= -3.6e-185) {
tmp = 2.0;
} else if (x <= 5.4e-162) {
tmp = t_0;
} else if (x <= 4.8e+42) {
tmp = 2.0;
} else if (x <= 3.8e+132) {
tmp = t_0;
} else {
tmp = t_1;
}
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 = (z / y) * (-4.0d0)
t_1 = x * (4.0d0 / y)
if (x <= (-1.3d+19)) then
tmp = t_1
else if (x <= (-3.6d-185)) then
tmp = 2.0d0
else if (x <= 5.4d-162) then
tmp = t_0
else if (x <= 4.8d+42) then
tmp = 2.0d0
else if (x <= 3.8d+132) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z / y) * -4.0;
double t_1 = x * (4.0 / y);
double tmp;
if (x <= -1.3e+19) {
tmp = t_1;
} else if (x <= -3.6e-185) {
tmp = 2.0;
} else if (x <= 5.4e-162) {
tmp = t_0;
} else if (x <= 4.8e+42) {
tmp = 2.0;
} else if (x <= 3.8e+132) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (z / y) * -4.0 t_1 = x * (4.0 / y) tmp = 0 if x <= -1.3e+19: tmp = t_1 elif x <= -3.6e-185: tmp = 2.0 elif x <= 5.4e-162: tmp = t_0 elif x <= 4.8e+42: tmp = 2.0 elif x <= 3.8e+132: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(z / y) * -4.0) t_1 = Float64(x * Float64(4.0 / y)) tmp = 0.0 if (x <= -1.3e+19) tmp = t_1; elseif (x <= -3.6e-185) tmp = 2.0; elseif (x <= 5.4e-162) tmp = t_0; elseif (x <= 4.8e+42) tmp = 2.0; elseif (x <= 3.8e+132) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z / y) * -4.0; t_1 = x * (4.0 / y); tmp = 0.0; if (x <= -1.3e+19) tmp = t_1; elseif (x <= -3.6e-185) tmp = 2.0; elseif (x <= 5.4e-162) tmp = t_0; elseif (x <= 4.8e+42) tmp = 2.0; elseif (x <= 3.8e+132) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.3e+19], t$95$1, If[LessEqual[x, -3.6e-185], 2.0, If[LessEqual[x, 5.4e-162], t$95$0, If[LessEqual[x, 4.8e+42], 2.0, If[LessEqual[x, 3.8e+132], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z}{y} \cdot -4\\
t_1 := x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -1.3 \cdot 10^{+19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -3.6 \cdot 10^{-185}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 5.4 \cdot 10^{-162}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{+42}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+132}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -1.3e19 or 3.80000000000000006e132 < x Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 67.8%
*-commutative67.8%
associate-*l/67.8%
associate-*r/67.6%
Simplified67.6%
if -1.3e19 < x < -3.5999999999999998e-185 or 5.39999999999999968e-162 < x < 4.7999999999999997e42Initial program 100.0%
Taylor expanded in y around inf 54.6%
if -3.5999999999999998e-185 < x < 5.39999999999999968e-162 or 4.7999999999999997e42 < x < 3.80000000000000006e132Initial program 99.9%
Taylor expanded in z around inf 65.8%
*-commutative65.8%
Simplified65.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ -4.0 y))) (t_1 (* x (/ 4.0 y))))
(if (<= x -3.6e+19)
t_1
(if (<= x -5.4e-184)
2.0
(if (<= x 8.8e-163)
t_0
(if (<= x 9.5e+40) 2.0 (if (<= x 3.8e+132) t_0 t_1)))))))
double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double t_1 = x * (4.0 / y);
double tmp;
if (x <= -3.6e+19) {
tmp = t_1;
} else if (x <= -5.4e-184) {
tmp = 2.0;
} else if (x <= 8.8e-163) {
tmp = t_0;
} else if (x <= 9.5e+40) {
tmp = 2.0;
} else if (x <= 3.8e+132) {
tmp = t_0;
} else {
tmp = t_1;
}
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 = z * ((-4.0d0) / y)
t_1 = x * (4.0d0 / y)
if (x <= (-3.6d+19)) then
tmp = t_1
else if (x <= (-5.4d-184)) then
tmp = 2.0d0
else if (x <= 8.8d-163) then
tmp = t_0
else if (x <= 9.5d+40) then
tmp = 2.0d0
else if (x <= 3.8d+132) then
tmp = t_0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double t_1 = x * (4.0 / y);
double tmp;
if (x <= -3.6e+19) {
tmp = t_1;
} else if (x <= -5.4e-184) {
tmp = 2.0;
} else if (x <= 8.8e-163) {
tmp = t_0;
} else if (x <= 9.5e+40) {
tmp = 2.0;
} else if (x <= 3.8e+132) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = z * (-4.0 / y) t_1 = x * (4.0 / y) tmp = 0 if x <= -3.6e+19: tmp = t_1 elif x <= -5.4e-184: tmp = 2.0 elif x <= 8.8e-163: tmp = t_0 elif x <= 9.5e+40: tmp = 2.0 elif x <= 3.8e+132: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-4.0 / y)) t_1 = Float64(x * Float64(4.0 / y)) tmp = 0.0 if (x <= -3.6e+19) tmp = t_1; elseif (x <= -5.4e-184) tmp = 2.0; elseif (x <= 8.8e-163) tmp = t_0; elseif (x <= 9.5e+40) tmp = 2.0; elseif (x <= 3.8e+132) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (-4.0 / y); t_1 = x * (4.0 / y); tmp = 0.0; if (x <= -3.6e+19) tmp = t_1; elseif (x <= -5.4e-184) tmp = 2.0; elseif (x <= 8.8e-163) tmp = t_0; elseif (x <= 9.5e+40) tmp = 2.0; elseif (x <= 3.8e+132) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.6e+19], t$95$1, If[LessEqual[x, -5.4e-184], 2.0, If[LessEqual[x, 8.8e-163], t$95$0, If[LessEqual[x, 9.5e+40], 2.0, If[LessEqual[x, 3.8e+132], t$95$0, t$95$1]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{-4}{y}\\
t_1 := x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -3.6 \cdot 10^{+19}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -5.4 \cdot 10^{-184}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 8.8 \cdot 10^{-163}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 9.5 \cdot 10^{+40}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{+132}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.6e19 or 3.80000000000000006e132 < x Initial program 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 67.8%
*-commutative67.8%
associate-*l/67.8%
associate-*r/67.6%
Simplified67.6%
if -3.6e19 < x < -5.4000000000000002e-184 or 8.80000000000000044e-163 < x < 9.5000000000000003e40Initial program 100.0%
Taylor expanded in y around inf 54.6%
if -5.4000000000000002e-184 < x < 8.80000000000000044e-163 or 9.5000000000000003e40 < x < 3.80000000000000006e132Initial program 99.9%
Taylor expanded in z around inf 65.8%
associate-*r/65.8%
*-commutative65.8%
associate-/l*65.6%
Simplified65.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -4.1e+18) (not (<= x 7500000000.0))) (* 4.0 (/ (- x z) y)) (+ 2.0 (* (/ z y) -4.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4.1e+18) || !(x <= 7500000000.0)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0 + ((z / y) * -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 ((x <= (-4.1d+18)) .or. (.not. (x <= 7500000000.0d0))) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 2.0d0 + ((z / y) * (-4.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -4.1e+18) || !(x <= 7500000000.0)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0 + ((z / y) * -4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4.1e+18) or not (x <= 7500000000.0): tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 + ((z / y) * -4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4.1e+18) || !(x <= 7500000000.0)) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -4.1e+18) || ~((x <= 7500000000.0))) tmp = 4.0 * ((x - z) / y); else tmp = 2.0 + ((z / y) * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4.1e+18], N[Not[LessEqual[x, 7500000000.0]], $MachinePrecision]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.1 \cdot 10^{+18} \lor \neg \left(x \leq 7500000000\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if x < -4.1e18 or 7.5e9 < x Initial program 99.9%
Taylor expanded in y around 0 82.5%
if -4.1e18 < x < 7.5e9Initial program 99.9%
+-commutative99.9%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
distribute-lft-in99.7%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*r*99.8%
metadata-eval99.8%
*-lft-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 91.7%
*-commutative91.7%
Simplified91.7%
Final simplification86.9%
(FPCore (x y z) :precision binary64 (if (<= z -4.5e+32) (* 4.0 (/ (- x z) y)) (if (<= z 1.5e-9) (+ 2.0 (/ (* 4.0 x) y)) (+ 2.0 (* (/ z y) -4.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.5e+32) {
tmp = 4.0 * ((x - z) / y);
} else if (z <= 1.5e-9) {
tmp = 2.0 + ((4.0 * x) / y);
} else {
tmp = 2.0 + ((z / y) * -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 <= (-4.5d+32)) then
tmp = 4.0d0 * ((x - z) / y)
else if (z <= 1.5d-9) then
tmp = 2.0d0 + ((4.0d0 * x) / y)
else
tmp = 2.0d0 + ((z / y) * (-4.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -4.5e+32) {
tmp = 4.0 * ((x - z) / y);
} else if (z <= 1.5e-9) {
tmp = 2.0 + ((4.0 * x) / y);
} else {
tmp = 2.0 + ((z / y) * -4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.5e+32: tmp = 4.0 * ((x - z) / y) elif z <= 1.5e-9: tmp = 2.0 + ((4.0 * x) / y) else: tmp = 2.0 + ((z / y) * -4.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.5e+32) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); elseif (z <= 1.5e-9) tmp = Float64(2.0 + Float64(Float64(4.0 * x) / y)); else tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.5e+32) tmp = 4.0 * ((x - z) / y); elseif (z <= 1.5e-9) tmp = 2.0 + ((4.0 * x) / y); else tmp = 2.0 + ((z / y) * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.5e+32], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.5e-9], N[(2.0 + N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.5 \cdot 10^{+32}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{elif}\;z \leq 1.5 \cdot 10^{-9}:\\
\;\;\;\;2 + \frac{4 \cdot x}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if z < -4.5000000000000003e32Initial program 100.0%
Taylor expanded in y around 0 87.8%
if -4.5000000000000003e32 < z < 1.49999999999999999e-9Initial program 99.9%
+-commutative99.9%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
distribute-lft-in99.7%
associate-+l+99.7%
associate-*l/99.7%
*-commutative99.7%
associate-*r*99.7%
metadata-eval99.7%
*-lft-identity99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 92.8%
+-commutative92.8%
associate-*r/92.8%
Simplified92.8%
if 1.49999999999999999e-9 < z Initial program 100.0%
+-commutative100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
+-commutative99.8%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*r*99.8%
metadata-eval99.8%
*-lft-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 86.4%
*-commutative86.4%
Simplified86.4%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (if (<= y -8.2e+98) 2.0 (if (<= y 4.6e+153) (* 4.0 (/ (- x z) y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+98) {
tmp = 2.0;
} else if (y <= 4.6e+153) {
tmp = 4.0 * ((x - z) / y);
} 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 (y <= (-8.2d+98)) then
tmp = 2.0d0
else if (y <= 4.6d+153) then
tmp = 4.0d0 * ((x - z) / y)
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -8.2e+98) {
tmp = 2.0;
} else if (y <= 4.6e+153) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.2e+98: tmp = 2.0 elif y <= 4.6e+153: tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.2e+98) tmp = 2.0; elseif (y <= 4.6e+153) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -8.2e+98) tmp = 2.0; elseif (y <= 4.6e+153) tmp = 4.0 * ((x - z) / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.2e+98], 2.0, If[LessEqual[y, 4.6e+153], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.2 \cdot 10^{+98}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 4.6 \cdot 10^{+153}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -8.2000000000000001e98 or 4.6000000000000003e153 < y Initial program 100.0%
Taylor expanded in y around inf 73.4%
if -8.2000000000000001e98 < y < 4.6000000000000003e153Initial program 99.9%
Taylor expanded in y around 0 85.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -4.1e+18) (not (<= x 2.1e+15))) (* x (/ 4.0 y)) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4.1e+18) || !(x <= 2.1e+15)) {
tmp = x * (4.0 / y);
} 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 ((x <= (-4.1d+18)) .or. (.not. (x <= 2.1d+15))) then
tmp = x * (4.0d0 / y)
else
tmp = 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -4.1e+18) || !(x <= 2.1e+15)) {
tmp = x * (4.0 / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4.1e+18) or not (x <= 2.1e+15): tmp = x * (4.0 / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4.1e+18) || !(x <= 2.1e+15)) tmp = Float64(x * Float64(4.0 / y)); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -4.1e+18) || ~((x <= 2.1e+15))) tmp = x * (4.0 / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4.1e+18], N[Not[LessEqual[x, 2.1e+15]], $MachinePrecision]], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.1 \cdot 10^{+18} \lor \neg \left(x \leq 2.1 \cdot 10^{+15}\right):\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if x < -4.1e18 or 2.1e15 < x Initial program 99.9%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 61.3%
*-commutative61.3%
associate-*l/61.3%
associate-*r/61.1%
Simplified61.1%
if -4.1e18 < x < 2.1e15Initial program 99.9%
Taylor expanded in y around inf 46.5%
Final simplification54.1%
(FPCore (x y z) :precision binary64 (+ 2.0 (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
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 + ((x - z) * (4.0d0 / y))
end function
public static double code(double x, double y, double z) {
return 2.0 + ((x - z) * (4.0 / y));
}
def code(x, y, z): return 2.0 + ((x - z) * (4.0 / y))
function code(x, y, z) return Float64(2.0 + Float64(Float64(x - z) * Float64(4.0 / y))) end
function tmp = code(x, y, z) tmp = 2.0 + ((x - z) * (4.0 / y)); end
code[x_, y_, z_] := N[(2.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
2 + \left(x - z\right) \cdot \frac{4}{y}
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
distribute-lft-in99.7%
associate-+l+99.7%
associate-*l/99.7%
*-commutative99.7%
associate-*r*99.7%
metadata-eval99.7%
*-lft-identity99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(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.9%
Taylor expanded in y around inf 30.8%
herbie shell --seed 2024186
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, C"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.25)) z)) y)))