
(FPCore (x y z) :precision binary64 (+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\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.75)) z)) y)))
double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - 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.75d0)) - z)) / y)
end function
public static double code(double x, double y, double z) {
return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y);
}
def code(x, y, z): return 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y)
function code(x, y, z) return Float64(1.0 + Float64(Float64(4.0 * Float64(Float64(x + Float64(y * 0.75)) - z)) / y)) end
function tmp = code(x, y, z) tmp = 1.0 + ((4.0 * ((x + (y * 0.75)) - z)) / y); end
code[x_, y_, z_] := N[(1.0 + N[(N[(4.0 * N[(N[(x + N[(y * 0.75), $MachinePrecision]), $MachinePrecision] - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \frac{4 \cdot \left(\left(x + y \cdot 0.75\right) - z\right)}{y}
\end{array}
(FPCore (x y z) :precision binary64 (+ 1.0 (+ (/ (* 4.0 (- x z)) y) 3.0)))
double code(double x, double y, double z) {
return 1.0 + (((4.0 * (x - z)) / y) + 3.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 + (((4.0d0 * (x - z)) / y) + 3.0d0)
end function
public static double code(double x, double y, double z) {
return 1.0 + (((4.0 * (x - z)) / y) + 3.0);
}
def code(x, y, z): return 1.0 + (((4.0 * (x - z)) / y) + 3.0)
function code(x, y, z) return Float64(1.0 + Float64(Float64(Float64(4.0 * Float64(x - z)) / y) + 3.0)) end
function tmp = code(x, y, z) tmp = 1.0 + (((4.0 * (x - z)) / y) + 3.0); end
code[x_, y_, z_] := N[(1.0 + N[(N[(N[(4.0 * N[(x - z), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision] + 3.0), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
1 + \left(\frac{4 \cdot \left(x - z\right)}{y} + 3\right)
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (* 4.0 (/ x y)))) (t_1 (+ 1.0 (/ (* z -4.0) y))))
(if (<= z -4.2e+78)
t_1
(if (<= z 9e-210)
t_0
(if (<= z 5.4e-52) 4.0 (if (<= z 1.35e+39) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + (4.0 * (x / y));
double t_1 = 1.0 + ((z * -4.0) / y);
double tmp;
if (z <= -4.2e+78) {
tmp = t_1;
} else if (z <= 9e-210) {
tmp = t_0;
} else if (z <= 5.4e-52) {
tmp = 4.0;
} else if (z <= 1.35e+39) {
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 * (x / y))
t_1 = 1.0d0 + ((z * (-4.0d0)) / y)
if (z <= (-4.2d+78)) then
tmp = t_1
else if (z <= 9d-210) then
tmp = t_0
else if (z <= 5.4d-52) then
tmp = 4.0d0
else if (z <= 1.35d+39) 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 * (x / y));
double t_1 = 1.0 + ((z * -4.0) / y);
double tmp;
if (z <= -4.2e+78) {
tmp = t_1;
} else if (z <= 9e-210) {
tmp = t_0;
} else if (z <= 5.4e-52) {
tmp = 4.0;
} else if (z <= 1.35e+39) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + (4.0 * (x / y)) t_1 = 1.0 + ((z * -4.0) / y) tmp = 0 if z <= -4.2e+78: tmp = t_1 elif z <= 9e-210: tmp = t_0 elif z <= 5.4e-52: tmp = 4.0 elif z <= 1.35e+39: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(4.0 * Float64(x / y))) t_1 = Float64(1.0 + Float64(Float64(z * -4.0) / y)) tmp = 0.0 if (z <= -4.2e+78) tmp = t_1; elseif (z <= 9e-210) tmp = t_0; elseif (z <= 5.4e-52) tmp = 4.0; elseif (z <= 1.35e+39) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + (4.0 * (x / y)); t_1 = 1.0 + ((z * -4.0) / y); tmp = 0.0; if (z <= -4.2e+78) tmp = t_1; elseif (z <= 9e-210) tmp = t_0; elseif (z <= 5.4e-52) tmp = 4.0; elseif (z <= 1.35e+39) 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[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -4.2e+78], t$95$1, If[LessEqual[z, 9e-210], t$95$0, If[LessEqual[z, 5.4e-52], 4.0, If[LessEqual[z, 1.35e+39], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + 4 \cdot \frac{x}{y}\\
t_1 := 1 + \frac{z \cdot -4}{y}\\
\mathbf{if}\;z \leq -4.2 \cdot 10^{+78}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 9 \cdot 10^{-210}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 5.4 \cdot 10^{-52}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq 1.35 \cdot 10^{+39}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;t\_1\\
\end{array}
\end{array}
if z < -4.2000000000000002e78 or 1.35000000000000002e39 < z Initial program 99.9%
Taylor expanded in z around inf 74.2%
*-commutative74.2%
associate-*l/74.2%
Simplified74.2%
if -4.2000000000000002e78 < z < 9.00000000000000039e-210 or 5.40000000000000019e-52 < z < 1.35000000000000002e39Initial program 99.9%
Taylor expanded in x around inf 60.3%
if 9.00000000000000039e-210 < z < 5.40000000000000019e-52Initial program 99.8%
Taylor expanded in y around inf 69.0%
Final simplification67.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -7.2e+155) (not (<= y 2.3e+86))) (+ 1.0 (+ 3.0 (* z (/ -4.0 y)))) (+ 1.0 (* (- x z) (/ 4.0 y)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -7.2e+155) || !(y <= 2.3e+86)) {
tmp = 1.0 + (3.0 + (z * (-4.0 / y)));
} else {
tmp = 1.0 + ((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 <= (-7.2d+155)) .or. (.not. (y <= 2.3d+86))) then
tmp = 1.0d0 + (3.0d0 + (z * ((-4.0d0) / y)))
else
tmp = 1.0d0 + ((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 <= -7.2e+155) || !(y <= 2.3e+86)) {
tmp = 1.0 + (3.0 + (z * (-4.0 / y)));
} else {
tmp = 1.0 + ((x - z) * (4.0 / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -7.2e+155) or not (y <= 2.3e+86): tmp = 1.0 + (3.0 + (z * (-4.0 / y))) else: tmp = 1.0 + ((x - z) * (4.0 / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -7.2e+155) || !(y <= 2.3e+86)) tmp = Float64(1.0 + Float64(3.0 + Float64(z * Float64(-4.0 / y)))); else tmp = Float64(1.0 + Float64(Float64(x - z) * Float64(4.0 / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -7.2e+155) || ~((y <= 2.3e+86))) tmp = 1.0 + (3.0 + (z * (-4.0 / y))); else tmp = 1.0 + ((x - z) * (4.0 / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -7.2e+155], N[Not[LessEqual[y, 2.3e+86]], $MachinePrecision]], N[(1.0 + N[(3.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -7.2 \cdot 10^{+155} \lor \neg \left(y \leq 2.3 \cdot 10^{+86}\right):\\
\;\;\;\;1 + \left(3 + z \cdot \frac{-4}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(x - z\right) \cdot \frac{4}{y}\\
\end{array}
\end{array}
if y < -7.20000000000000015e155 or 2.2999999999999999e86 < y Initial program 99.8%
Taylor expanded in x around 0 88.5%
div-sub88.5%
sub-neg88.5%
associate-/l*88.7%
*-inverses88.7%
metadata-eval88.7%
distribute-lft-in88.7%
metadata-eval88.7%
distribute-rgt-neg-in88.7%
*-lft-identity88.7%
associate-*l/88.6%
associate-*l*88.6%
*-commutative88.6%
distribute-rgt-neg-in88.6%
associate-*r/88.6%
metadata-eval88.6%
distribute-neg-frac88.6%
metadata-eval88.6%
Simplified88.6%
if -7.20000000000000015e155 < y < 2.2999999999999999e86Initial program 99.9%
Taylor expanded in y around 0 85.5%
*-lft-identity85.5%
associate-*l/85.2%
associate-*r*85.2%
associate-*r/85.2%
metadata-eval85.2%
Simplified85.2%
Final simplification86.3%
(FPCore (x y z) :precision binary64 (if (or (<= z -7.4e+78) (not (<= z 1.3e+38))) (+ 1.0 (+ 3.0 (* z (/ -4.0 y)))) (+ 1.0 (+ 3.0 (* 4.0 (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -7.4e+78) || !(z <= 1.3e+38)) {
tmp = 1.0 + (3.0 + (z * (-4.0 / y)));
} else {
tmp = 1.0 + (3.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 <= (-7.4d+78)) .or. (.not. (z <= 1.3d+38))) then
tmp = 1.0d0 + (3.0d0 + (z * ((-4.0d0) / y)))
else
tmp = 1.0d0 + (3.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 <= -7.4e+78) || !(z <= 1.3e+38)) {
tmp = 1.0 + (3.0 + (z * (-4.0 / y)));
} else {
tmp = 1.0 + (3.0 + (4.0 * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -7.4e+78) or not (z <= 1.3e+38): tmp = 1.0 + (3.0 + (z * (-4.0 / y))) else: tmp = 1.0 + (3.0 + (4.0 * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -7.4e+78) || !(z <= 1.3e+38)) tmp = Float64(1.0 + Float64(3.0 + Float64(z * Float64(-4.0 / y)))); else tmp = Float64(1.0 + Float64(3.0 + Float64(4.0 * Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -7.4e+78) || ~((z <= 1.3e+38))) tmp = 1.0 + (3.0 + (z * (-4.0 / y))); else tmp = 1.0 + (3.0 + (4.0 * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -7.4e+78], N[Not[LessEqual[z, 1.3e+38]], $MachinePrecision]], N[(1.0 + N[(3.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(3.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.4 \cdot 10^{+78} \lor \neg \left(z \leq 1.3 \cdot 10^{+38}\right):\\
\;\;\;\;1 + \left(3 + z \cdot \frac{-4}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(3 + 4 \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -7.39999999999999969e78 or 1.3e38 < z Initial program 99.9%
Taylor expanded in x around 0 91.8%
div-sub91.8%
sub-neg91.8%
associate-/l*91.9%
*-inverses91.9%
metadata-eval91.9%
distribute-lft-in91.9%
metadata-eval91.9%
distribute-rgt-neg-in91.9%
*-lft-identity91.9%
associate-*l/91.6%
associate-*l*91.6%
*-commutative91.6%
distribute-rgt-neg-in91.6%
associate-*r/91.6%
metadata-eval91.6%
distribute-neg-frac91.6%
metadata-eval91.6%
Simplified91.6%
if -7.39999999999999969e78 < z < 1.3e38Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 91.7%
Final simplification91.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -1.85e+77) (not (<= z 1.08e+39))) (+ 1.0 (+ 3.0 (/ (* z -4.0) y))) (+ 1.0 (+ 3.0 (* 4.0 (/ x y))))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1.85e+77) || !(z <= 1.08e+39)) {
tmp = 1.0 + (3.0 + ((z * -4.0) / y));
} else {
tmp = 1.0 + (3.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 <= (-1.85d+77)) .or. (.not. (z <= 1.08d+39))) then
tmp = 1.0d0 + (3.0d0 + ((z * (-4.0d0)) / y))
else
tmp = 1.0d0 + (3.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 <= -1.85e+77) || !(z <= 1.08e+39)) {
tmp = 1.0 + (3.0 + ((z * -4.0) / y));
} else {
tmp = 1.0 + (3.0 + (4.0 * (x / y)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -1.85e+77) or not (z <= 1.08e+39): tmp = 1.0 + (3.0 + ((z * -4.0) / y)) else: tmp = 1.0 + (3.0 + (4.0 * (x / y))) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -1.85e+77) || !(z <= 1.08e+39)) tmp = Float64(1.0 + Float64(3.0 + Float64(Float64(z * -4.0) / y))); else tmp = Float64(1.0 + Float64(3.0 + Float64(4.0 * Float64(x / y)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -1.85e+77) || ~((z <= 1.08e+39))) tmp = 1.0 + (3.0 + ((z * -4.0) / y)); else tmp = 1.0 + (3.0 + (4.0 * (x / y))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -1.85e+77], N[Not[LessEqual[z, 1.08e+39]], $MachinePrecision]], N[(1.0 + N[(3.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(3.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.85 \cdot 10^{+77} \lor \neg \left(z \leq 1.08 \cdot 10^{+39}\right):\\
\;\;\;\;1 + \left(3 + \frac{z \cdot -4}{y}\right)\\
\mathbf{else}:\\
\;\;\;\;1 + \left(3 + 4 \cdot \frac{x}{y}\right)\\
\end{array}
\end{array}
if z < -1.84999999999999997e77 or 1.07999999999999998e39 < z Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around 0 91.9%
associate-*r/91.9%
Simplified91.9%
if -1.84999999999999997e77 < z < 1.07999999999999998e39Initial program 99.9%
Taylor expanded in y around inf 100.0%
+-commutative100.0%
associate-*r/100.0%
Simplified100.0%
Taylor expanded in x around inf 91.7%
Final simplification91.8%
(FPCore (x y z) :precision binary64 (if (<= y -9e+161) 4.0 (if (<= y 3.6e+177) (+ 1.0 (* (- x z) (/ 4.0 y))) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -9e+161) {
tmp = 4.0;
} else if (y <= 3.6e+177) {
tmp = 1.0 + ((x - z) * (4.0 / y));
} else {
tmp = 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 (y <= (-9d+161)) then
tmp = 4.0d0
else if (y <= 3.6d+177) then
tmp = 1.0d0 + ((x - z) * (4.0d0 / y))
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -9e+161) {
tmp = 4.0;
} else if (y <= 3.6e+177) {
tmp = 1.0 + ((x - z) * (4.0 / y));
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -9e+161: tmp = 4.0 elif y <= 3.6e+177: tmp = 1.0 + ((x - z) * (4.0 / y)) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -9e+161) tmp = 4.0; elseif (y <= 3.6e+177) tmp = Float64(1.0 + Float64(Float64(x - z) * Float64(4.0 / y))); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -9e+161) tmp = 4.0; elseif (y <= 3.6e+177) tmp = 1.0 + ((x - z) * (4.0 / y)); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -9e+161], 4.0, If[LessEqual[y, 3.6e+177], N[(1.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -9 \cdot 10^{+161}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 3.6 \cdot 10^{+177}:\\
\;\;\;\;1 + \left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -8.99999999999999984e161 or 3.60000000000000003e177 < y Initial program 99.8%
Taylor expanded in y around inf 81.9%
if -8.99999999999999984e161 < y < 3.60000000000000003e177Initial program 99.9%
Taylor expanded in y around 0 83.7%
*-lft-identity83.7%
associate-*l/83.4%
associate-*r*83.4%
associate-*r/83.4%
metadata-eval83.4%
Simplified83.4%
Final simplification83.1%
(FPCore (x y z) :precision binary64 (if (<= y -2.7e+156) 4.0 (if (<= y 6.2e+86) (+ 1.0 (* 4.0 (/ x y))) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+156) {
tmp = 4.0;
} else if (y <= 6.2e+86) {
tmp = 1.0 + (4.0 * (x / y));
} else {
tmp = 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 (y <= (-2.7d+156)) then
tmp = 4.0d0
else if (y <= 6.2d+86) then
tmp = 1.0d0 + (4.0d0 * (x / y))
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+156) {
tmp = 4.0;
} else if (y <= 6.2e+86) {
tmp = 1.0 + (4.0 * (x / y));
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e+156: tmp = 4.0 elif y <= 6.2e+86: tmp = 1.0 + (4.0 * (x / y)) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e+156) tmp = 4.0; elseif (y <= 6.2e+86) tmp = Float64(1.0 + Float64(4.0 * Float64(x / y))); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -2.7e+156) tmp = 4.0; elseif (y <= 6.2e+86) tmp = 1.0 + (4.0 * (x / y)); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+156], 4.0, If[LessEqual[y, 6.2e+86], N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+156}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 6.2 \cdot 10^{+86}:\\
\;\;\;\;1 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -2.7e156 or 6.2000000000000004e86 < y Initial program 99.8%
Taylor expanded in y around inf 70.2%
if -2.7e156 < y < 6.2000000000000004e86Initial program 99.9%
Taylor expanded in x around inf 46.4%
Final simplification53.9%
(FPCore (x y z) :precision binary64 4.0)
double code(double x, double y, double z) {
return 4.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
end function
public static double code(double x, double y, double z) {
return 4.0;
}
def code(x, y, z): return 4.0
function code(x, y, z) return 4.0 end
function tmp = code(x, y, z) tmp = 4.0; end
code[x_, y_, z_] := 4.0
\begin{array}{l}
\\
4
\end{array}
Initial program 99.9%
Taylor expanded in y around inf 34.4%
Final simplification34.4%
herbie shell --seed 2024078
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, A"
:precision binary64
(+ 1.0 (/ (* 4.0 (- (+ x (* y 0.75)) z)) y)))