
(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 (+ (/ (- x z) (* y 0.25)) 2.0))
double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 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 = ((x - z) / (y * 0.25d0)) + 2.0d0
end function
public static double code(double x, double y, double z) {
return ((x - z) / (y * 0.25)) + 2.0;
}
def code(x, y, z): return ((x - z) / (y * 0.25)) + 2.0
function code(x, y, z) return Float64(Float64(Float64(x - z) / Float64(y * 0.25)) + 2.0) end
function tmp = code(x, y, z) tmp = ((x - z) / (y * 0.25)) + 2.0; end
code[x_, y_, z_] := N[(N[(N[(x - z), $MachinePrecision] / N[(y * 0.25), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{x - z}{y \cdot 0.25} + 2
\end{array}
Initial program 100.0%
+-commutative100.0%
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%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
(FPCore (x y z)
:precision binary64
(if (or (<= z -1e+218)
(not (or (<= z -4e+113) (and (not (<= z -2.2e+61)) (<= z 3.4e+112)))))
(+ 1.0 (* -4.0 (/ z y)))
(+ 2.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+218) || !((z <= -4e+113) || (!(z <= -2.2e+61) && (z <= 3.4e+112)))) {
tmp = 1.0 + (-4.0 * (z / y));
} else {
tmp = 2.0 + (4.0 * (x / y));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((z <= (-1d+218)) .or. (.not. (z <= (-4d+113)) .or. (.not. (z <= (-2.2d+61))) .and. (z <= 3.4d+112))) then
tmp = 1.0d0 + ((-4.0d0) * (z / y))
else
tmp = 2.0d0 + (4.0d0 * (x / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+218) || !((z <= -4e+113) || (!(z <= -2.2e+61) && (z <= 3.4e+112)))) {
tmp = 1.0 + (-4.0 * (z / y));
} else {
tmp = 2.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1e+218) or not ((z <= -4e+113) or (not (z <= -2.2e+61) and (z <= 3.4e+112))): tmp = 1.0 + (-4.0 * (z / y)) else: tmp = 2.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1e+218) || !((z <= -4e+113) || (!(z <= -2.2e+61) && (z <= 3.4e+112)))) tmp = Float64(1.0 + Float64(-4.0 * Float64(z / y))); else tmp = Float64(2.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1e+218) || ~(((z <= -4e+113) || (~((z <= -2.2e+61)) && (z <= 3.4e+112))))) tmp = 1.0 + (-4.0 * (z / y)); else tmp = 2.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1e+218], N[Not[Or[LessEqual[z, -4e+113], And[N[Not[LessEqual[z, -2.2e+61]], $MachinePrecision], LessEqual[z, 3.4e+112]]]], $MachinePrecision]], N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{+218} \lor \neg \left(z \leq -4 \cdot 10^{+113} \lor \neg \left(z \leq -2.2 \cdot 10^{+61}\right) \land z \leq 3.4 \cdot 10^{+112}\right):\\
\;\;\;\;1 + -4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -1.00000000000000008e218 or -4e113 < z < -2.2e61 or 3.39999999999999993e112 < z Initial program 100.0%
Taylor expanded in z around inf 83.0%
*-commutative83.0%
Simplified83.0%
if -1.00000000000000008e218 < z < -4e113 or -2.2e61 < z < 3.39999999999999993e112Initial 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%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 81.8%
Final simplification82.1%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* -4.0 (/ z y)))) (t_1 (+ 1.0 (/ (* x 4.0) y))))
(if (<= x -3.55e+47)
t_1
(if (<= x -2e-119)
t_0
(if (<= x -1.55e-192) 2.0 (if (<= x 1550000000.0) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (-4.0 * (z / y));
double t_1 = 1.0 + ((x * 4.0) / y);
double tmp;
if (x <= -3.55e+47) {
tmp = t_1;
} else if (x <= -2e-119) {
tmp = t_0;
} else if (x <= -1.55e-192) {
tmp = 2.0;
} else if (x <= 1550000000.0) {
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 = 1.0d0 + ((-4.0d0) * (z / y))
t_1 = 1.0d0 + ((x * 4.0d0) / y)
if (x <= (-3.55d+47)) then
tmp = t_1
else if (x <= (-2d-119)) then
tmp = t_0
else if (x <= (-1.55d-192)) then
tmp = 2.0d0
else if (x <= 1550000000.0d0) 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 = 1.0 + (-4.0 * (z / y));
double t_1 = 1.0 + ((x * 4.0) / y);
double tmp;
if (x <= -3.55e+47) {
tmp = t_1;
} else if (x <= -2e-119) {
tmp = t_0;
} else if (x <= -1.55e-192) {
tmp = 2.0;
} else if (x <= 1550000000.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (-4.0 * (z / y)) t_1 = 1.0 + ((x * 4.0) / y) tmp = 0 if x <= -3.55e+47: tmp = t_1 elif x <= -2e-119: tmp = t_0 elif x <= -1.55e-192: tmp = 2.0 elif x <= 1550000000.0: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(-4.0 * Float64(z / y))) t_1 = Float64(1.0 + Float64(Float64(x * 4.0) / y)) tmp = 0.0 if (x <= -3.55e+47) tmp = t_1; elseif (x <= -2e-119) tmp = t_0; elseif (x <= -1.55e-192) tmp = 2.0; elseif (x <= 1550000000.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (-4.0 * (z / y)); t_1 = 1.0 + ((x * 4.0) / y); tmp = 0.0; if (x <= -3.55e+47) tmp = t_1; elseif (x <= -2e-119) tmp = t_0; elseif (x <= -1.55e-192) tmp = 2.0; elseif (x <= 1550000000.0) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -3.55e+47], t$95$1, If[LessEqual[x, -2e-119], t$95$0, If[LessEqual[x, -1.55e-192], 2.0, If[LessEqual[x, 1550000000.0], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -4 \cdot \frac{z}{y}\\
t_1 := 1 + \frac{x \cdot 4}{y}\\
\mathbf{if}\;x \leq -3.55 \cdot 10^{+47}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2 \cdot 10^{-119}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.55 \cdot 10^{-192}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 1550000000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -3.5500000000000001e47 or 1.55e9 < x Initial program 100.0%
Taylor expanded in x around inf 70.9%
*-commutative70.9%
associate-*l/70.9%
Simplified70.9%
if -3.5500000000000001e47 < x < -2.00000000000000003e-119 or -1.55e-192 < x < 1.55e9Initial program 99.9%
Taylor expanded in z around inf 61.4%
*-commutative61.4%
Simplified61.4%
if -2.00000000000000003e-119 < x < -1.55e-192Initial program 100.0%
Taylor expanded in y around inf 74.5%
Final simplification66.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* -4.0 (/ z y)))) (t_1 (+ 1.0 (* x (/ 4.0 y)))))
(if (<= x -8.5e+78)
t_1
(if (<= x -2.5e-120)
t_0
(if (<= x -1.6e-192) 2.0 (if (<= x 34000.0) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (-4.0 * (z / y));
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -8.5e+78) {
tmp = t_1;
} else if (x <= -2.5e-120) {
tmp = t_0;
} else if (x <= -1.6e-192) {
tmp = 2.0;
} else if (x <= 34000.0) {
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 = 1.0d0 + ((-4.0d0) * (z / y))
t_1 = 1.0d0 + (x * (4.0d0 / y))
if (x <= (-8.5d+78)) then
tmp = t_1
else if (x <= (-2.5d-120)) then
tmp = t_0
else if (x <= (-1.6d-192)) then
tmp = 2.0d0
else if (x <= 34000.0d0) 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 = 1.0 + (-4.0 * (z / y));
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -8.5e+78) {
tmp = t_1;
} else if (x <= -2.5e-120) {
tmp = t_0;
} else if (x <= -1.6e-192) {
tmp = 2.0;
} else if (x <= 34000.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (-4.0 * (z / y)) t_1 = 1.0 + (x * (4.0 / y)) tmp = 0 if x <= -8.5e+78: tmp = t_1 elif x <= -2.5e-120: tmp = t_0 elif x <= -1.6e-192: tmp = 2.0 elif x <= 34000.0: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(-4.0 * Float64(z / y))) t_1 = Float64(1.0 + Float64(x * Float64(4.0 / y))) tmp = 0.0 if (x <= -8.5e+78) tmp = t_1; elseif (x <= -2.5e-120) tmp = t_0; elseif (x <= -1.6e-192) tmp = 2.0; elseif (x <= 34000.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (-4.0 * (z / y)); t_1 = 1.0 + (x * (4.0 / y)); tmp = 0.0; if (x <= -8.5e+78) tmp = t_1; elseif (x <= -2.5e-120) tmp = t_0; elseif (x <= -1.6e-192) tmp = 2.0; elseif (x <= 34000.0) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8.5e+78], t$95$1, If[LessEqual[x, -2.5e-120], t$95$0, If[LessEqual[x, -1.6e-192], 2.0, If[LessEqual[x, 34000.0], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + -4 \cdot \frac{z}{y}\\
t_1 := 1 + x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{+78}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -2.5 \cdot 10^{-120}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.6 \cdot 10^{-192}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 34000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -8.50000000000000079e78 or 34000 < x Initial program 100.0%
Taylor expanded in x around inf 73.1%
associate-*r/73.1%
associate-*l/72.9%
*-commutative72.9%
Simplified72.9%
if -8.50000000000000079e78 < x < -2.50000000000000003e-120 or -1.6000000000000001e-192 < x < 34000Initial program 99.9%
Taylor expanded in z around inf 60.1%
*-commutative60.1%
Simplified60.1%
if -2.50000000000000003e-120 < x < -1.6000000000000001e-192Initial program 100.0%
Taylor expanded in y around inf 74.5%
Final simplification66.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* z (/ -4.0 y)))) (t_1 (+ 1.0 (* x (/ 4.0 y)))))
(if (<= x -1e+79)
t_1
(if (<= x -7.8e-121)
t_0
(if (<= x -1.65e-192) 2.0 (if (<= x 820000000.0) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (z * (-4.0 / y));
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -1e+79) {
tmp = t_1;
} else if (x <= -7.8e-121) {
tmp = t_0;
} else if (x <= -1.65e-192) {
tmp = 2.0;
} else if (x <= 820000000.0) {
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 = 1.0d0 + (z * ((-4.0d0) / y))
t_1 = 1.0d0 + (x * (4.0d0 / y))
if (x <= (-1d+79)) then
tmp = t_1
else if (x <= (-7.8d-121)) then
tmp = t_0
else if (x <= (-1.65d-192)) then
tmp = 2.0d0
else if (x <= 820000000.0d0) 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 = 1.0 + (z * (-4.0 / y));
double t_1 = 1.0 + (x * (4.0 / y));
double tmp;
if (x <= -1e+79) {
tmp = t_1;
} else if (x <= -7.8e-121) {
tmp = t_0;
} else if (x <= -1.65e-192) {
tmp = 2.0;
} else if (x <= 820000000.0) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (z * (-4.0 / y)) t_1 = 1.0 + (x * (4.0 / y)) tmp = 0 if x <= -1e+79: tmp = t_1 elif x <= -7.8e-121: tmp = t_0 elif x <= -1.65e-192: tmp = 2.0 elif x <= 820000000.0: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(z * Float64(-4.0 / y))) t_1 = Float64(1.0 + Float64(x * Float64(4.0 / y))) tmp = 0.0 if (x <= -1e+79) tmp = t_1; elseif (x <= -7.8e-121) tmp = t_0; elseif (x <= -1.65e-192) tmp = 2.0; elseif (x <= 820000000.0) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (z * (-4.0 / y)); t_1 = 1.0 + (x * (4.0 / y)); tmp = 0.0; if (x <= -1e+79) tmp = t_1; elseif (x <= -7.8e-121) tmp = t_0; elseif (x <= -1.65e-192) tmp = 2.0; elseif (x <= 820000000.0) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1e+79], t$95$1, If[LessEqual[x, -7.8e-121], t$95$0, If[LessEqual[x, -1.65e-192], 2.0, If[LessEqual[x, 820000000.0], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + z \cdot \frac{-4}{y}\\
t_1 := 1 + x \cdot \frac{4}{y}\\
\mathbf{if}\;x \leq -1 \cdot 10^{+79}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -7.8 \cdot 10^{-121}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.65 \cdot 10^{-192}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 820000000:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if x < -9.99999999999999967e78 or 8.2e8 < x Initial program 100.0%
Taylor expanded in x around inf 73.1%
associate-*r/73.1%
associate-*l/72.9%
*-commutative72.9%
Simplified72.9%
if -9.99999999999999967e78 < x < -7.80000000000000001e-121 or -1.64999999999999995e-192 < x < 8.2e8Initial program 99.9%
Taylor expanded in z around inf 60.1%
associate-*r/60.1%
metadata-eval60.1%
associate-*r*60.1%
neg-mul-160.1%
*-commutative60.1%
associate-*r/59.9%
distribute-lft-neg-out59.9%
distribute-rgt-neg-in59.9%
distribute-neg-frac59.9%
metadata-eval59.9%
Simplified59.9%
if -7.80000000000000001e-121 < x < -1.64999999999999995e-192Initial program 100.0%
Taylor expanded in y around inf 74.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.5e+40) (not (<= x 320000000.0))) (+ 2.0 (* 4.0 (/ x y))) (+ 2.0 (/ (* z -4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.5e+40) || !(x <= 320000000.0)) {
tmp = 2.0 + (4.0 * (x / y));
} else {
tmp = 2.0 + ((z * -4.0) / y);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-8.5d+40)) .or. (.not. (x <= 320000000.0d0))) then
tmp = 2.0d0 + (4.0d0 * (x / y))
else
tmp = 2.0d0 + ((z * (-4.0d0)) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -8.5e+40) || !(x <= 320000000.0)) {
tmp = 2.0 + (4.0 * (x / y));
} else {
tmp = 2.0 + ((z * -4.0) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.5e+40) or not (x <= 320000000.0): tmp = 2.0 + (4.0 * (x / y)) else: tmp = 2.0 + ((z * -4.0) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.5e+40) || !(x <= 320000000.0)) tmp = Float64(2.0 + Float64(4.0 * Float64(x / y))); else tmp = Float64(2.0 + Float64(Float64(z * -4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8.5e+40) || ~((x <= 320000000.0))) tmp = 2.0 + (4.0 * (x / y)); else tmp = 2.0 + ((z * -4.0) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.5e+40], N[Not[LessEqual[x, 320000000.0]], $MachinePrecision]], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.5 \cdot 10^{+40} \lor \neg \left(x \leq 320000000\right):\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{z \cdot -4}{y}\\
\end{array}
\end{array}
if x < -8.49999999999999996e40 or 3.2e8 < x 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-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around inf 88.5%
if -8.49999999999999996e40 < x < 3.2e8Initial program 99.9%
+-commutative99.9%
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%
clear-num99.8%
div-inv99.8%
metadata-eval99.8%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
Taylor expanded in x around 0 95.2%
associate-*r/95.2%
Simplified95.2%
Final simplification92.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.6e+72) (not (<= x 6.5e-45))) (+ 1.0 (* x (/ 4.0 y))) 2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.6e+72) || !(x <= 6.5e-45)) {
tmp = 1.0 + (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 <= (-3.6d+72)) .or. (.not. (x <= 6.5d-45))) then
tmp = 1.0d0 + (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 <= -3.6e+72) || !(x <= 6.5e-45)) {
tmp = 1.0 + (x * (4.0 / y));
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.6e+72) or not (x <= 6.5e-45): tmp = 1.0 + (x * (4.0 / y)) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.6e+72) || !(x <= 6.5e-45)) tmp = Float64(1.0 + 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 <= -3.6e+72) || ~((x <= 6.5e-45))) tmp = 1.0 + (x * (4.0 / y)); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.6e+72], N[Not[LessEqual[x, 6.5e-45]], $MachinePrecision]], N[(1.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.6 \cdot 10^{+72} \lor \neg \left(x \leq 6.5 \cdot 10^{-45}\right):\\
\;\;\;\;1 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if x < -3.60000000000000035e72 or 6.4999999999999995e-45 < x Initial program 100.0%
Taylor expanded in x around inf 69.6%
associate-*r/69.6%
associate-*l/69.4%
*-commutative69.4%
Simplified69.4%
if -3.60000000000000035e72 < x < 6.4999999999999995e-45Initial program 99.9%
Taylor expanded in y around inf 47.0%
Final simplification57.5%
(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 100.0%
+-commutative100.0%
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%
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 100.0%
Taylor expanded in y around inf 34.5%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = 1.0d0
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 100.0%
Taylor expanded in x around inf 39.9%
associate-*r/39.9%
associate-*l/39.8%
*-commutative39.8%
Simplified39.8%
Taylor expanded in x around 0 8.6%
herbie shell --seed 2024101
(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)))