
(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(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}
Initial program 100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ z y) -4.0)) (t_1 (/ (* 4.0 x) y)))
(if (<= z -6e+62)
t_0
(if (<= z 3.3e-306)
t_1
(if (<= z 2.4e-137) 2.0 (if (<= z 1.15e+21) t_1 t_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 (z <= -6e+62) {
tmp = t_0;
} else if (z <= 3.3e-306) {
tmp = t_1;
} else if (z <= 2.4e-137) {
tmp = 2.0;
} else if (z <= 1.15e+21) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (z / y) * (-4.0d0)
t_1 = (4.0d0 * x) / y
if (z <= (-6d+62)) then
tmp = t_0
else if (z <= 3.3d-306) then
tmp = t_1
else if (z <= 2.4d-137) then
tmp = 2.0d0
else if (z <= 1.15d+21) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z / y) * -4.0;
double t_1 = (4.0 * x) / y;
double tmp;
if (z <= -6e+62) {
tmp = t_0;
} else if (z <= 3.3e-306) {
tmp = t_1;
} else if (z <= 2.4e-137) {
tmp = 2.0;
} else if (z <= 1.15e+21) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z / y) * -4.0 t_1 = (4.0 * x) / y tmp = 0 if z <= -6e+62: tmp = t_0 elif z <= 3.3e-306: tmp = t_1 elif z <= 2.4e-137: tmp = 2.0 elif z <= 1.15e+21: tmp = t_1 else: tmp = t_0 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 (z <= -6e+62) tmp = t_0; elseif (z <= 3.3e-306) tmp = t_1; elseif (z <= 2.4e-137) tmp = 2.0; elseif (z <= 1.15e+21) tmp = t_1; else tmp = t_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 (z <= -6e+62) tmp = t_0; elseif (z <= 3.3e-306) tmp = t_1; elseif (z <= 2.4e-137) tmp = 2.0; elseif (z <= 1.15e+21) tmp = t_1; else tmp = t_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[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[z, -6e+62], t$95$0, If[LessEqual[z, 3.3e-306], t$95$1, If[LessEqual[z, 2.4e-137], 2.0, If[LessEqual[z, 1.15e+21], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z}{y} \cdot -4\\
t_1 := \frac{4 \cdot x}{y}\\
\mathbf{if}\;z \leq -6 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 3.3 \cdot 10^{-306}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.4 \cdot 10^{-137}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+21}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -6e62 or 1.15e21 < z Initial program 100.0%
Taylor expanded in z around inf 67.8%
*-commutative67.8%
Simplified67.8%
if -6e62 < z < 3.3000000000000001e-306 or 2.4e-137 < z < 1.15e21Initial program 100.0%
Taylor expanded in x around inf 53.9%
associate-*r/53.9%
Simplified53.9%
if 3.3000000000000001e-306 < z < 2.4e-137Initial program 100.0%
Taylor expanded in y around inf 66.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ z y) -4.0)) (t_1 (* x (/ 4.0 y))))
(if (<= z -8.5e+62)
t_0
(if (<= z 1e-308)
t_1
(if (<= z 2.2e-137) 2.0 (if (<= z 6e+19) t_1 t_0))))))
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 (z <= -8.5e+62) {
tmp = t_0;
} else if (z <= 1e-308) {
tmp = t_1;
} else if (z <= 2.2e-137) {
tmp = 2.0;
} else if (z <= 6e+19) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = (z / y) * (-4.0d0)
t_1 = x * (4.0d0 / y)
if (z <= (-8.5d+62)) then
tmp = t_0
else if (z <= 1d-308) then
tmp = t_1
else if (z <= 2.2d-137) then
tmp = 2.0d0
else if (z <= 6d+19) then
tmp = t_1
else
tmp = t_0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = (z / y) * -4.0;
double t_1 = x * (4.0 / y);
double tmp;
if (z <= -8.5e+62) {
tmp = t_0;
} else if (z <= 1e-308) {
tmp = t_1;
} else if (z <= 2.2e-137) {
tmp = 2.0;
} else if (z <= 6e+19) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (z / y) * -4.0 t_1 = x * (4.0 / y) tmp = 0 if z <= -8.5e+62: tmp = t_0 elif z <= 1e-308: tmp = t_1 elif z <= 2.2e-137: tmp = 2.0 elif z <= 6e+19: tmp = t_1 else: tmp = t_0 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 (z <= -8.5e+62) tmp = t_0; elseif (z <= 1e-308) tmp = t_1; elseif (z <= 2.2e-137) tmp = 2.0; elseif (z <= 6e+19) tmp = t_1; else tmp = t_0; 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 (z <= -8.5e+62) tmp = t_0; elseif (z <= 1e-308) tmp = t_1; elseif (z <= 2.2e-137) tmp = 2.0; elseif (z <= 6e+19) tmp = t_1; else tmp = t_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[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -8.5e+62], t$95$0, If[LessEqual[z, 1e-308], t$95$1, If[LessEqual[z, 2.2e-137], 2.0, If[LessEqual[z, 6e+19], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{z}{y} \cdot -4\\
t_1 := x \cdot \frac{4}{y}\\
\mathbf{if}\;z \leq -8.5 \cdot 10^{+62}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 10^{-308}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 2.2 \cdot 10^{-137}:\\
\;\;\;\;2\\
\mathbf{elif}\;z \leq 6 \cdot 10^{+19}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if z < -8.4999999999999997e62 or 6e19 < z Initial program 100.0%
Taylor expanded in z around inf 67.8%
*-commutative67.8%
Simplified67.8%
if -8.4999999999999997e62 < z < 9.9999999999999991e-309 or 2.2000000000000001e-137 < z < 6e19Initial program 100.0%
Taylor expanded in x around inf 53.9%
associate-*r/53.9%
associate-*l/53.8%
*-commutative53.8%
Simplified53.8%
if 9.9999999999999991e-309 < z < 2.2000000000000001e-137Initial program 100.0%
Taylor expanded in y around inf 66.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.2e+47) (not (<= y 4.1e+99))) (+ 2.0 (* x (/ 4.0 y))) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.2e+47) || !(y <= 4.1e+99)) {
tmp = 2.0 + (x * (4.0 / 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 <= (-1.2d+47)) .or. (.not. (y <= 4.1d+99))) then
tmp = 2.0d0 + (x * (4.0d0 / 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 <= -1.2e+47) || !(y <= 4.1e+99)) {
tmp = 2.0 + (x * (4.0 / y));
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.2e+47) or not (y <= 4.1e+99): tmp = 2.0 + (x * (4.0 / y)) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.2e+47) || !(y <= 4.1e+99)) tmp = Float64(2.0 + Float64(x * Float64(4.0 / 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 <= -1.2e+47) || ~((y <= 4.1e+99))) tmp = 2.0 + (x * (4.0 / y)); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.2e+47], N[Not[LessEqual[y, 4.1e+99]], $MachinePrecision]], N[(2.0 + N[(x * N[(4.0 / 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 -1.2 \cdot 10^{+47} \lor \neg \left(y \leq 4.1 \cdot 10^{+99}\right):\\
\;\;\;\;2 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -1.20000000000000009e47 or 4.09999999999999979e99 < y Initial program 100.0%
+-commutative100.0%
associate-*l/99.9%
+-commutative99.9%
associate--l+99.9%
+-commutative99.9%
distribute-lft-in99.9%
associate-+l+99.9%
associate-*l/99.9%
*-commutative99.9%
associate-*r*99.9%
metadata-eval99.9%
*-lft-identity99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around inf 86.6%
if -1.20000000000000009e47 < y < 4.09999999999999979e99Initial program 100.0%
Taylor expanded in y around 0 91.3%
Final simplification89.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.5e+28) (not (<= y 1.65e+83))) (+ 2.0 (* (/ z y) -4.0)) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.5e+28) || !(y <= 1.65e+83)) {
tmp = 2.0 + ((z / y) * -4.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) :: tmp
if ((y <= (-4.5d+28)) .or. (.not. (y <= 1.65d+83))) then
tmp = 2.0d0 + ((z / y) * (-4.0d0))
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 <= -4.5e+28) || !(y <= 1.65e+83)) {
tmp = 2.0 + ((z / y) * -4.0);
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -4.5e+28) or not (y <= 1.65e+83): tmp = 2.0 + ((z / y) * -4.0) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -4.5e+28) || !(y <= 1.65e+83)) tmp = Float64(2.0 + Float64(Float64(z / y) * -4.0)); 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 <= -4.5e+28) || ~((y <= 1.65e+83))) tmp = 2.0 + ((z / y) * -4.0); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -4.5e+28], N[Not[LessEqual[y, 1.65e+83]], $MachinePrecision]], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -4.5 \cdot 10^{+28} \lor \neg \left(y \leq 1.65 \cdot 10^{+83}\right):\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -4.4999999999999997e28 or 1.64999999999999992e83 < y Initial program 100.0%
+-commutative100.0%
associate-*l/99.9%
+-commutative99.9%
associate--l+99.9%
+-commutative99.9%
distribute-lft-in99.9%
associate-+l+99.9%
associate-*l/99.9%
*-commutative99.9%
associate-*r*99.9%
metadata-eval99.9%
*-lft-identity99.9%
*-inverses99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 84.3%
*-commutative84.3%
Simplified84.3%
if -4.4999999999999997e28 < y < 1.64999999999999992e83Initial program 100.0%
Taylor expanded in y around 0 92.2%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (<= y -1.95e+149) 2.0 (if (<= y 6.9e+215) (* 4.0 (/ (- x z) y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.95e+149) {
tmp = 2.0;
} else if (y <= 6.9e+215) {
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 <= (-1.95d+149)) then
tmp = 2.0d0
else if (y <= 6.9d+215) 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 <= -1.95e+149) {
tmp = 2.0;
} else if (y <= 6.9e+215) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.95e+149: tmp = 2.0 elif y <= 6.9e+215: tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.95e+149) tmp = 2.0; elseif (y <= 6.9e+215) 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 <= -1.95e+149) tmp = 2.0; elseif (y <= 6.9e+215) tmp = 4.0 * ((x - z) / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.95e+149], 2.0, If[LessEqual[y, 6.9e+215], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.95 \cdot 10^{+149}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 6.9 \cdot 10^{+215}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -1.95e149 or 6.8999999999999996e215 < y Initial program 100.0%
Taylor expanded in y around inf 93.5%
if -1.95e149 < y < 6.8999999999999996e215Initial program 100.0%
Taylor expanded in y around 0 83.3%
(FPCore (x y z) :precision binary64 (if (<= y -2e+29) 2.0 (if (<= y 3.4e+86) (* x (/ 4.0 y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2e+29) {
tmp = 2.0;
} else if (y <= 3.4e+86) {
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 (y <= (-2d+29)) then
tmp = 2.0d0
else if (y <= 3.4d+86) 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 (y <= -2e+29) {
tmp = 2.0;
} else if (y <= 3.4e+86) {
tmp = x * (4.0 / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2e+29: tmp = 2.0 elif y <= 3.4e+86: tmp = x * (4.0 / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2e+29) tmp = 2.0; elseif (y <= 3.4e+86) 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 (y <= -2e+29) tmp = 2.0; elseif (y <= 3.4e+86) tmp = x * (4.0 / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2e+29], 2.0, If[LessEqual[y, 3.4e+86], N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2 \cdot 10^{+29}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 3.4 \cdot 10^{+86}:\\
\;\;\;\;x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -1.99999999999999983e29 or 3.3999999999999998e86 < y Initial program 100.0%
Taylor expanded in y around inf 68.0%
if -1.99999999999999983e29 < y < 3.3999999999999998e86Initial program 100.0%
Taylor expanded in x around inf 44.4%
associate-*r/44.4%
associate-*l/44.3%
*-commutative44.3%
Simplified44.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 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%
(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 33.1%
herbie shell --seed 2024181
(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)))