
(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 (+ 4.0 (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
return 4.0 + (4.0 * ((x - 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 = 4.0d0 + (4.0d0 * ((x - z) / y))
end function
public static double code(double x, double y, double z) {
return 4.0 + (4.0 * ((x - z) / y));
}
def code(x, y, z): return 4.0 + (4.0 * ((x - z) / y))
function code(x, y, z) return Float64(4.0 + Float64(4.0 * Float64(Float64(x - z) / y))) end
function tmp = code(x, y, z) tmp = 4.0 + (4.0 * ((x - z) / y)); end
code[x_, y_, z_] := N[(4.0 + N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 + 4 \cdot \frac{x - z}{y}
\end{array}
Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(if (or (<= x -3.5e+108)
(and (not (<= x -1.8e+43)) (or (<= x -0.0062) (not (<= x 2.5e-13)))))
(+ (* 4.0 (/ x y)) 1.0)
4.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.5e+108) || (!(x <= -1.8e+43) && ((x <= -0.0062) || !(x <= 2.5e-13)))) {
tmp = (4.0 * (x / y)) + 1.0;
} 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 ((x <= (-3.5d+108)) .or. (.not. (x <= (-1.8d+43))) .and. (x <= (-0.0062d0)) .or. (.not. (x <= 2.5d-13))) then
tmp = (4.0d0 * (x / y)) + 1.0d0
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.5e+108) || (!(x <= -1.8e+43) && ((x <= -0.0062) || !(x <= 2.5e-13)))) {
tmp = (4.0 * (x / y)) + 1.0;
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.5e+108) or (not (x <= -1.8e+43) and ((x <= -0.0062) or not (x <= 2.5e-13))): tmp = (4.0 * (x / y)) + 1.0 else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.5e+108) || (!(x <= -1.8e+43) && ((x <= -0.0062) || !(x <= 2.5e-13)))) tmp = Float64(Float64(4.0 * Float64(x / y)) + 1.0); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.5e+108) || (~((x <= -1.8e+43)) && ((x <= -0.0062) || ~((x <= 2.5e-13))))) tmp = (4.0 * (x / y)) + 1.0; else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.5e+108], And[N[Not[LessEqual[x, -1.8e+43]], $MachinePrecision], Or[LessEqual[x, -0.0062], N[Not[LessEqual[x, 2.5e-13]], $MachinePrecision]]]], N[(N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.5 \cdot 10^{+108} \lor \neg \left(x \leq -1.8 \cdot 10^{+43}\right) \land \left(x \leq -0.0062 \lor \neg \left(x \leq 2.5 \cdot 10^{-13}\right)\right):\\
\;\;\;\;4 \cdot \frac{x}{y} + 1\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if x < -3.5000000000000002e108 or -1.80000000000000005e43 < x < -0.00619999999999999978 or 2.49999999999999995e-13 < x Initial program 100.0%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around inf 70.0%
if -3.5000000000000002e108 < x < -1.80000000000000005e43 or -0.00619999999999999978 < x < 2.49999999999999995e-13Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 51.1%
Final simplification60.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* 4.0 (/ x y)) 1.0)) (t_1 (+ 1.0 (* z (/ -4.0 y)))))
(if (<= z -2.45e+25)
t_1
(if (<= z 6.2e-246)
t_0
(if (<= z 2.9e-220) 4.0 (if (<= z 4.6e+110) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = (4.0 * (x / y)) + 1.0;
double t_1 = 1.0 + (z * (-4.0 / y));
double tmp;
if (z <= -2.45e+25) {
tmp = t_1;
} else if (z <= 6.2e-246) {
tmp = t_0;
} else if (z <= 2.9e-220) {
tmp = 4.0;
} else if (z <= 4.6e+110) {
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 = (4.0d0 * (x / y)) + 1.0d0
t_1 = 1.0d0 + (z * ((-4.0d0) / y))
if (z <= (-2.45d+25)) then
tmp = t_1
else if (z <= 6.2d-246) then
tmp = t_0
else if (z <= 2.9d-220) then
tmp = 4.0d0
else if (z <= 4.6d+110) 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 = (4.0 * (x / y)) + 1.0;
double t_1 = 1.0 + (z * (-4.0 / y));
double tmp;
if (z <= -2.45e+25) {
tmp = t_1;
} else if (z <= 6.2e-246) {
tmp = t_0;
} else if (z <= 2.9e-220) {
tmp = 4.0;
} else if (z <= 4.6e+110) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (4.0 * (x / y)) + 1.0 t_1 = 1.0 + (z * (-4.0 / y)) tmp = 0 if z <= -2.45e+25: tmp = t_1 elif z <= 6.2e-246: tmp = t_0 elif z <= 2.9e-220: tmp = 4.0 elif z <= 4.6e+110: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(4.0 * Float64(x / y)) + 1.0) t_1 = Float64(1.0 + Float64(z * Float64(-4.0 / y))) tmp = 0.0 if (z <= -2.45e+25) tmp = t_1; elseif (z <= 6.2e-246) tmp = t_0; elseif (z <= 2.9e-220) tmp = 4.0; elseif (z <= 4.6e+110) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (4.0 * (x / y)) + 1.0; t_1 = 1.0 + (z * (-4.0 / y)); tmp = 0.0; if (z <= -2.45e+25) tmp = t_1; elseif (z <= 6.2e-246) tmp = t_0; elseif (z <= 2.9e-220) tmp = 4.0; elseif (z <= 4.6e+110) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -2.45e+25], t$95$1, If[LessEqual[z, 6.2e-246], t$95$0, If[LessEqual[z, 2.9e-220], 4.0, If[LessEqual[z, 4.6e+110], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y} + 1\\
t_1 := 1 + z \cdot \frac{-4}{y}\\
\mathbf{if}\;z \leq -2.45 \cdot 10^{+25}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{-246}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{-220}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{+110}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -2.45e25 or 4.6e110 < z Initial program 99.9%
associate-/l*99.7%
Simplified99.7%
Taylor expanded in y around 0 82.1%
Taylor expanded in x around 0 72.3%
associate-*r/72.3%
*-commutative72.3%
associate-*r/72.1%
Simplified72.1%
if -2.45e25 < z < 6.2000000000000001e-246 or 2.8999999999999998e-220 < z < 4.6e110Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around inf 64.3%
if 6.2000000000000001e-246 < z < 2.8999999999999998e-220Initial program 99.5%
associate-*l/99.7%
+-commutative99.7%
fma-def99.5%
Simplified99.5%
Taylor expanded in y around inf 100.0%
Final simplification68.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ (* 4.0 (/ x y)) 1.0)) (t_1 (+ 1.0 (/ (* z -4.0) y))))
(if (<= z -7.5e+24)
t_1
(if (<= z 4.3e-246)
t_0
(if (<= z 3.45e-220) 4.0 (if (<= z 4.6e+110) t_0 t_1))))))
double code(double x, double y, double z) {
double t_0 = (4.0 * (x / y)) + 1.0;
double t_1 = 1.0 + ((z * -4.0) / y);
double tmp;
if (z <= -7.5e+24) {
tmp = t_1;
} else if (z <= 4.3e-246) {
tmp = t_0;
} else if (z <= 3.45e-220) {
tmp = 4.0;
} else if (z <= 4.6e+110) {
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 = (4.0d0 * (x / y)) + 1.0d0
t_1 = 1.0d0 + ((z * (-4.0d0)) / y)
if (z <= (-7.5d+24)) then
tmp = t_1
else if (z <= 4.3d-246) then
tmp = t_0
else if (z <= 3.45d-220) then
tmp = 4.0d0
else if (z <= 4.6d+110) 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 = (4.0 * (x / y)) + 1.0;
double t_1 = 1.0 + ((z * -4.0) / y);
double tmp;
if (z <= -7.5e+24) {
tmp = t_1;
} else if (z <= 4.3e-246) {
tmp = t_0;
} else if (z <= 3.45e-220) {
tmp = 4.0;
} else if (z <= 4.6e+110) {
tmp = t_0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = (4.0 * (x / y)) + 1.0 t_1 = 1.0 + ((z * -4.0) / y) tmp = 0 if z <= -7.5e+24: tmp = t_1 elif z <= 4.3e-246: tmp = t_0 elif z <= 3.45e-220: tmp = 4.0 elif z <= 4.6e+110: tmp = t_0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(Float64(4.0 * Float64(x / y)) + 1.0) t_1 = Float64(1.0 + Float64(Float64(z * -4.0) / y)) tmp = 0.0 if (z <= -7.5e+24) tmp = t_1; elseif (z <= 4.3e-246) tmp = t_0; elseif (z <= 3.45e-220) tmp = 4.0; elseif (z <= 4.6e+110) tmp = t_0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (4.0 * (x / y)) + 1.0; t_1 = 1.0 + ((z * -4.0) / y); tmp = 0.0; if (z <= -7.5e+24) tmp = t_1; elseif (z <= 4.3e-246) tmp = t_0; elseif (z <= 3.45e-220) tmp = 4.0; elseif (z <= 4.6e+110) tmp = t_0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -7.5e+24], t$95$1, If[LessEqual[z, 4.3e-246], t$95$0, If[LessEqual[z, 3.45e-220], 4.0, If[LessEqual[z, 4.6e+110], t$95$0, t$95$1]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y} + 1\\
t_1 := 1 + \frac{z \cdot -4}{y}\\
\mathbf{if}\;z \leq -7.5 \cdot 10^{+24}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 4.3 \cdot 10^{-246}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 3.45 \cdot 10^{-220}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{+110}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if z < -7.50000000000000014e24 or 4.6e110 < z Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around inf 72.3%
associate-*r/72.3%
metadata-eval72.3%
associate-*r*72.3%
neg-mul-172.3%
associate-*l/72.1%
*-commutative72.1%
associate-*r/72.3%
neg-mul-172.3%
*-commutative72.3%
associate-*l*72.3%
metadata-eval72.3%
Simplified72.3%
if -7.50000000000000014e24 < z < 4.29999999999999992e-246 or 3.4499999999999999e-220 < z < 4.6e110Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around inf 64.3%
if 4.29999999999999992e-246 < z < 3.4499999999999999e-220Initial program 99.5%
associate-*l/99.7%
+-commutative99.7%
fma-def99.5%
Simplified99.5%
Taylor expanded in y around inf 100.0%
Final simplification68.5%
(FPCore (x y z) :precision binary64 (if (<= z -5.2e+25) (- 4.0 (* 4.0 (/ z y))) (if (<= z 8.8e+27) (+ 4.0 (* 4.0 (/ x y))) (+ 1.0 (/ 4.0 (/ y (- x z)))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -5.2e+25) {
tmp = 4.0 - (4.0 * (z / y));
} else if (z <= 8.8e+27) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 1.0 + (4.0 / (y / (x - z)));
}
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 <= (-5.2d+25)) then
tmp = 4.0d0 - (4.0d0 * (z / y))
else if (z <= 8.8d+27) then
tmp = 4.0d0 + (4.0d0 * (x / y))
else
tmp = 1.0d0 + (4.0d0 / (y / (x - z)))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -5.2e+25) {
tmp = 4.0 - (4.0 * (z / y));
} else if (z <= 8.8e+27) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 1.0 + (4.0 / (y / (x - z)));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -5.2e+25: tmp = 4.0 - (4.0 * (z / y)) elif z <= 8.8e+27: tmp = 4.0 + (4.0 * (x / y)) else: tmp = 1.0 + (4.0 / (y / (x - z))) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -5.2e+25) tmp = Float64(4.0 - Float64(4.0 * Float64(z / y))); elseif (z <= 8.8e+27) tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); else tmp = Float64(1.0 + Float64(4.0 / Float64(y / Float64(x - z)))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -5.2e+25) tmp = 4.0 - (4.0 * (z / y)); elseif (z <= 8.8e+27) tmp = 4.0 + (4.0 * (x / y)); else tmp = 1.0 + (4.0 / (y / (x - z))); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -5.2e+25], N[(4.0 - N[(4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 8.8e+27], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(1.0 + N[(4.0 / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+25}:\\
\;\;\;\;4 - 4 \cdot \frac{z}{y}\\
\mathbf{elif}\;z \leq 8.8 \cdot 10^{+27}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;1 + \frac{4}{\frac{y}{x - z}}\\
\end{array}
\end{array}
if z < -5.1999999999999997e25Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 92.6%
neg-mul-192.6%
distribute-neg-frac92.6%
Simplified92.6%
if -5.1999999999999997e25 < z < 8.7999999999999995e27Initial program 99.9%
associate-*l/99.6%
+-commutative99.6%
fma-def99.6%
Simplified99.6%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 95.8%
if 8.7999999999999995e27 < z Initial program 99.9%
associate-/l*99.8%
Simplified99.8%
Taylor expanded in y around 0 86.0%
Final simplification92.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -9e+96) (not (<= z 5.2e+112))) (+ 1.0 (/ (* z -4.0) y)) (+ 4.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -9e+96) || !(z <= 5.2e+112)) {
tmp = 1.0 + ((z * -4.0) / y);
} else {
tmp = 4.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 <= (-9d+96)) .or. (.not. (z <= 5.2d+112))) then
tmp = 1.0d0 + ((z * (-4.0d0)) / y)
else
tmp = 4.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 <= -9e+96) || !(z <= 5.2e+112)) {
tmp = 1.0 + ((z * -4.0) / y);
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -9e+96) or not (z <= 5.2e+112): tmp = 1.0 + ((z * -4.0) / y) else: tmp = 4.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -9e+96) || !(z <= 5.2e+112)) tmp = Float64(1.0 + Float64(Float64(z * -4.0) / y)); else tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -9e+96) || ~((z <= 5.2e+112))) tmp = 1.0 + ((z * -4.0) / y); else tmp = 4.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -9e+96], N[Not[LessEqual[z, 5.2e+112]], $MachinePrecision]], N[(1.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -9 \cdot 10^{+96} \lor \neg \left(z \leq 5.2 \cdot 10^{+112}\right):\\
\;\;\;\;1 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -8.99999999999999914e96 or 5.2000000000000001e112 < z Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in z around inf 75.6%
associate-*r/75.6%
metadata-eval75.6%
associate-*r*75.6%
neg-mul-175.6%
associate-*l/75.4%
*-commutative75.4%
associate-*r/75.6%
neg-mul-175.6%
*-commutative75.6%
associate-*l*75.6%
metadata-eval75.6%
Simplified75.6%
if -8.99999999999999914e96 < z < 5.2000000000000001e112Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 91.7%
Final simplification85.7%
(FPCore (x y z) :precision binary64 (if (or (<= z -8e+23) (not (<= z 4.8e+110))) (- 4.0 (* 4.0 (/ z y))) (+ 4.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -8e+23) || !(z <= 4.8e+110)) {
tmp = 4.0 - (4.0 * (z / y));
} else {
tmp = 4.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 <= (-8d+23)) .or. (.not. (z <= 4.8d+110))) then
tmp = 4.0d0 - (4.0d0 * (z / y))
else
tmp = 4.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 <= -8e+23) || !(z <= 4.8e+110)) {
tmp = 4.0 - (4.0 * (z / y));
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -8e+23) or not (z <= 4.8e+110): tmp = 4.0 - (4.0 * (z / y)) else: tmp = 4.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -8e+23) || !(z <= 4.8e+110)) tmp = Float64(4.0 - Float64(4.0 * Float64(z / y))); else tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -8e+23) || ~((z <= 4.8e+110))) tmp = 4.0 - (4.0 * (z / y)); else tmp = 4.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -8e+23], N[Not[LessEqual[z, 4.8e+110]], $MachinePrecision]], N[(4.0 - N[(4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8 \cdot 10^{+23} \lor \neg \left(z \leq 4.8 \cdot 10^{+110}\right):\\
\;\;\;\;4 - 4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -7.9999999999999993e23 or 4.80000000000000025e110 < z Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 89.5%
neg-mul-189.5%
distribute-neg-frac89.5%
Simplified89.5%
if -7.9999999999999993e23 < z < 4.80000000000000025e110Initial program 99.9%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 93.5%
Final simplification91.8%
(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%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 30.5%
Final simplification30.5%
herbie shell --seed 2023279
(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)))