
(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 8 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.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%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (<= y -2.2e+96)
2.0
(if (or (<= y 2.15e+73) (and (not (<= y 6.2e+120)) (<= y 3.5e+155)))
(* (- x z) (/ 4.0 y))
2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.2e+96) {
tmp = 2.0;
} else if ((y <= 2.15e+73) || (!(y <= 6.2e+120) && (y <= 3.5e+155))) {
tmp = (x - z) * (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 (y <= (-2.2d+96)) then
tmp = 2.0d0
else if ((y <= 2.15d+73) .or. (.not. (y <= 6.2d+120)) .and. (y <= 3.5d+155)) then
tmp = (x - z) * (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 (y <= -2.2e+96) {
tmp = 2.0;
} else if ((y <= 2.15e+73) || (!(y <= 6.2e+120) && (y <= 3.5e+155))) {
tmp = (x - z) * (4.0 / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.2e+96: tmp = 2.0 elif (y <= 2.15e+73) or (not (y <= 6.2e+120) and (y <= 3.5e+155)): tmp = (x - z) * (4.0 / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.2e+96) tmp = 2.0; elseif ((y <= 2.15e+73) || (!(y <= 6.2e+120) && (y <= 3.5e+155))) tmp = Float64(Float64(x - z) * Float64(4.0 / y)); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.2e+96) tmp = 2.0; elseif ((y <= 2.15e+73) || (~((y <= 6.2e+120)) && (y <= 3.5e+155))) tmp = (x - z) * (4.0 / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.2e+96], 2.0, If[Or[LessEqual[y, 2.15e+73], And[N[Not[LessEqual[y, 6.2e+120]], $MachinePrecision], LessEqual[y, 3.5e+155]]], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.2 \cdot 10^{+96}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 2.15 \cdot 10^{+73} \lor \neg \left(y \leq 6.2 \cdot 10^{+120}\right) \land y \leq 3.5 \cdot 10^{+155}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -2.1999999999999999e96 or 2.15000000000000007e73 < y < 6.19999999999999947e120 or 3.49999999999999985e155 < y Initial program 100.0%
Taylor expanded in y around inf 78.9%
if -2.1999999999999999e96 < y < 2.15000000000000007e73 or 6.19999999999999947e120 < y < 3.49999999999999985e155Initial 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-*l*99.7%
metadata-eval99.7%
*-rgt-identity99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
clear-num99.7%
div-inv99.7%
metadata-eval99.7%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
div-sub97.1%
*-un-lft-identity97.1%
*-commutative97.1%
times-frac97.1%
metadata-eval97.1%
associate-/l*97.1%
associate-+l-97.1%
*-commutative97.1%
associate-/l*97.0%
Applied egg-rr97.0%
Taylor expanded in y around 0 84.2%
distribute-lft-out--84.2%
*-commutative84.2%
associate-*r/83.9%
Simplified83.9%
Final simplification82.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ z y) -4.0)))
(if (<= y -660000000.0)
2.0
(if (<= y -2.1e-279)
t_0
(if (<= y 3.8e-101) (* 4.0 (/ x y)) (if (<= y 3.7e+66) t_0 2.0))))))
double code(double x, double y, double z) {
double t_0 = (z / y) * -4.0;
double tmp;
if (y <= -660000000.0) {
tmp = 2.0;
} else if (y <= -2.1e-279) {
tmp = t_0;
} else if (y <= 3.8e-101) {
tmp = 4.0 * (x / y);
} else if (y <= 3.7e+66) {
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) :: tmp
t_0 = (z / y) * (-4.0d0)
if (y <= (-660000000.0d0)) then
tmp = 2.0d0
else if (y <= (-2.1d-279)) then
tmp = t_0
else if (y <= 3.8d-101) then
tmp = 4.0d0 * (x / y)
else if (y <= 3.7d+66) 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 tmp;
if (y <= -660000000.0) {
tmp = 2.0;
} else if (y <= -2.1e-279) {
tmp = t_0;
} else if (y <= 3.8e-101) {
tmp = 4.0 * (x / y);
} else if (y <= 3.7e+66) {
tmp = t_0;
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): t_0 = (z / y) * -4.0 tmp = 0 if y <= -660000000.0: tmp = 2.0 elif y <= -2.1e-279: tmp = t_0 elif y <= 3.8e-101: tmp = 4.0 * (x / y) elif y <= 3.7e+66: tmp = t_0 else: tmp = 2.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(z / y) * -4.0) tmp = 0.0 if (y <= -660000000.0) tmp = 2.0; elseif (y <= -2.1e-279) tmp = t_0; elseif (y <= 3.8e-101) tmp = Float64(4.0 * Float64(x / y)); elseif (y <= 3.7e+66) tmp = t_0; else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (z / y) * -4.0; tmp = 0.0; if (y <= -660000000.0) tmp = 2.0; elseif (y <= -2.1e-279) tmp = t_0; elseif (y <= 3.8e-101) tmp = 4.0 * (x / y); elseif (y <= 3.7e+66) 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]}, If[LessEqual[y, -660000000.0], 2.0, If[LessEqual[y, -2.1e-279], t$95$0, If[LessEqual[y, 3.8e-101], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.7e+66], t$95$0, 2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z}{y} \cdot -4\\
\mathbf{if}\;y \leq -660000000:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq -2.1 \cdot 10^{-279}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq 3.8 \cdot 10^{-101}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{elif}\;y \leq 3.7 \cdot 10^{+66}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -6.6e8 or 3.7e66 < y Initial program 100.0%
Taylor expanded in y around inf 65.2%
if -6.6e8 < y < -2.10000000000000006e-279 or 3.8000000000000001e-101 < y < 3.7e66Initial program 100.0%
+-commutative100.0%
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-*l*99.7%
metadata-eval99.7%
*-rgt-identity99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
clear-num99.7%
div-inv99.7%
metadata-eval99.7%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
div-sub96.8%
*-un-lft-identity96.8%
*-commutative96.8%
times-frac96.8%
metadata-eval96.8%
associate-/l*96.8%
associate-+l-96.8%
*-commutative96.8%
associate-/l*96.7%
Applied egg-rr96.7%
Taylor expanded in z around inf 56.5%
*-commutative56.5%
Simplified56.5%
if -2.10000000000000006e-279 < y < 3.8000000000000001e-101Initial program 99.9%
+-commutative99.9%
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/99.9%
*-un-lft-identity99.9%
Applied egg-rr99.9%
div-sub95.6%
*-un-lft-identity95.6%
*-commutative95.6%
times-frac95.6%
metadata-eval95.6%
associate-/l*95.6%
associate-+l-95.6%
*-commutative95.6%
associate-/l*95.5%
Applied egg-rr95.5%
Taylor expanded in x around inf 69.7%
Final simplification62.8%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.4e+46) (not (<= y 2.5e-57))) (+ 2.0 (* (/ z y) -4.0)) (* (- x z) (/ 4.0 y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.4e+46) || !(y <= 2.5e-57)) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = (x - 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 ((y <= (-6.4d+46)) .or. (.not. (y <= 2.5d-57))) then
tmp = 2.0d0 + ((z / y) * (-4.0d0))
else
tmp = (x - z) * (4.0d0 / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -6.4e+46) || !(y <= 2.5e-57)) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = (x - z) * (4.0 / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.4e+46) or not (y <= 2.5e-57): tmp = 2.0 + ((z / y) * -4.0) else: tmp = (x - z) * (4.0 / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -6.4e+46) || !(y <= 2.5e-57)) tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); else tmp = Float64(Float64(x - z) * Float64(4.0 / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -6.4e+46) || ~((y <= 2.5e-57))) tmp = 2.0 + ((z / y) * -4.0); else tmp = (x - z) * (4.0 / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -6.4e+46], N[Not[LessEqual[y, 2.5e-57]], $MachinePrecision]], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{+46} \lor \neg \left(y \leq 2.5 \cdot 10^{-57}\right):\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;\left(x - z\right) \cdot \frac{4}{y}\\
\end{array}
\end{array}
if y < -6.3999999999999996e46 or 2.5000000000000001e-57 < y 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.9%
associate-*l/99.9%
*-commutative99.9%
associate-*l*99.9%
metadata-eval99.9%
*-rgt-identity99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 81.0%
+-commutative81.0%
*-commutative81.0%
Simplified81.0%
if -6.3999999999999996e46 < y < 2.5000000000000001e-57Initial 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-*l*99.7%
metadata-eval99.7%
*-rgt-identity99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
clear-num99.7%
div-inv99.7%
metadata-eval99.7%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
div-sub96.2%
*-un-lft-identity96.2%
*-commutative96.2%
times-frac96.2%
metadata-eval96.2%
associate-/l*96.2%
associate-+l-96.2%
*-commutative96.2%
associate-/l*96.0%
Applied egg-rr96.0%
Taylor expanded in y around 0 89.6%
distribute-lft-out--89.6%
*-commutative89.6%
associate-*r/89.4%
Simplified89.4%
Final simplification85.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.75e+60) (not (<= z 9.2e+51))) (+ 2.0 (* (/ z y) -4.0)) (+ 2.0 (/ (* x 4.0) y))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.75e+60) || !(z <= 9.2e+51)) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = 2.0 + ((x * 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 ((z <= (-2.75d+60)) .or. (.not. (z <= 9.2d+51))) then
tmp = 2.0d0 + ((z / y) * (-4.0d0))
else
tmp = 2.0d0 + ((x * 4.0d0) / y)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -2.75e+60) || !(z <= 9.2e+51)) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = 2.0 + ((x * 4.0) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.75e+60) or not (z <= 9.2e+51): tmp = 2.0 + ((z / y) * -4.0) else: tmp = 2.0 + ((x * 4.0) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.75e+60) || !(z <= 9.2e+51)) tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); else tmp = Float64(2.0 + Float64(Float64(x * 4.0) / y)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.75e+60) || ~((z <= 9.2e+51))) tmp = 2.0 + ((z / y) * -4.0); else tmp = 2.0 + ((x * 4.0) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.75e+60], N[Not[LessEqual[z, 9.2e+51]], $MachinePrecision]], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(x * 4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.75 \cdot 10^{+60} \lor \neg \left(z \leq 9.2 \cdot 10^{+51}\right):\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{x \cdot 4}{y}\\
\end{array}
\end{array}
if z < -2.75e60 or 9.2000000000000002e51 < 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-*l*99.8%
metadata-eval99.8%
*-rgt-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 91.8%
+-commutative91.8%
*-commutative91.8%
Simplified91.8%
if -2.75e60 < z < 9.2000000000000002e51Initial program 99.9%
+-commutative99.9%
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 94.6%
+-commutative94.6%
associate-*r/94.6%
Simplified94.6%
Final simplification93.6%
(FPCore (x y z) :precision binary64 (if (<= y -6.4e+46) 2.0 (if (<= y 2.5e-57) (* 4.0 (/ x y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.4e+46) {
tmp = 2.0;
} else if (y <= 2.5e-57) {
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 (y <= (-6.4d+46)) then
tmp = 2.0d0
else if (y <= 2.5d-57) 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 (y <= -6.4e+46) {
tmp = 2.0;
} else if (y <= 2.5e-57) {
tmp = 4.0 * (x / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.4e+46: tmp = 2.0 elif y <= 2.5e-57: tmp = 4.0 * (x / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.4e+46) tmp = 2.0; elseif (y <= 2.5e-57) 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 (y <= -6.4e+46) tmp = 2.0; elseif (y <= 2.5e-57) tmp = 4.0 * (x / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.4e+46], 2.0, If[LessEqual[y, 2.5e-57], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.4 \cdot 10^{+46}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 2.5 \cdot 10^{-57}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -6.3999999999999996e46 or 2.5000000000000001e-57 < y Initial program 100.0%
Taylor expanded in y around inf 62.0%
if -6.3999999999999996e46 < y < 2.5000000000000001e-57Initial 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-*l*99.7%
metadata-eval99.7%
*-rgt-identity99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
clear-num99.7%
div-inv99.7%
metadata-eval99.7%
associate-*l/100.0%
*-un-lft-identity100.0%
Applied egg-rr100.0%
div-sub96.2%
*-un-lft-identity96.2%
*-commutative96.2%
times-frac96.2%
metadata-eval96.2%
associate-/l*96.2%
associate-+l-96.2%
*-commutative96.2%
associate-/l*96.0%
Applied egg-rr96.0%
Taylor expanded in x around inf 52.0%
Final simplification56.9%
(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.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%
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 35.6%
Final simplification35.6%
herbie shell --seed 2024053
(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)))