
(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 9 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 (fma 4.0 (+ 0.75 (/ (- x z) y)) 1.0))
double code(double x, double y, double z) {
return fma(4.0, (0.75 + ((x - z) / y)), 1.0);
}
function code(x, y, z) return fma(4.0, Float64(0.75 + Float64(Float64(x - z) / y)), 1.0) end
code[x_, y_, z_] := N[(4.0 * N[(0.75 + N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision] + 1.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(4, 0.75 + \frac{x - z}{y}, 1\right)
\end{array}
Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* 4.0 (+ x y)) y)))
(if (<= y -8e+91)
t_0
(if (<= y -4.8e-48)
(+ 4.0 (* z (/ -4.0 y)))
(if (<= y 1.65e-31) (* 4.0 (/ (- x z) y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = (4.0 * (x + y)) / y;
double tmp;
if (y <= -8e+91) {
tmp = t_0;
} else if (y <= -4.8e-48) {
tmp = 4.0 + (z * (-4.0 / y));
} else if (y <= 1.65e-31) {
tmp = 4.0 * ((x - z) / y);
} 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) :: tmp
t_0 = (4.0d0 * (x + y)) / y
if (y <= (-8d+91)) then
tmp = t_0
else if (y <= (-4.8d-48)) then
tmp = 4.0d0 + (z * ((-4.0d0) / y))
else if (y <= 1.65d-31) then
tmp = 4.0d0 * ((x - z) / y)
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)) / y;
double tmp;
if (y <= -8e+91) {
tmp = t_0;
} else if (y <= -4.8e-48) {
tmp = 4.0 + (z * (-4.0 / y));
} else if (y <= 1.65e-31) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (4.0 * (x + y)) / y tmp = 0 if y <= -8e+91: tmp = t_0 elif y <= -4.8e-48: tmp = 4.0 + (z * (-4.0 / y)) elif y <= 1.65e-31: tmp = 4.0 * ((x - z) / y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(4.0 * Float64(x + y)) / y) tmp = 0.0 if (y <= -8e+91) tmp = t_0; elseif (y <= -4.8e-48) tmp = Float64(4.0 + Float64(z * Float64(-4.0 / y))); elseif (y <= 1.65e-31) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (4.0 * (x + y)) / y; tmp = 0.0; if (y <= -8e+91) tmp = t_0; elseif (y <= -4.8e-48) tmp = 4.0 + (z * (-4.0 / y)); elseif (y <= 1.65e-31) tmp = 4.0 * ((x - z) / y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(4.0 * N[(x + y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]}, If[LessEqual[y, -8e+91], t$95$0, If[LessEqual[y, -4.8e-48], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.65e-31], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{4 \cdot \left(x + y\right)}{y}\\
\mathbf{if}\;y \leq -8 \cdot 10^{+91}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -4.8 \cdot 10^{-48}:\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\mathbf{elif}\;y \leq 1.65 \cdot 10^{-31}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -8.00000000000000064e91 or 1.65e-31 < y Initial program 99.9%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
Taylor expanded in x around inf 91.2%
if -8.00000000000000064e91 < y < -4.8e-48Initial program 99.8%
+-commutative99.8%
associate-/l*99.8%
fma-define99.8%
associate--l+99.8%
+-commutative99.8%
remove-double-neg99.8%
sub-neg99.8%
associate--r+99.8%
div-sub99.8%
sub-neg99.8%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 88.7%
sub-neg88.7%
distribute-lft-in88.7%
metadata-eval88.7%
associate-+r+88.7%
metadata-eval88.7%
neg-mul-188.7%
associate-*r*88.7%
metadata-eval88.7%
associate-*r/88.7%
*-commutative88.7%
associate-/l*88.4%
Simplified88.4%
if -4.8e-48 < y < 1.65e-31Initial program 100.0%
Taylor expanded in y around 0 95.4%
Final simplification92.7%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 4.0 (* x (/ 4.0 y)))))
(if (<= y -1e+90)
t_0
(if (<= y -7.5e-49)
(+ 4.0 (* z (/ -4.0 y)))
(if (<= y 2.9e-25) (* 4.0 (/ (- x z) y)) t_0)))))
double code(double x, double y, double z) {
double t_0 = 4.0 + (x * (4.0 / y));
double tmp;
if (y <= -1e+90) {
tmp = t_0;
} else if (y <= -7.5e-49) {
tmp = 4.0 + (z * (-4.0 / y));
} else if (y <= 2.9e-25) {
tmp = 4.0 * ((x - z) / y);
} 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) :: tmp
t_0 = 4.0d0 + (x * (4.0d0 / y))
if (y <= (-1d+90)) then
tmp = t_0
else if (y <= (-7.5d-49)) then
tmp = 4.0d0 + (z * ((-4.0d0) / y))
else if (y <= 2.9d-25) then
tmp = 4.0d0 * ((x - z) / y)
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 * (4.0 / y));
double tmp;
if (y <= -1e+90) {
tmp = t_0;
} else if (y <= -7.5e-49) {
tmp = 4.0 + (z * (-4.0 / y));
} else if (y <= 2.9e-25) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 + (x * (4.0 / y)) tmp = 0 if y <= -1e+90: tmp = t_0 elif y <= -7.5e-49: tmp = 4.0 + (z * (-4.0 / y)) elif y <= 2.9e-25: tmp = 4.0 * ((x - z) / y) else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 + Float64(x * Float64(4.0 / y))) tmp = 0.0 if (y <= -1e+90) tmp = t_0; elseif (y <= -7.5e-49) tmp = Float64(4.0 + Float64(z * Float64(-4.0 / y))); elseif (y <= 2.9e-25) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 + (x * (4.0 / y)); tmp = 0.0; if (y <= -1e+90) tmp = t_0; elseif (y <= -7.5e-49) tmp = 4.0 + (z * (-4.0 / y)); elseif (y <= 2.9e-25) tmp = 4.0 * ((x - z) / y); else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 + N[(x * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -1e+90], t$95$0, If[LessEqual[y, -7.5e-49], N[(4.0 + N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2.9e-25], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 + x \cdot \frac{4}{y}\\
\mathbf{if}\;y \leq -1 \cdot 10^{+90}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -7.5 \cdot 10^{-49}:\\
\;\;\;\;4 + z \cdot \frac{-4}{y}\\
\mathbf{elif}\;y \leq 2.9 \cdot 10^{-25}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -9.99999999999999966e89 or 2.9000000000000001e-25 < y Initial program 99.9%
+-commutative99.9%
associate-/l*99.9%
fma-define99.9%
associate--l+99.9%
+-commutative99.9%
remove-double-neg99.9%
sub-neg99.9%
associate--r+99.9%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 91.0%
distribute-lft-in91.0%
metadata-eval91.0%
associate-+r+91.0%
metadata-eval91.0%
associate-*r/91.0%
*-commutative91.0%
associate-*r/90.9%
Simplified90.9%
if -9.99999999999999966e89 < y < -7.4999999999999998e-49Initial program 99.8%
+-commutative99.8%
associate-/l*99.8%
fma-define99.8%
associate--l+99.8%
+-commutative99.8%
remove-double-neg99.8%
sub-neg99.8%
associate--r+99.8%
div-sub99.8%
sub-neg99.8%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in x around 0 88.7%
sub-neg88.7%
distribute-lft-in88.7%
metadata-eval88.7%
associate-+r+88.7%
metadata-eval88.7%
neg-mul-188.7%
associate-*r*88.7%
metadata-eval88.7%
associate-*r/88.7%
*-commutative88.7%
associate-/l*88.4%
Simplified88.4%
if -7.4999999999999998e-49 < y < 2.9000000000000001e-25Initial program 100.0%
Taylor expanded in y around 0 95.5%
(FPCore (x y z)
:precision binary64
(if (<= y -6.5e-49)
4.0
(if (<= y -4.6e-85)
(* -4.0 (/ z y))
(if (<= y 3.55e+109) (* 4.0 (/ x y)) 4.0))))
double code(double x, double y, double z) {
double tmp;
if (y <= -6.5e-49) {
tmp = 4.0;
} else if (y <= -4.6e-85) {
tmp = -4.0 * (z / y);
} else if (y <= 3.55e+109) {
tmp = 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 <= (-6.5d-49)) then
tmp = 4.0d0
else if (y <= (-4.6d-85)) then
tmp = (-4.0d0) * (z / y)
else if (y <= 3.55d+109) then
tmp = 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 <= -6.5e-49) {
tmp = 4.0;
} else if (y <= -4.6e-85) {
tmp = -4.0 * (z / y);
} else if (y <= 3.55e+109) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -6.5e-49: tmp = 4.0 elif y <= -4.6e-85: tmp = -4.0 * (z / y) elif y <= 3.55e+109: tmp = 4.0 * (x / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -6.5e-49) tmp = 4.0; elseif (y <= -4.6e-85) tmp = Float64(-4.0 * Float64(z / y)); elseif (y <= 3.55e+109) tmp = 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 <= -6.5e-49) tmp = 4.0; elseif (y <= -4.6e-85) tmp = -4.0 * (z / y); elseif (y <= 3.55e+109) tmp = 4.0 * (x / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -6.5e-49], 4.0, If[LessEqual[y, -4.6e-85], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3.55e+109], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 4.0]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -6.5 \cdot 10^{-49}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq -4.6 \cdot 10^{-85}:\\
\;\;\;\;-4 \cdot \frac{z}{y}\\
\mathbf{elif}\;y \leq 3.55 \cdot 10^{+109}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -6.49999999999999968e-49 or 3.5500000000000001e109 < y Initial program 99.8%
Taylor expanded in y around inf 72.1%
if -6.49999999999999968e-49 < y < -4.6000000000000001e-85Initial program 100.0%
Taylor expanded in z around inf 86.2%
*-commutative86.2%
Simplified86.2%
if -4.6000000000000001e-85 < y < 3.5500000000000001e109Initial program 100.0%
Taylor expanded in x around inf 55.4%
Final simplification64.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -8.5e-48) (not (<= y 1.7e-24))) (+ 4.0 (* x (/ 4.0 y))) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -8.5e-48) || !(y <= 1.7e-24)) {
tmp = 4.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 <= (-8.5d-48)) .or. (.not. (y <= 1.7d-24))) then
tmp = 4.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 <= -8.5e-48) || !(y <= 1.7e-24)) {
tmp = 4.0 + (x * (4.0 / y));
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -8.5e-48) or not (y <= 1.7e-24): tmp = 4.0 + (x * (4.0 / y)) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -8.5e-48) || !(y <= 1.7e-24)) tmp = Float64(4.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 <= -8.5e-48) || ~((y <= 1.7e-24))) tmp = 4.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, -8.5e-48], N[Not[LessEqual[y, 1.7e-24]], $MachinePrecision]], N[(4.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 -8.5 \cdot 10^{-48} \lor \neg \left(y \leq 1.7 \cdot 10^{-24}\right):\\
\;\;\;\;4 + x \cdot \frac{4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -8.5000000000000004e-48 or 1.69999999999999996e-24 < y Initial program 99.8%
+-commutative99.8%
associate-/l*99.8%
fma-define99.8%
associate--l+99.8%
+-commutative99.8%
remove-double-neg99.8%
sub-neg99.8%
associate--r+99.8%
div-sub99.9%
sub-neg99.9%
associate-*l/100.0%
*-inverses100.0%
metadata-eval100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
distribute-neg-out100.0%
+-commutative100.0%
sub-neg100.0%
distribute-frac-neg100.0%
distribute-frac-neg2100.0%
remove-double-neg100.0%
Simplified100.0%
Taylor expanded in z around 0 86.5%
distribute-lft-in86.5%
metadata-eval86.5%
associate-+r+86.5%
metadata-eval86.5%
associate-*r/86.5%
*-commutative86.5%
associate-*r/86.4%
Simplified86.4%
if -8.5000000000000004e-48 < y < 1.69999999999999996e-24Initial program 100.0%
Taylor expanded in y around 0 95.5%
Final simplification90.4%
(FPCore (x y z) :precision binary64 (if (<= y -480000000000.0) 4.0 (if (<= y 9e+108) (* 4.0 (/ (- x z) y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -480000000000.0) {
tmp = 4.0;
} else if (y <= 9e+108) {
tmp = 4.0 * ((x - z) / 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 <= (-480000000000.0d0)) then
tmp = 4.0d0
else if (y <= 9d+108) then
tmp = 4.0d0 * ((x - z) / 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 <= -480000000000.0) {
tmp = 4.0;
} else if (y <= 9e+108) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -480000000000.0: tmp = 4.0 elif y <= 9e+108: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -480000000000.0) tmp = 4.0; elseif (y <= 9e+108) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -480000000000.0) tmp = 4.0; elseif (y <= 9e+108) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -480000000000.0], 4.0, If[LessEqual[y, 9e+108], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -480000000000:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 9 \cdot 10^{+108}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -4.8e11 or 9e108 < y Initial program 99.8%
Taylor expanded in y around inf 74.1%
if -4.8e11 < y < 9e108Initial program 100.0%
Taylor expanded in y around 0 88.3%
(FPCore (x y z) :precision binary64 (if (<= y -8.5e-49) 4.0 (if (<= y 5.2e+109) (* 4.0 (/ x y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -8.5e-49) {
tmp = 4.0;
} else if (y <= 5.2e+109) {
tmp = 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 <= (-8.5d-49)) then
tmp = 4.0d0
else if (y <= 5.2d+109) then
tmp = 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 <= -8.5e-49) {
tmp = 4.0;
} else if (y <= 5.2e+109) {
tmp = 4.0 * (x / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -8.5e-49: tmp = 4.0 elif y <= 5.2e+109: tmp = 4.0 * (x / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -8.5e-49) tmp = 4.0; elseif (y <= 5.2e+109) tmp = 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 <= -8.5e-49) tmp = 4.0; elseif (y <= 5.2e+109) tmp = 4.0 * (x / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -8.5e-49], 4.0, If[LessEqual[y, 5.2e+109], N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -8.5 \cdot 10^{-49}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 5.2 \cdot 10^{+109}:\\
\;\;\;\;4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -8.50000000000000069e-49 or 5.1999999999999997e109 < y Initial program 99.8%
Taylor expanded in y around inf 72.1%
if -8.50000000000000069e-49 < y < 5.1999999999999997e109Initial program 100.0%
Taylor expanded in x around inf 53.4%
(FPCore (x y z) :precision binary64 (/ (* 4.0 (+ (- x z) y)) y))
double code(double x, double y, double z) {
return (4.0 * ((x - z) + y)) / 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 * ((x - z) + y)) / y
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - z) + y)) / y;
}
def code(x, y, z): return (4.0 * ((x - z) + y)) / y
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - z) + y)) / y) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - z) + y)) / y; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - z), $MachinePrecision] + y), $MachinePrecision]), $MachinePrecision] / y), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - z\right) + y\right)}{y}
\end{array}
Initial program 99.9%
Taylor expanded in y around 0 100.0%
distribute-lft-out100.0%
Simplified100.0%
Final simplification100.0%
(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 41.1%
herbie shell --seed 2024170
(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)))