
(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 (+ 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.5%
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
(let* ((t_0 (* -4.0 (/ z y))) (t_1 (* 4.0 (/ x y))))
(if (<= z -1.45e+152)
t_0
(if (<= z -2.3e+25)
t_1
(if (<= z -1.3e-148)
4.0
(if (<= z -6.5e-181) t_1 (if (<= z 7.2e+40) 4.0 t_0)))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (z / y);
double t_1 = 4.0 * (x / y);
double tmp;
if (z <= -1.45e+152) {
tmp = t_0;
} else if (z <= -2.3e+25) {
tmp = t_1;
} else if (z <= -1.3e-148) {
tmp = 4.0;
} else if (z <= -6.5e-181) {
tmp = t_1;
} else if (z <= 7.2e+40) {
tmp = 4.0;
} 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) * (z / y)
t_1 = 4.0d0 * (x / y)
if (z <= (-1.45d+152)) then
tmp = t_0
else if (z <= (-2.3d+25)) then
tmp = t_1
else if (z <= (-1.3d-148)) then
tmp = 4.0d0
else if (z <= (-6.5d-181)) then
tmp = t_1
else if (z <= 7.2d+40) then
tmp = 4.0d0
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 * (z / y);
double t_1 = 4.0 * (x / y);
double tmp;
if (z <= -1.45e+152) {
tmp = t_0;
} else if (z <= -2.3e+25) {
tmp = t_1;
} else if (z <= -1.3e-148) {
tmp = 4.0;
} else if (z <= -6.5e-181) {
tmp = t_1;
} else if (z <= 7.2e+40) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (z / y) t_1 = 4.0 * (x / y) tmp = 0 if z <= -1.45e+152: tmp = t_0 elif z <= -2.3e+25: tmp = t_1 elif z <= -1.3e-148: tmp = 4.0 elif z <= -6.5e-181: tmp = t_1 elif z <= 7.2e+40: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(z / y)) t_1 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (z <= -1.45e+152) tmp = t_0; elseif (z <= -2.3e+25) tmp = t_1; elseif (z <= -1.3e-148) tmp = 4.0; elseif (z <= -6.5e-181) tmp = t_1; elseif (z <= 7.2e+40) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (z / y); t_1 = 4.0 * (x / y); tmp = 0.0; if (z <= -1.45e+152) tmp = t_0; elseif (z <= -2.3e+25) tmp = t_1; elseif (z <= -1.3e-148) tmp = 4.0; elseif (z <= -6.5e-181) tmp = t_1; elseif (z <= 7.2e+40) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.45e+152], t$95$0, If[LessEqual[z, -2.3e+25], t$95$1, If[LessEqual[z, -1.3e-148], 4.0, If[LessEqual[z, -6.5e-181], t$95$1, If[LessEqual[z, 7.2e+40], 4.0, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{z}{y}\\
t_1 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;z \leq -1.45 \cdot 10^{+152}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -2.3 \cdot 10^{+25}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1.3 \cdot 10^{-148}:\\
\;\;\;\;4\\
\mathbf{elif}\;z \leq -6.5 \cdot 10^{-181}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 7.2 \cdot 10^{+40}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if z < -1.4499999999999999e152 or 7.19999999999999993e40 < z Initial 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 z around inf 68.6%
if -1.4499999999999999e152 < z < -2.2999999999999998e25 or -1.30000000000000004e-148 < z < -6.4999999999999997e-181Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 59.7%
if -2.2999999999999998e25 < z < -1.30000000000000004e-148 or -6.4999999999999997e-181 < z < 7.19999999999999993e40Initial program 99.1%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 62.4%
Final simplification64.1%
(FPCore (x y z)
:precision binary64
(if (<= y -3.6e+126)
4.0
(if (or (<= y -2400000000000.0)
(and (not (<= y -4.8e-14)) (<= y 1.72e+105)))
(* 4.0 (/ (- x z) y))
4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.6e+126) {
tmp = 4.0;
} else if ((y <= -2400000000000.0) || (!(y <= -4.8e-14) && (y <= 1.72e+105))) {
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 <= (-3.6d+126)) then
tmp = 4.0d0
else if ((y <= (-2400000000000.0d0)) .or. (.not. (y <= (-4.8d-14))) .and. (y <= 1.72d+105)) 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 <= -3.6e+126) {
tmp = 4.0;
} else if ((y <= -2400000000000.0) || (!(y <= -4.8e-14) && (y <= 1.72e+105))) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.6e+126: tmp = 4.0 elif (y <= -2400000000000.0) or (not (y <= -4.8e-14) and (y <= 1.72e+105)): tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.6e+126) tmp = 4.0; elseif ((y <= -2400000000000.0) || (!(y <= -4.8e-14) && (y <= 1.72e+105))) 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 <= -3.6e+126) tmp = 4.0; elseif ((y <= -2400000000000.0) || (~((y <= -4.8e-14)) && (y <= 1.72e+105))) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.6e+126], 4.0, If[Or[LessEqual[y, -2400000000000.0], And[N[Not[LessEqual[y, -4.8e-14]], $MachinePrecision], LessEqual[y, 1.72e+105]]], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.6 \cdot 10^{+126}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq -2400000000000 \lor \neg \left(y \leq -4.8 \cdot 10^{-14}\right) \land y \leq 1.72 \cdot 10^{+105}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -3.6e126 or -2.4e12 < y < -4.8e-14 or 1.7200000000000001e105 < y Initial program 98.8%
associate-*l/99.8%
+-commutative99.8%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 74.5%
if -3.6e126 < y < -2.4e12 or -4.8e-14 < y < 1.7200000000000001e105Initial 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 y around 0 80.9%
Final simplification78.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -3e-29) (not (<= y 7400000.0))) (+ 4.0 (* -4.0 (/ z y))) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3e-29) || !(y <= 7400000.0)) {
tmp = 4.0 + (-4.0 * (z / 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 <= (-3d-29)) .or. (.not. (y <= 7400000.0d0))) then
tmp = 4.0d0 + ((-4.0d0) * (z / 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 <= -3e-29) || !(y <= 7400000.0)) {
tmp = 4.0 + (-4.0 * (z / y));
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3e-29) or not (y <= 7400000.0): tmp = 4.0 + (-4.0 * (z / y)) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3e-29) || !(y <= 7400000.0)) tmp = Float64(4.0 + Float64(-4.0 * Float64(z / 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 <= -3e-29) || ~((y <= 7400000.0))) tmp = 4.0 + (-4.0 * (z / y)); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3e-29], N[Not[LessEqual[y, 7400000.0]], $MachinePrecision]], N[(4.0 + N[(-4.0 * N[(z / 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 -3 \cdot 10^{-29} \lor \neg \left(y \leq 7400000\right):\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -3.0000000000000003e-29 or 7.4e6 < y Initial program 99.2%
associate-*l/99.8%
+-commutative99.8%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 84.1%
if -3.0000000000000003e-29 < y < 7.4e6Initial program 100.0%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 88.4%
Final simplification86.0%
(FPCore (x y z) :precision binary64 (if (<= z -95.0) (* 4.0 (/ (- x z) y)) (if (<= z 1.15e+41) (+ 4.0 (* 4.0 (/ x y))) (+ 4.0 (* -4.0 (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -95.0) {
tmp = 4.0 * ((x - z) / y);
} else if (z <= 1.15e+41) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + (-4.0 * (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 (z <= (-95.0d0)) then
tmp = 4.0d0 * ((x - z) / y)
else if (z <= 1.15d+41) then
tmp = 4.0d0 + (4.0d0 * (x / y))
else
tmp = 4.0d0 + ((-4.0d0) * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -95.0) {
tmp = 4.0 * ((x - z) / y);
} else if (z <= 1.15e+41) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -95.0: tmp = 4.0 * ((x - z) / y) elif z <= 1.15e+41: tmp = 4.0 + (4.0 * (x / y)) else: tmp = 4.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -95.0) tmp = Float64(4.0 * Float64(Float64(x - z) / y)); elseif (z <= 1.15e+41) tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); else tmp = Float64(4.0 + Float64(-4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -95.0) tmp = 4.0 * ((x - z) / y); elseif (z <= 1.15e+41) tmp = 4.0 + (4.0 * (x / y)); else tmp = 4.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -95.0], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.15e+41], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -95:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+41}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if z < -95Initial 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 y around 0 83.4%
if -95 < z < 1.1499999999999999e41Initial program 99.1%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
Taylor expanded in z around 0 94.1%
if 1.1499999999999999e41 < z Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 90.8%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (<= z -95.0) (+ 1.0 (/ 4.0 (/ y (- x z)))) (if (<= z 1.8e+40) (+ 4.0 (* 4.0 (/ x y))) (+ 4.0 (* -4.0 (/ z y))))))
double code(double x, double y, double z) {
double tmp;
if (z <= -95.0) {
tmp = 1.0 + (4.0 / (y / (x - z)));
} else if (z <= 1.8e+40) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + (-4.0 * (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 (z <= (-95.0d0)) then
tmp = 1.0d0 + (4.0d0 / (y / (x - z)))
else if (z <= 1.8d+40) then
tmp = 4.0d0 + (4.0d0 * (x / y))
else
tmp = 4.0d0 + ((-4.0d0) * (z / y))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -95.0) {
tmp = 1.0 + (4.0 / (y / (x - z)));
} else if (z <= 1.8e+40) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + (-4.0 * (z / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -95.0: tmp = 1.0 + (4.0 / (y / (x - z))) elif z <= 1.8e+40: tmp = 4.0 + (4.0 * (x / y)) else: tmp = 4.0 + (-4.0 * (z / y)) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -95.0) tmp = Float64(1.0 + Float64(4.0 / Float64(y / Float64(x - z)))); elseif (z <= 1.8e+40) tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); else tmp = Float64(4.0 + Float64(-4.0 * Float64(z / y))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -95.0) tmp = 1.0 + (4.0 / (y / (x - z))); elseif (z <= 1.8e+40) tmp = 4.0 + (4.0 * (x / y)); else tmp = 4.0 + (-4.0 * (z / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -95.0], N[(1.0 + N[(4.0 / N[(y / N[(x - z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.8e+40], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -95:\\
\;\;\;\;1 + \frac{4}{\frac{y}{x - z}}\\
\mathbf{elif}\;z \leq 1.8 \cdot 10^{+40}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + -4 \cdot \frac{z}{y}\\
\end{array}
\end{array}
if z < -95Initial program 99.9%
associate-/l*99.6%
Simplified99.6%
Taylor expanded in y around 0 85.1%
if -95 < z < 1.79999999999999998e40Initial program 99.1%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
Taylor expanded in z around 0 94.1%
if 1.79999999999999998e40 < z Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 90.8%
Final simplification90.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -90.0) (not (<= z 1.65e+37))) (* -4.0 (/ z y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -90.0) || !(z <= 1.65e+37)) {
tmp = -4.0 * (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 ((z <= (-90.0d0)) .or. (.not. (z <= 1.65d+37))) then
tmp = (-4.0d0) * (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 ((z <= -90.0) || !(z <= 1.65e+37)) {
tmp = -4.0 * (z / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -90.0) or not (z <= 1.65e+37): tmp = -4.0 * (z / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -90.0) || !(z <= 1.65e+37)) tmp = Float64(-4.0 * Float64(z / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -90.0) || ~((z <= 1.65e+37))) tmp = -4.0 * (z / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -90.0], N[Not[LessEqual[z, 1.65e+37]], $MachinePrecision]], N[(-4.0 * N[(z / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -90 \lor \neg \left(z \leq 1.65 \cdot 10^{+37}\right):\\
\;\;\;\;-4 \cdot \frac{z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if z < -90 or 1.65e37 < z Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
Taylor expanded in z around inf 59.5%
if -90 < z < 1.65e37Initial program 99.1%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 60.1%
Final simplification59.8%
(FPCore (x y z) :precision binary64 1.0)
double code(double x, double y, double z) {
return 1.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
end function
public static double code(double x, double y, double z) {
return 1.0;
}
def code(x, y, z): return 1.0
function code(x, y, z) return 1.0 end
function tmp = code(x, y, z) tmp = 1.0; end
code[x_, y_, z_] := 1.0
\begin{array}{l}
\\
1
\end{array}
Initial program 99.5%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in z around inf 37.6%
associate-*r/37.6%
metadata-eval37.6%
associate-*r*37.6%
neg-mul-137.6%
associate-*l/37.5%
*-commutative37.5%
associate-*r/37.6%
neg-mul-137.6%
*-commutative37.6%
associate-*l*37.6%
metadata-eval37.6%
Simplified37.6%
Taylor expanded in z around 0 8.5%
Final simplification8.5%
(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.5%
associate-*l/99.7%
+-commutative99.7%
fma-def99.7%
Simplified99.7%
Taylor expanded in y around inf 40.5%
Final simplification40.5%
herbie shell --seed 2023293
(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)))