
(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 (/ (* 4.0 x) y)) (t_1 (* (/ z y) -4.0)))
(if (<= x -6.6e+72)
t_0
(if (<= x -1.1e-168)
t_1
(if (<= x -9.6e-259)
2.0
(if (<= x 1.55e-291)
t_1
(if (<= x 2e-135) 2.0 (if (<= x 1.4e-26) 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 <= -6.6e+72) {
tmp = t_0;
} else if (x <= -1.1e-168) {
tmp = t_1;
} else if (x <= -9.6e-259) {
tmp = 2.0;
} else if (x <= 1.55e-291) {
tmp = t_1;
} else if (x <= 2e-135) {
tmp = 2.0;
} else if (x <= 1.4e-26) {
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 <= (-6.6d+72)) then
tmp = t_0
else if (x <= (-1.1d-168)) then
tmp = t_1
else if (x <= (-9.6d-259)) then
tmp = 2.0d0
else if (x <= 1.55d-291) then
tmp = t_1
else if (x <= 2d-135) then
tmp = 2.0d0
else if (x <= 1.4d-26) 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 <= -6.6e+72) {
tmp = t_0;
} else if (x <= -1.1e-168) {
tmp = t_1;
} else if (x <= -9.6e-259) {
tmp = 2.0;
} else if (x <= 1.55e-291) {
tmp = t_1;
} else if (x <= 2e-135) {
tmp = 2.0;
} else if (x <= 1.4e-26) {
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 <= -6.6e+72: tmp = t_0 elif x <= -1.1e-168: tmp = t_1 elif x <= -9.6e-259: tmp = 2.0 elif x <= 1.55e-291: tmp = t_1 elif x <= 2e-135: tmp = 2.0 elif x <= 1.4e-26: 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 <= -6.6e+72) tmp = t_0; elseif (x <= -1.1e-168) tmp = t_1; elseif (x <= -9.6e-259) tmp = 2.0; elseif (x <= 1.55e-291) tmp = t_1; elseif (x <= 2e-135) tmp = 2.0; elseif (x <= 1.4e-26) 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 <= -6.6e+72) tmp = t_0; elseif (x <= -1.1e-168) tmp = t_1; elseif (x <= -9.6e-259) tmp = 2.0; elseif (x <= 1.55e-291) tmp = t_1; elseif (x <= 2e-135) tmp = 2.0; elseif (x <= 1.4e-26) 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, -6.6e+72], t$95$0, If[LessEqual[x, -1.1e-168], t$95$1, If[LessEqual[x, -9.6e-259], 2.0, If[LessEqual[x, 1.55e-291], t$95$1, If[LessEqual[x, 2e-135], 2.0, If[LessEqual[x, 1.4e-26], 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 -6.6 \cdot 10^{+72}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.1 \cdot 10^{-168}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -9.6 \cdot 10^{-259}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 1.55 \cdot 10^{-291}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2 \cdot 10^{-135}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -6.6e72 or 1.4000000000000001e-26 < x Initial program 100.0%
Taylor expanded in x around inf 71.3%
associate-*r/71.3%
Simplified71.3%
if -6.6e72 < x < -1.0999999999999999e-168 or -9.6000000000000002e-259 < x < 1.55000000000000006e-291 or 2.0000000000000001e-135 < x < 1.4000000000000001e-26Initial program 99.9%
Taylor expanded in z around inf 64.3%
*-commutative64.3%
Simplified64.3%
if -1.0999999999999999e-168 < x < -9.6000000000000002e-259 or 1.55000000000000006e-291 < x < 2.0000000000000001e-135Initial program 100.0%
Taylor expanded in y around inf 68.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ 4.0 (/ y x))) (t_1 (* (/ z y) -4.0)))
(if (<= x -9e+77)
t_0
(if (<= x -1.85e-167)
t_1
(if (<= x -6.8e-259)
2.0
(if (<= x 1.2e-291)
t_1
(if (<= x 6.2e-136) 2.0 (if (<= x 2.1e-26) 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 <= -9e+77) {
tmp = t_0;
} else if (x <= -1.85e-167) {
tmp = t_1;
} else if (x <= -6.8e-259) {
tmp = 2.0;
} else if (x <= 1.2e-291) {
tmp = t_1;
} else if (x <= 6.2e-136) {
tmp = 2.0;
} else if (x <= 2.1e-26) {
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 <= (-9d+77)) then
tmp = t_0
else if (x <= (-1.85d-167)) then
tmp = t_1
else if (x <= (-6.8d-259)) then
tmp = 2.0d0
else if (x <= 1.2d-291) then
tmp = t_1
else if (x <= 6.2d-136) then
tmp = 2.0d0
else if (x <= 2.1d-26) 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 <= -9e+77) {
tmp = t_0;
} else if (x <= -1.85e-167) {
tmp = t_1;
} else if (x <= -6.8e-259) {
tmp = 2.0;
} else if (x <= 1.2e-291) {
tmp = t_1;
} else if (x <= 6.2e-136) {
tmp = 2.0;
} else if (x <= 2.1e-26) {
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 <= -9e+77: tmp = t_0 elif x <= -1.85e-167: tmp = t_1 elif x <= -6.8e-259: tmp = 2.0 elif x <= 1.2e-291: tmp = t_1 elif x <= 6.2e-136: tmp = 2.0 elif x <= 2.1e-26: 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 <= -9e+77) tmp = t_0; elseif (x <= -1.85e-167) tmp = t_1; elseif (x <= -6.8e-259) tmp = 2.0; elseif (x <= 1.2e-291) tmp = t_1; elseif (x <= 6.2e-136) tmp = 2.0; elseif (x <= 2.1e-26) 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 <= -9e+77) tmp = t_0; elseif (x <= -1.85e-167) tmp = t_1; elseif (x <= -6.8e-259) tmp = 2.0; elseif (x <= 1.2e-291) tmp = t_1; elseif (x <= 6.2e-136) tmp = 2.0; elseif (x <= 2.1e-26) 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, -9e+77], t$95$0, If[LessEqual[x, -1.85e-167], t$95$1, If[LessEqual[x, -6.8e-259], 2.0, If[LessEqual[x, 1.2e-291], t$95$1, If[LessEqual[x, 6.2e-136], 2.0, If[LessEqual[x, 2.1e-26], 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 -9 \cdot 10^{+77}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq -1.85 \cdot 10^{-167}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq -6.8 \cdot 10^{-259}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-291}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 6.2 \cdot 10^{-136}:\\
\;\;\;\;2\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-26}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -9.00000000000000049e77 or 2.10000000000000008e-26 < x Initial program 100.0%
Taylor expanded in x around inf 71.3%
associate-*r/71.3%
Simplified71.3%
clear-num71.2%
inv-pow71.2%
*-un-lft-identity71.2%
times-frac71.2%
metadata-eval71.2%
Applied egg-rr71.2%
unpow-171.2%
associate-/r*71.2%
metadata-eval71.2%
Simplified71.2%
if -9.00000000000000049e77 < x < -1.8500000000000001e-167 or -6.80000000000000024e-259 < x < 1.20000000000000006e-291 or 6.2e-136 < x < 2.10000000000000008e-26Initial program 99.9%
Taylor expanded in z around inf 64.3%
*-commutative64.3%
Simplified64.3%
if -1.8500000000000001e-167 < x < -6.80000000000000024e-259 or 1.20000000000000006e-291 < x < 6.2e-136Initial program 100.0%
Taylor expanded in y around inf 68.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -5.3e+74) (not (<= x 2.1e-26))) (+ 2.0 (* x (/ 4.0 y))) (+ 2.0 (* (/ z y) -4.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5.3e+74) || !(x <= 2.1e-26)) {
tmp = 2.0 + (x * (4.0 / 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 <= (-5.3d+74)) .or. (.not. (x <= 2.1d-26))) then
tmp = 2.0d0 + (x * (4.0d0 / 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 <= -5.3e+74) || !(x <= 2.1e-26)) {
tmp = 2.0 + (x * (4.0 / y));
} else {
tmp = 2.0 + ((z / y) * -4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5.3e+74) or not (x <= 2.1e-26): tmp = 2.0 + (x * (4.0 / y)) else: tmp = 2.0 + ((z / y) * -4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5.3e+74) || !(x <= 2.1e-26)) tmp = Float64(2.0 + Float64(x * Float64(4.0 / 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 <= -5.3e+74) || ~((x <= 2.1e-26))) tmp = 2.0 + (x * (4.0 / y)); else tmp = 2.0 + ((z / y) * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5.3e+74], N[Not[LessEqual[x, 2.1e-26]], $MachinePrecision]], N[(2.0 + N[(x * N[(4.0 / 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 -5.3 \cdot 10^{+74} \lor \neg \left(x \leq 2.1 \cdot 10^{-26}\right):\\
\;\;\;\;2 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if x < -5.2999999999999998e74 or 2.10000000000000008e-26 < x Initial 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-*r*99.7%
metadata-eval99.7%
*-lft-identity99.7%
*-inverses99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 87.8%
if -5.2999999999999998e74 < x < 2.10000000000000008e-26Initial 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 x around 0 95.4%
*-commutative95.4%
Simplified95.4%
Final simplification92.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -7e+76) (not (<= x 3.1e+27))) (* 4.0 (/ (- x z) y)) (+ 2.0 (* (/ z y) -4.0))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -7e+76) || !(x <= 3.1e+27)) {
tmp = 4.0 * ((x - z) / 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 <= (-7d+76)) .or. (.not. (x <= 3.1d+27))) then
tmp = 4.0d0 * ((x - z) / 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 <= -7e+76) || !(x <= 3.1e+27)) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0 + ((z / y) * -4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -7e+76) or not (x <= 3.1e+27): tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 + ((z / y) * -4.0) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -7e+76) || !(x <= 3.1e+27)) tmp = Float64(4.0 * Float64(Float64(x - z) / 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 <= -7e+76) || ~((x <= 3.1e+27))) tmp = 4.0 * ((x - z) / y); else tmp = 2.0 + ((z / y) * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -7e+76], N[Not[LessEqual[x, 3.1e+27]], $MachinePrecision]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(2.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -7 \cdot 10^{+76} \lor \neg \left(x \leq 3.1 \cdot 10^{+27}\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if x < -7.00000000000000001e76 or 3.09999999999999996e27 < x Initial program 100.0%
Taylor expanded in y around 0 87.1%
if -7.00000000000000001e76 < x < 3.09999999999999996e27Initial 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 x around 0 92.7%
*-commutative92.7%
Simplified92.7%
Final simplification90.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.7e+87) 2.0 (if (<= y 3.2e+172) (* 4.0 (/ (- x z) y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.7e+87) {
tmp = 2.0;
} else if (y <= 3.2e+172) {
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.7d+87)) then
tmp = 2.0d0
else if (y <= 3.2d+172) 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.7e+87) {
tmp = 2.0;
} else if (y <= 3.2e+172) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.7e+87: tmp = 2.0 elif y <= 3.2e+172: tmp = 4.0 * ((x - z) / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.7e+87) tmp = 2.0; elseif (y <= 3.2e+172) 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.7e+87) tmp = 2.0; elseif (y <= 3.2e+172) tmp = 4.0 * ((x - z) / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.7e+87], 2.0, If[LessEqual[y, 3.2e+172], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.7 \cdot 10^{+87}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 3.2 \cdot 10^{+172}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -1.7000000000000001e87 or 3.19999999999999985e172 < y Initial program 100.0%
Taylor expanded in y around inf 72.0%
if -1.7000000000000001e87 < y < 3.19999999999999985e172Initial program 100.0%
Taylor expanded in y around 0 82.4%
(FPCore (x y z) :precision binary64 (if (<= y -6.5e-21) 2.0 (if (<= y 1.4e+14) (* z (/ -4.0 y)) 2.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e-21) {
tmp = 2.0;
} else if (y <= 1.4e+14) {
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 <= (-6.5d-21)) then
tmp = 2.0d0
else if (y <= 1.4d+14) 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 <= -6.5e-21) {
tmp = 2.0;
} else if (y <= 1.4e+14) {
tmp = z * (-4.0 / y);
} else {
tmp = 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.5e-21: tmp = 2.0 elif y <= 1.4e+14: tmp = z * (-4.0 / y) else: tmp = 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.5e-21) tmp = 2.0; elseif (y <= 1.4e+14) 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 <= -6.5e-21) tmp = 2.0; elseif (y <= 1.4e+14) tmp = z * (-4.0 / y); else tmp = 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.5e-21], 2.0, If[LessEqual[y, 1.4e+14], N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision], 2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{-21}:\\
\;\;\;\;2\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{+14}:\\
\;\;\;\;z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;2\\
\end{array}
\end{array}
if y < -6.49999999999999987e-21 or 1.4e14 < y Initial program 100.0%
Taylor expanded in y around inf 59.3%
if -6.49999999999999987e-21 < y < 1.4e14Initial program 100.0%
Taylor expanded in z around inf 52.6%
associate-*r/52.6%
*-commutative52.6%
associate-/l*53.2%
Simplified53.2%
(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 32.7%
herbie shell --seed 2024157
(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)))