
(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 11 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 (/ (* 4.0 x) y)) (t_1 (* (/ z y) -4.0)))
(if (<= x -5.5e+58)
t_0
(if (<= x -2.4e-160)
t_1
(if (<= x 6.8e-228) 2.0 (if (<= x 0.00185) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = (4.0 * x) / y;
double t_1 = (z / y) * -4.0;
double tmp;
if (x <= -5.5e+58) {
tmp = t_0;
} else if (x <= -2.4e-160) {
tmp = t_1;
} else if (x <= 6.8e-228) {
tmp = 2.0;
} else if (x <= 0.00185) {
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 = (4.0d0 * x) / y
t_1 = (z / y) * (-4.0d0)
if (x <= (-5.5d+58)) then
tmp = t_0
else if (x <= (-2.4d-160)) then
tmp = t_1
else if (x <= 6.8d-228) then
tmp = 2.0d0
else if (x <= 0.00185d0) 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 = (4.0 * x) / y;
double t_1 = (z / y) * -4.0;
double tmp;
if (x <= -5.5e+58) {
tmp = t_0;
} else if (x <= -2.4e-160) {
tmp = t_1;
} else if (x <= 6.8e-228) {
tmp = 2.0;
} else if (x <= 0.00185) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (4.0 * x) / y t_1 = (z / y) * -4.0 tmp = 0 if x <= -5.5e+58: tmp = t_0 elif x <= -2.4e-160: tmp = t_1 elif x <= 6.8e-228: tmp = 2.0 elif x <= 0.00185: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(4.0 * x) / y) t_1 = Float64(Float64(z / y) * -4.0) tmp = 0.0 if (x <= -5.5e+58) tmp = t_0; elseif (x <= -2.4e-160) tmp = t_1; elseif (x <= 6.8e-228) tmp = 2.0; elseif (x <= 0.00185) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (4.0 * x) / y; t_1 = (z / y) * -4.0; tmp = 0.0; if (x <= -5.5e+58) tmp = t_0; elseif (x <= -2.4e-160) tmp = t_1; elseif (x <= 6.8e-228) tmp = 2.0; elseif (x <= 0.00185) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(4.0 * x), $MachinePrecision] / y), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]}, If[LessEqual[x, -5.5e+58], t$95$0, If[LessEqual[x, -2.4e-160], t$95$1, If[LessEqual[x, 6.8e-228], 2.0, If[LessEqual[x, 0.00185], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{4 \cdot x}{y}\\
t_1 := \frac{z}{y} \cdot -4\\
\mathbf{if}\;x \leq -5.5 \cdot 10^{+58}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.4 \cdot 10^{-160}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 6.8 \cdot 10^{-228}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 0.00185:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.4999999999999999e58 or 0.0018500000000000001 < x Initial program 100.0%
Taylor expanded in x around inf 67.5%
associate-*r/67.5%
Simplified67.5%
if -5.4999999999999999e58 < x < -2.39999999999999991e-160 or 6.79999999999999981e-228 < x < 0.0018500000000000001Initial program 99.9%
Taylor expanded in z around inf 56.4%
*-commutative56.4%
Simplified56.4%
if -2.39999999999999991e-160 < x < 6.79999999999999981e-228Initial program 100.0%
Taylor expanded in y around inf 59.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ 4.0 (/ y x))) (t_1 (* (/ z y) -4.0)))
(if (<= x -1.7e+59)
t_0
(if (<= x -2.15e-156)
t_1
(if (<= x 2e-226) 2.0 (if (<= x 0.025) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = 4.0 / (y / x);
double t_1 = (z / y) * -4.0;
double tmp;
if (x <= -1.7e+59) {
tmp = t_0;
} else if (x <= -2.15e-156) {
tmp = t_1;
} else if (x <= 2e-226) {
tmp = 2.0;
} else if (x <= 0.025) {
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 = 4.0d0 / (y / x)
t_1 = (z / y) * (-4.0d0)
if (x <= (-1.7d+59)) then
tmp = t_0
else if (x <= (-2.15d-156)) then
tmp = t_1
else if (x <= 2d-226) then
tmp = 2.0d0
else if (x <= 0.025d0) 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 = 4.0 / (y / x);
double t_1 = (z / y) * -4.0;
double tmp;
if (x <= -1.7e+59) {
tmp = t_0;
} else if (x <= -2.15e-156) {
tmp = t_1;
} else if (x <= 2e-226) {
tmp = 2.0;
} else if (x <= 0.025) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 / (y / x) t_1 = (z / y) * -4.0 tmp = 0 if x <= -1.7e+59: tmp = t_0 elif x <= -2.15e-156: tmp = t_1 elif x <= 2e-226: tmp = 2.0 elif x <= 0.025: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 / Float64(y / x)) t_1 = Float64(Float64(z / y) * -4.0) tmp = 0.0 if (x <= -1.7e+59) tmp = t_0; elseif (x <= -2.15e-156) tmp = t_1; elseif (x <= 2e-226) tmp = 2.0; elseif (x <= 0.025) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 / (y / x); t_1 = (z / y) * -4.0; tmp = 0.0; if (x <= -1.7e+59) tmp = t_0; elseif (x <= -2.15e-156) tmp = t_1; elseif (x <= 2e-226) tmp = 2.0; elseif (x <= 0.025) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 / N[(y / x), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]}, If[LessEqual[x, -1.7e+59], t$95$0, If[LessEqual[x, -2.15e-156], t$95$1, If[LessEqual[x, 2e-226], 2.0, If[LessEqual[x, 0.025], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{4}{\frac{y}{x}}\\
t_1 := \frac{z}{y} \cdot -4\\
\mathbf{if}\;x \leq -1.7 \cdot 10^{+59}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -2.15 \cdot 10^{-156}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-226}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 0.025:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.70000000000000003e59 or 0.025000000000000001 < x Initial program 100.0%
Taylor expanded in y around 0 80.8%
clear-num80.6%
un-div-inv80.6%
Applied egg-rr80.6%
Taylor expanded in x around inf 67.5%
associate-*r/67.5%
associate-*l/67.3%
associate-/r/67.3%
Simplified67.3%
if -1.70000000000000003e59 < x < -2.14999999999999989e-156 or 1.99999999999999984e-226 < x < 0.025000000000000001Initial program 99.9%
Taylor expanded in z around inf 56.4%
*-commutative56.4%
Simplified56.4%
if -2.14999999999999989e-156 < x < 1.99999999999999984e-226Initial program 100.0%
Taylor expanded in y around inf 59.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.9e+59) (not (<= x 0.032))) (+ 2.0 (* 4.0 (/ x y))) (+ 2.0 (* (/ z y) -4.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.9e+59) || !(x <= 0.032)) {
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 ((x <= (-1.9d+59)) .or. (.not. (x <= 0.032d0))) 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 ((x <= -1.9e+59) || !(x <= 0.032)) {
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 (x <= -1.9e+59) or not (x <= 0.032): 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 ((x <= -1.9e+59) || !(x <= 0.032)) tmp = Float64(2.0 + Float64(4.0 * Float64(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 ((x <= -1.9e+59) || ~((x <= 0.032))) 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[Or[LessEqual[x, -1.9e+59], N[Not[LessEqual[x, 0.032]], $MachinePrecision]], N[(2.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{+59} \lor \neg \left(x \leq 0.032\right):\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if x < -1.9e59 or 0.032000000000000001 < 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-*r*99.8%
metadata-eval99.8%
*-lft-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 86.5%
if -1.9e59 < x < 0.032000000000000001Initial 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-*r*99.8%
metadata-eval99.8%
*-lft-identity99.8%
*-inverses99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 93.4%
*-commutative93.4%
Simplified93.4%
Final simplification90.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -4.4e+83) (not (<= y 1.1e+94))) (+ 2.0 (* 4.0 (/ x y))) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -4.4e+83) || !(y <= 1.1e+94)) {
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 <= (-4.4d+83)) .or. (.not. (y <= 1.1d+94))) 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 <= -4.4e+83) || !(y <= 1.1e+94)) {
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 <= -4.4e+83) or not (y <= 1.1e+94): 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 <= -4.4e+83) || !(y <= 1.1e+94)) 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 <= -4.4e+83) || ~((y <= 1.1e+94))) 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, -4.4e+83], N[Not[LessEqual[y, 1.1e+94]], $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 -4.4 \cdot 10^{+83} \lor \neg \left(y \leq 1.1 \cdot 10^{+94}\right):\\
\;\;\;\;2 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -4.39999999999999997e83 or 1.10000000000000006e94 < y Initial program 99.9%
+-commutative99.9%
associate-*l/99.9%
+-commutative99.9%
associate--l+99.9%
+-commutative99.9%
distribute-lft-in99.8%
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 z around 0 88.1%
if -4.39999999999999997e83 < y < 1.10000000000000006e94Initial program 100.0%
Taylor expanded in y around 0 88.7%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.25e+185) 2.0 (if (<= y 7.2e+95) (* 4.0 (/ (- x z) y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.25e+185) {
tmp = 2.0;
} else if (y <= 7.2e+95) {
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.25d+185)) then
tmp = 2.0d0
else if (y <= 7.2d+95) 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.25e+185) {
tmp = 2.0;
} else if (y <= 7.2e+95) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.25e+185: tmp = 2.0 elif y <= 7.2e+95: tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.25e+185) tmp = 2.0; elseif (y <= 7.2e+95) 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.25e+185) tmp = 2.0; elseif (y <= 7.2e+95) tmp = 4.0 * ((x - z) / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.25e+185], 2.0, If[LessEqual[y, 7.2e+95], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{+185}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{+95}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -1.24999999999999997e185 or 7.19999999999999955e95 < y Initial program 100.0%
Taylor expanded in y around inf 79.3%
if -1.24999999999999997e185 < y < 7.19999999999999955e95Initial program 100.0%
Taylor expanded in y around 0 83.6%
(FPCore (x y z) :precision binary64 (if (<= y -1.35e+79) 2.0 (if (<= y 1.12e+94) (* (/ z y) -4.0) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.35e+79) {
tmp = 2.0;
} else if (y <= 1.12e+94) {
tmp = (z / y) * -4.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) :: tmp
if (y <= (-1.35d+79)) then
tmp = 2.0d0
else if (y <= 1.12d+94) then
tmp = (z / y) * (-4.0d0)
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.35e+79) {
tmp = 2.0;
} else if (y <= 1.12e+94) {
tmp = (z / y) * -4.0;
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.35e+79: tmp = 2.0 elif y <= 1.12e+94: tmp = (z / y) * -4.0 else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.35e+79) tmp = 2.0; elseif (y <= 1.12e+94) tmp = Float64(Float64(z / y) * -4.0); else tmp = 2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.35e+79) tmp = 2.0; elseif (y <= 1.12e+94) tmp = (z / y) * -4.0; else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.35e+79], 2.0, If[LessEqual[y, 1.12e+94], N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+79}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 1.12 \cdot 10^{+94}:\\
\;\;\;\;\frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -1.35e79 or 1.11999999999999996e94 < y Initial program 99.9%
Taylor expanded in y around inf 70.8%
if -1.35e79 < y < 1.11999999999999996e94Initial program 100.0%
Taylor expanded in z around inf 49.6%
*-commutative49.6%
Simplified49.6%
(FPCore (x y z) :precision binary64 (if (<= y -2.95e+80) 2.0 (if (<= y 1.15e+95) (* z (/ -4.0 y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.95e+80) {
tmp = 2.0;
} else if (y <= 1.15e+95) {
tmp = 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.95d+80)) then
tmp = 2.0d0
else if (y <= 1.15d+95) then
tmp = 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.95e+80) {
tmp = 2.0;
} else if (y <= 1.15e+95) {
tmp = z * (-4.0 / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.95e+80: tmp = 2.0 elif y <= 1.15e+95: tmp = z * (-4.0 / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.95e+80) tmp = 2.0; elseif (y <= 1.15e+95) tmp = Float64(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.95e+80) tmp = 2.0; elseif (y <= 1.15e+95) tmp = z * (-4.0 / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.95e+80], 2.0, If[LessEqual[y, 1.15e+95], N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.95 \cdot 10^{+80}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 1.15 \cdot 10^{+95}:\\
\;\;\;\;z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -2.94999999999999986e80 or 1.14999999999999999e95 < y Initial program 99.9%
Taylor expanded in y around inf 70.8%
if -2.94999999999999986e80 < y < 1.14999999999999999e95Initial program 100.0%
Taylor expanded in z around inf 49.6%
associate-*r/49.6%
*-commutative49.6%
associate-/l*49.5%
Simplified49.5%
(FPCore (x y z) :precision binary64 (+ (/ 1.0 (/ y (* 4.0 (- x z)))) 2.0))
double code(double x, double y, double z) {
return (1.0 / (y / (4.0 * (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 = (1.0d0 / (y / (4.0d0 * (x - z)))) + 2.0d0
end function
public static double code(double x, double y, double z) {
return (1.0 / (y / (4.0 * (x - z)))) + 2.0;
}
def code(x, y, z): return (1.0 / (y / (4.0 * (x - z)))) + 2.0
function code(x, y, z) return Float64(Float64(1.0 / Float64(y / Float64(4.0 * Float64(x - z)))) + 2.0) end
function tmp = code(x, y, z) tmp = (1.0 / (y / (4.0 * (x - z)))) + 2.0; end
code[x_, y_, z_] := N[(N[(1.0 / N[(y / N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] + 2.0), $MachinePrecision]
\begin{array}{l}
\\
\frac{1}{\frac{y}{4 \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%
associate-*l/100.0%
clear-num99.8%
Applied egg-rr99.8%
(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-*r*99.8%
metadata-eval99.8%
*-lft-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 33.1%
herbie shell --seed 2024185
(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)))