
(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 9 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 (+ 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(4.0 * Float64(Float64(x + Float64(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[(4.0 * N[(N[(x + N[(N[(y * 0.25), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + 4 \cdot \frac{x + \left(y \cdot 0.25 - z\right)}{y}
\end{array}
Initial program 99.6%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ -4.0 y))) (t_1 (* 4.0 (/ x y))))
(if (<= y -0.049)
2.0
(if (<= y -7e-53)
t_1
(if (<= y -1.3e-74)
t_0
(if (<= y -2.7e-200)
t_1
(if (<= y -9.5e-298)
t_0
(if (<= y 6e-284) t_1 (if (<= y 4.8e+97) t_0 2.0)))))))))
double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double t_1 = 4.0 * (x / y);
double tmp;
if (y <= -0.049) {
tmp = 2.0;
} else if (y <= -7e-53) {
tmp = t_1;
} else if (y <= -1.3e-74) {
tmp = t_0;
} else if (y <= -2.7e-200) {
tmp = t_1;
} else if (y <= -9.5e-298) {
tmp = t_0;
} else if (y <= 6e-284) {
tmp = t_1;
} else if (y <= 4.8e+97) {
tmp = t_0;
} 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 = z * ((-4.0d0) / y)
t_1 = 4.0d0 * (x / y)
if (y <= (-0.049d0)) then
tmp = 2.0d0
else if (y <= (-7d-53)) then
tmp = t_1
else if (y <= (-1.3d-74)) then
tmp = t_0
else if (y <= (-2.7d-200)) then
tmp = t_1
else if (y <= (-9.5d-298)) then
tmp = t_0
else if (y <= 6d-284) then
tmp = t_1
else if (y <= 4.8d+97) then
tmp = t_0
else
tmp = 2.0d0
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 = 4.0 * (x / y);
double tmp;
if (y <= -0.049) {
tmp = 2.0;
} else if (y <= -7e-53) {
tmp = t_1;
} else if (y <= -1.3e-74) {
tmp = t_0;
} else if (y <= -2.7e-200) {
tmp = t_1;
} else if (y <= -9.5e-298) {
tmp = t_0;
} else if (y <= 6e-284) {
tmp = t_1;
} else if (y <= 4.8e+97) {
tmp = t_0;
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): t_0 = z * (-4.0 / y) t_1 = 4.0 * (x / y) tmp = 0 if y <= -0.049: tmp = 2.0 elif y <= -7e-53: tmp = t_1 elif y <= -1.3e-74: tmp = t_0 elif y <= -2.7e-200: tmp = t_1 elif y <= -9.5e-298: tmp = t_0 elif y <= 6e-284: tmp = t_1 elif y <= 4.8e+97: tmp = t_0 else: tmp = 2.0 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-4.0 / y)) t_1 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (y <= -0.049) tmp = 2.0; elseif (y <= -7e-53) tmp = t_1; elseif (y <= -1.3e-74) tmp = t_0; elseif (y <= -2.7e-200) tmp = t_1; elseif (y <= -9.5e-298) tmp = t_0; elseif (y <= 6e-284) tmp = t_1; elseif (y <= 4.8e+97) tmp = t_0; else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (-4.0 / y); t_1 = 4.0 * (x / y); tmp = 0.0; if (y <= -0.049) tmp = 2.0; elseif (y <= -7e-53) tmp = t_1; elseif (y <= -1.3e-74) tmp = t_0; elseif (y <= -2.7e-200) tmp = t_1; elseif (y <= -9.5e-298) tmp = t_0; elseif (y <= 6e-284) tmp = t_1; elseif (y <= 4.8e+97) tmp = t_0; else tmp = 2.0; 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[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.049], 2.0, If[LessEqual[y, -7e-53], t$95$1, If[LessEqual[y, -1.3e-74], t$95$0, If[LessEqual[y, -2.7e-200], t$95$1, If[LessEqual[y, -9.5e-298], t$95$0, If[LessEqual[y, 6e-284], t$95$1, If[LessEqual[y, 4.8e+97], t$95$0, 2.0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{-4}{y}\\
t_1 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;y \leq -0.049:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq -7 \cdot 10^{-53}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.3 \cdot 10^{-74}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -2.7 \cdot 10^{-200}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -9.5 \cdot 10^{-298}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 6 \cdot 10^{-284}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 4.8 \cdot 10^{+97}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -0.049000000000000002 or 4.8e97 < y Initial program 99.1%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 64.0%
if -0.049000000000000002 < y < -6.99999999999999987e-53 or -1.3e-74 < y < -2.7000000000000001e-200 or -9.50000000000000012e-298 < y < 5.9999999999999999e-284Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around inf 66.8%
if -6.99999999999999987e-53 < y < -1.3e-74 or -2.7000000000000001e-200 < y < -9.50000000000000012e-298 or 5.9999999999999999e-284 < y < 4.8e97Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around inf 62.5%
associate-*r/62.5%
metadata-eval62.5%
associate-*r*62.5%
neg-mul-162.5%
associate-*l/62.3%
distribute-rgt-neg-out62.3%
*-commutative62.3%
distribute-rgt-neg-in62.3%
distribute-neg-frac62.3%
metadata-eval62.3%
Simplified62.3%
Final simplification63.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ z y) -4.0)) (t_1 (* 4.0 (/ x y))))
(if (<= y -0.037)
2.0
(if (<= y -7.8e-54)
t_1
(if (<= y -2.8e-78)
t_0
(if (<= y -3e-201)
t_1
(if (<= y -1.85e-298)
t_0
(if (<= y 1.95e-283) t_1 (if (<= y 7.4e+102) t_0 2.0)))))))))
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 (y <= -0.037) {
tmp = 2.0;
} else if (y <= -7.8e-54) {
tmp = t_1;
} else if (y <= -2.8e-78) {
tmp = t_0;
} else if (y <= -3e-201) {
tmp = t_1;
} else if (y <= -1.85e-298) {
tmp = t_0;
} else if (y <= 1.95e-283) {
tmp = t_1;
} else if (y <= 7.4e+102) {
tmp = t_0;
} 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 = (z / y) * (-4.0d0)
t_1 = 4.0d0 * (x / y)
if (y <= (-0.037d0)) then
tmp = 2.0d0
else if (y <= (-7.8d-54)) then
tmp = t_1
else if (y <= (-2.8d-78)) then
tmp = t_0
else if (y <= (-3d-201)) then
tmp = t_1
else if (y <= (-1.85d-298)) then
tmp = t_0
else if (y <= 1.95d-283) then
tmp = t_1
else if (y <= 7.4d+102) then
tmp = t_0
else
tmp = 2.0d0
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 (y <= -0.037) {
tmp = 2.0;
} else if (y <= -7.8e-54) {
tmp = t_1;
} else if (y <= -2.8e-78) {
tmp = t_0;
} else if (y <= -3e-201) {
tmp = t_1;
} else if (y <= -1.85e-298) {
tmp = t_0;
} else if (y <= 1.95e-283) {
tmp = t_1;
} else if (y <= 7.4e+102) {
tmp = t_0;
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): t_0 = (z / y) * -4.0 t_1 = 4.0 * (x / y) tmp = 0 if y <= -0.037: tmp = 2.0 elif y <= -7.8e-54: tmp = t_1 elif y <= -2.8e-78: tmp = t_0 elif y <= -3e-201: tmp = t_1 elif y <= -1.85e-298: tmp = t_0 elif y <= 1.95e-283: tmp = t_1 elif y <= 7.4e+102: tmp = t_0 else: tmp = 2.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z / y) * -4.0) t_1 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (y <= -0.037) tmp = 2.0; elseif (y <= -7.8e-54) tmp = t_1; elseif (y <= -2.8e-78) tmp = t_0; elseif (y <= -3e-201) tmp = t_1; elseif (y <= -1.85e-298) tmp = t_0; elseif (y <= 1.95e-283) tmp = t_1; elseif (y <= 7.4e+102) tmp = t_0; else tmp = 2.0; 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 (y <= -0.037) tmp = 2.0; elseif (y <= -7.8e-54) tmp = t_1; elseif (y <= -2.8e-78) tmp = t_0; elseif (y <= -3e-201) tmp = t_1; elseif (y <= -1.85e-298) tmp = t_0; elseif (y <= 1.95e-283) tmp = t_1; elseif (y <= 7.4e+102) tmp = t_0; else tmp = 2.0; 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[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -0.037], 2.0, If[LessEqual[y, -7.8e-54], t$95$1, If[LessEqual[y, -2.8e-78], t$95$0, If[LessEqual[y, -3e-201], t$95$1, If[LessEqual[y, -1.85e-298], t$95$0, If[LessEqual[y, 1.95e-283], t$95$1, If[LessEqual[y, 7.4e+102], t$95$0, 2.0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z}{y} \cdot -4\\
t_1 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;y \leq -0.037:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq -7.8 \cdot 10^{-54}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -2.8 \cdot 10^{-78}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -3 \cdot 10^{-201}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq -1.85 \cdot 10^{-298}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 1.95 \cdot 10^{-283}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 7.4 \cdot 10^{+102}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -0.0369999999999999982 or 7.40000000000000045e102 < y Initial program 99.1%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 64.0%
if -0.0369999999999999982 < y < -7.8e-54 or -2.80000000000000024e-78 < y < -3.00000000000000002e-201 or -1.8499999999999999e-298 < y < 1.9500000000000001e-283Initial program 99.9%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in x around inf 66.8%
if -7.8e-54 < y < -2.80000000000000024e-78 or -3.00000000000000002e-201 < y < -1.8499999999999999e-298 or 1.9500000000000001e-283 < y < 7.40000000000000045e102Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in z around inf 62.5%
*-commutative62.5%
Simplified62.5%
Final simplification63.9%
(FPCore (x y z)
:precision binary64
(if (<= y -7.5e+171)
2.0
(if (or (<= y -1.3e+115) (and (not (<= y -1.15e+60)) (<= y 2.5e+129)))
(* 4.0 (/ (- x z) y))
2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -7.5e+171) {
tmp = 2.0;
} else if ((y <= -1.3e+115) || (!(y <= -1.15e+60) && (y <= 2.5e+129))) {
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 <= (-7.5d+171)) then
tmp = 2.0d0
else if ((y <= (-1.3d+115)) .or. (.not. (y <= (-1.15d+60))) .and. (y <= 2.5d+129)) 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 <= -7.5e+171) {
tmp = 2.0;
} else if ((y <= -1.3e+115) || (!(y <= -1.15e+60) && (y <= 2.5e+129))) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -7.5e+171: tmp = 2.0 elif (y <= -1.3e+115) or (not (y <= -1.15e+60) and (y <= 2.5e+129)): tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -7.5e+171) tmp = 2.0; elseif ((y <= -1.3e+115) || (!(y <= -1.15e+60) && (y <= 2.5e+129))) 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 <= -7.5e+171) tmp = 2.0; elseif ((y <= -1.3e+115) || (~((y <= -1.15e+60)) && (y <= 2.5e+129))) tmp = 4.0 * ((x - z) / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -7.5e+171], 2.0, If[Or[LessEqual[y, -1.3e+115], And[N[Not[LessEqual[y, -1.15e+60]], $MachinePrecision], LessEqual[y, 2.5e+129]]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.5 \cdot 10^{+171}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq -1.3 \cdot 10^{+115} \lor \neg \left(y \leq -1.15 \cdot 10^{+60}\right) \land y \leq 2.5 \cdot 10^{+129}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -7.4999999999999998e171 or -1.3e115 < y < -1.15000000000000008e60 or 2.5000000000000001e129 < y Initial program 98.7%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 76.3%
if -7.4999999999999998e171 < y < -1.3e115 or -1.15000000000000008e60 < y < 2.5000000000000001e129Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 84.9%
Final simplification82.3%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 2.0 (* 4.0 (/ x y)))))
(if (<= x -3.2e+69)
t_0
(if (<= x 1.65e-63)
(+ 2.0 (* (/ z y) -4.0))
(if (<= x 2.4e+41) t_0 (* 4.0 (/ (- x z) y)))))))
double code(double x, double y, double z) {
double t_0 = 2.0 + (4.0 * (x / y));
double tmp;
if (x <= -3.2e+69) {
tmp = t_0;
} else if (x <= 1.65e-63) {
tmp = 2.0 + ((z / y) * -4.0);
} else if (x <= 2.4e+41) {
tmp = t_0;
} 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) :: t_0
real(8) :: tmp
t_0 = 2.0d0 + (4.0d0 * (x / y))
if (x <= (-3.2d+69)) then
tmp = t_0
else if (x <= 1.65d-63) then
tmp = 2.0d0 + ((z / y) * (-4.0d0))
else if (x <= 2.4d+41) then
tmp = t_0
else
tmp = 4.0d0 * ((x - z) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 2.0 + (4.0 * (x / y));
double tmp;
if (x <= -3.2e+69) {
tmp = t_0;
} else if (x <= 1.65e-63) {
tmp = 2.0 + ((z / y) * -4.0);
} else if (x <= 2.4e+41) {
tmp = t_0;
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): t_0 = 2.0 + (4.0 * (x / y)) tmp = 0 if x <= -3.2e+69: tmp = t_0 elif x <= 1.65e-63: tmp = 2.0 + ((z / y) * -4.0) elif x <= 2.4e+41: tmp = t_0 else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) t_0 = Float64(2.0 + Float64(4.0 * Float64(x / y))) tmp = 0.0 if (x <= -3.2e+69) tmp = t_0; elseif (x <= 1.65e-63) tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); elseif (x <= 2.4e+41) tmp = t_0; else tmp = Float64(4.0 * Float64(Float64(x - z) / y)); end return tmp end
function tmp_2 = code(x, y, z) t_0 = 2.0 + (4.0 * (x / y)); tmp = 0.0; if (x <= -3.2e+69) tmp = t_0; elseif (x <= 1.65e-63) tmp = 2.0 + ((z / y) * -4.0); elseif (x <= 2.4e+41) tmp = t_0; else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.2e+69], t$95$0, If[LessEqual[x, 1.65e-63], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 2.4e+41], t$95$0, N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 2 + 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -3.2 \cdot 10^{+69}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-63}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\mathbf{elif}\;x \leq 2.4 \cdot 10^{+41}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if x < -3.19999999999999985e69 or 1.64999999999999997e-63 < x < 2.4000000000000002e41Initial 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-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 90.2%
if -3.19999999999999985e69 < x < 1.64999999999999997e-63Initial program 99.2%
+-commutative99.2%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
+-commutative99.7%
distribute-lft-in99.8%
associate-+l+99.8%
associate-*l/99.8%
*-commutative99.8%
associate-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 93.4%
*-commutative93.4%
Simplified93.4%
if 2.4000000000000002e41 < x Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 89.1%
Final simplification91.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -2e-5) (not (<= y 6.2e+92))) (+ 2.0 (* 4.0 (/ x y))) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -2e-5) || !(y <= 6.2e+92)) {
tmp = 2.0 + (4.0 * (x / 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 <= (-2d-5)) .or. (.not. (y <= 6.2d+92))) then
tmp = 2.0d0 + (4.0d0 * (x / 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 <= -2e-5) || !(y <= 6.2e+92)) {
tmp = 2.0 + (4.0 * (x / y));
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -2e-5) or not (y <= 6.2e+92): tmp = 2.0 + (4.0 * (x / y)) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -2e-5) || !(y <= 6.2e+92)) tmp = Float64(2.0 + Float64(4.0 * Float64(x / 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 <= -2e-5) || ~((y <= 6.2e+92))) tmp = 2.0 + (4.0 * (x / y)); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -2e-5], N[Not[LessEqual[y, 6.2e+92]], $MachinePrecision]], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{-5} \lor \neg \left(y \leq 6.2 \cdot 10^{+92}\right):\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -2.00000000000000016e-5 or 6.2000000000000004e92 < y Initial program 99.1%
+-commutative99.1%
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-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 86.4%
if -2.00000000000000016e-5 < y < 6.2000000000000004e92Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around 0 90.4%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.6e+115) (not (<= x 6e+39))) (* 4.0 (/ x y)) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.6e+115) || !(x <= 6e+39)) {
tmp = 4.0 * (x / 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 <= (-1.6d+115)) .or. (.not. (x <= 6d+39))) then
tmp = 4.0d0 * (x / 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 <= -1.6e+115) || !(x <= 6e+39)) {
tmp = 4.0 * (x / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.6e+115) or not (x <= 6e+39): tmp = 4.0 * (x / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.6e+115) || !(x <= 6e+39)) tmp = Float64(4.0 * Float64(x / y)); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.6e+115) || ~((x <= 6e+39))) tmp = 4.0 * (x / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.6e+115], N[Not[LessEqual[x, 6e+39]], $MachinePrecision]], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.6 \cdot 10^{+115} \lor \neg \left(x \leq 6 \cdot 10^{+39}\right):\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if x < -1.6e115 or 5.9999999999999999e39 < x Initial program 100.0%
associate-/l*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in x around inf 73.1%
if -1.6e115 < x < 5.9999999999999999e39Initial program 99.4%
associate-/l*99.9%
associate--l+99.9%
Simplified99.9%
Taylor expanded in y around inf 46.8%
Final simplification56.3%
(FPCore (x y z) :precision binary64 (+ (* (/ 4.0 y) (- x z)) 2.0))
double code(double x, double y, double z) {
return ((4.0 / y) * (x - 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 / y) * (x - z)) + 2.0d0
end function
public static double code(double x, double y, double z) {
return ((4.0 / y) * (x - z)) + 2.0;
}
def code(x, y, z): return ((4.0 / y) * (x - z)) + 2.0
function code(x, y, z) return Float64(Float64(Float64(4.0 / y) * Float64(x - z)) + 2.0) end
function tmp = code(x, y, z) tmp = ((4.0 / y) * (x - z)) + 2.0; end
code[x_, y_, z_] := N[(N[(N[(4.0 / y), $MachinePrecision] * N[(x - z), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{4}{y} \cdot \left(x - z\right) + 2
\end{array}
Initial program 99.6%
+-commutative99.6%
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-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.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*100.0%
associate--l+100.0%
Simplified100.0%
Taylor expanded in y around inf 34.4%
Final simplification34.4%
herbie shell --seed 2024071
(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)))