
(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.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.8%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* z (/ -4.0 y))) (t_1 (* 4.0 (/ x y))))
(if (<= x -2.95e+32)
t_1
(if (<= x -3.1e-85)
4.0
(if (<= x 3.8e-302)
t_0
(if (<= x 1.2e-144)
4.0
(if (<= x 2.05e-110) t_0 (if (<= x 7.8e+90) 4.0 t_1))))))))
double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double t_1 = 4.0 * (x / y);
double tmp;
if (x <= -2.95e+32) {
tmp = t_1;
} else if (x <= -3.1e-85) {
tmp = 4.0;
} else if (x <= 3.8e-302) {
tmp = t_0;
} else if (x <= 1.2e-144) {
tmp = 4.0;
} else if (x <= 2.05e-110) {
tmp = t_0;
} else if (x <= 7.8e+90) {
tmp = 4.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 = z * ((-4.0d0) / y)
t_1 = 4.0d0 * (x / y)
if (x <= (-2.95d+32)) then
tmp = t_1
else if (x <= (-3.1d-85)) then
tmp = 4.0d0
else if (x <= 3.8d-302) then
tmp = t_0
else if (x <= 1.2d-144) then
tmp = 4.0d0
else if (x <= 2.05d-110) then
tmp = t_0
else if (x <= 7.8d+90) then
tmp = 4.0d0
else
tmp = t_1
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = z * (-4.0 / y);
double t_1 = 4.0 * (x / y);
double tmp;
if (x <= -2.95e+32) {
tmp = t_1;
} else if (x <= -3.1e-85) {
tmp = 4.0;
} else if (x <= 3.8e-302) {
tmp = t_0;
} else if (x <= 1.2e-144) {
tmp = 4.0;
} else if (x <= 2.05e-110) {
tmp = t_0;
} else if (x <= 7.8e+90) {
tmp = 4.0;
} else {
tmp = t_1;
}
return tmp;
}
def code(x, y, z): t_0 = z * (-4.0 / y) t_1 = 4.0 * (x / y) tmp = 0 if x <= -2.95e+32: tmp = t_1 elif x <= -3.1e-85: tmp = 4.0 elif x <= 3.8e-302: tmp = t_0 elif x <= 1.2e-144: tmp = 4.0 elif x <= 2.05e-110: tmp = t_0 elif x <= 7.8e+90: tmp = 4.0 else: tmp = t_1 return tmp
function code(x, y, z) t_0 = Float64(z * Float64(-4.0 / y)) t_1 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (x <= -2.95e+32) tmp = t_1; elseif (x <= -3.1e-85) tmp = 4.0; elseif (x <= 3.8e-302) tmp = t_0; elseif (x <= 1.2e-144) tmp = 4.0; elseif (x <= 2.05e-110) tmp = t_0; elseif (x <= 7.8e+90) tmp = 4.0; else tmp = t_1; end return tmp end
function tmp_2 = code(x, y, z) t_0 = z * (-4.0 / y); t_1 = 4.0 * (x / y); tmp = 0.0; if (x <= -2.95e+32) tmp = t_1; elseif (x <= -3.1e-85) tmp = 4.0; elseif (x <= 3.8e-302) tmp = t_0; elseif (x <= 1.2e-144) tmp = 4.0; elseif (x <= 2.05e-110) tmp = t_0; elseif (x <= 7.8e+90) tmp = 4.0; else tmp = t_1; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -2.95e+32], t$95$1, If[LessEqual[x, -3.1e-85], 4.0, If[LessEqual[x, 3.8e-302], t$95$0, If[LessEqual[x, 1.2e-144], 4.0, If[LessEqual[x, 2.05e-110], t$95$0, If[LessEqual[x, 7.8e+90], 4.0, t$95$1]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := z \cdot \frac{-4}{y}\\
t_1 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -2.95 \cdot 10^{+32}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq -3.1 \cdot 10^{-85}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 3.8 \cdot 10^{-302}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 1.2 \cdot 10^{-144}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{-110}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{+90}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t_1\\
\end{array}
\end{array}
if x < -2.94999999999999983e32 or 7.8000000000000004e90 < x Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.8%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 87.2%
Taylor expanded in x around inf 68.7%
*-commutative68.7%
Simplified68.7%
if -2.94999999999999983e32 < x < -3.1000000000000002e-85 or 3.8e-302 < x < 1.19999999999999997e-144 or 2.04999999999999991e-110 < x < 7.8000000000000004e90Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.8%
associate-*l/99.9%
associate-/l*99.9%
*-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 57.6%
if -3.1000000000000002e-85 < x < 3.8e-302 or 1.19999999999999997e-144 < x < 2.04999999999999991e-110Initial program 100.0%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
distribute-lft-in99.7%
associate-+r+99.7%
*-commutative99.7%
+-commutative99.7%
fma-def99.7%
associate-*r*99.7%
associate-*l/99.7%
associate-/l*99.7%
*-inverses99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 68.4%
Taylor expanded in x around 0 64.0%
*-commutative64.0%
associate-*l/64.0%
associate-*r/63.8%
Simplified63.8%
Final simplification63.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x y))))
(if (<= x -6.8e+31)
t_0
(if (<= x -9.7e-85)
4.0
(if (<= x 1.65e-296)
(* (/ z y) -4.0)
(if (<= x 1.4e-144)
4.0
(if (<= x 1.52e-108)
(* z (/ -4.0 y))
(if (<= x 3.05e+90) 4.0 t_0))))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / y);
double tmp;
if (x <= -6.8e+31) {
tmp = t_0;
} else if (x <= -9.7e-85) {
tmp = 4.0;
} else if (x <= 1.65e-296) {
tmp = (z / y) * -4.0;
} else if (x <= 1.4e-144) {
tmp = 4.0;
} else if (x <= 1.52e-108) {
tmp = z * (-4.0 / y);
} else if (x <= 3.05e+90) {
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) :: tmp
t_0 = 4.0d0 * (x / y)
if (x <= (-6.8d+31)) then
tmp = t_0
else if (x <= (-9.7d-85)) then
tmp = 4.0d0
else if (x <= 1.65d-296) then
tmp = (z / y) * (-4.0d0)
else if (x <= 1.4d-144) then
tmp = 4.0d0
else if (x <= 1.52d-108) then
tmp = z * ((-4.0d0) / y)
else if (x <= 3.05d+90) 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 * (x / y);
double tmp;
if (x <= -6.8e+31) {
tmp = t_0;
} else if (x <= -9.7e-85) {
tmp = 4.0;
} else if (x <= 1.65e-296) {
tmp = (z / y) * -4.0;
} else if (x <= 1.4e-144) {
tmp = 4.0;
} else if (x <= 1.52e-108) {
tmp = z * (-4.0 / y);
} else if (x <= 3.05e+90) {
tmp = 4.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / y) tmp = 0 if x <= -6.8e+31: tmp = t_0 elif x <= -9.7e-85: tmp = 4.0 elif x <= 1.65e-296: tmp = (z / y) * -4.0 elif x <= 1.4e-144: tmp = 4.0 elif x <= 1.52e-108: tmp = z * (-4.0 / y) elif x <= 3.05e+90: tmp = 4.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / y)) tmp = 0.0 if (x <= -6.8e+31) tmp = t_0; elseif (x <= -9.7e-85) tmp = 4.0; elseif (x <= 1.65e-296) tmp = Float64(Float64(z / y) * -4.0); elseif (x <= 1.4e-144) tmp = 4.0; elseif (x <= 1.52e-108) tmp = Float64(z * Float64(-4.0 / y)); elseif (x <= 3.05e+90) tmp = 4.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / y); tmp = 0.0; if (x <= -6.8e+31) tmp = t_0; elseif (x <= -9.7e-85) tmp = 4.0; elseif (x <= 1.65e-296) tmp = (z / y) * -4.0; elseif (x <= 1.4e-144) tmp = 4.0; elseif (x <= 1.52e-108) tmp = z * (-4.0 / y); elseif (x <= 3.05e+90) tmp = 4.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -6.8e+31], t$95$0, If[LessEqual[x, -9.7e-85], 4.0, If[LessEqual[x, 1.65e-296], N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision], If[LessEqual[x, 1.4e-144], 4.0, If[LessEqual[x, 1.52e-108], N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 3.05e+90], 4.0, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{y}\\
\mathbf{if}\;x \leq -6.8 \cdot 10^{+31}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -9.7 \cdot 10^{-85}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 1.65 \cdot 10^{-296}:\\
\;\;\;\;\frac{z}{y} \cdot -4\\
\mathbf{elif}\;x \leq 1.4 \cdot 10^{-144}:\\
\;\;\;\;4\\
\mathbf{elif}\;x \leq 1.52 \cdot 10^{-108}:\\
\;\;\;\;z \cdot \frac{-4}{y}\\
\mathbf{elif}\;x \leq 3.05 \cdot 10^{+90}:\\
\;\;\;\;4\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -6.7999999999999996e31 or 3.0499999999999998e90 < x Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.8%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 87.2%
Taylor expanded in x around inf 68.7%
*-commutative68.7%
Simplified68.7%
if -6.7999999999999996e31 < x < -9.6999999999999997e-85 or 1.65e-296 < x < 1.39999999999999999e-144 or 1.52000000000000001e-108 < x < 3.0499999999999998e90Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.8%
associate-*l/99.9%
associate-/l*99.9%
*-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 57.6%
if -9.6999999999999997e-85 < x < 1.65e-296Initial program 100.0%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
distribute-lft-in99.7%
associate-+r+99.7%
*-commutative99.7%
+-commutative99.7%
fma-def99.7%
associate-*r*99.7%
associate-*l/99.7%
associate-/l*99.7%
*-inverses99.7%
metadata-eval99.7%
metadata-eval99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 65.3%
Taylor expanded in x around 0 60.5%
*-commutative60.5%
Simplified60.5%
if 1.39999999999999999e-144 < x < 1.52000000000000001e-108Initial program 100.0%
associate-*l/100.0%
+-commutative100.0%
associate--l+100.0%
distribute-lft-in100.0%
associate-+r+100.0%
*-commutative100.0%
+-commutative100.0%
fma-def100.0%
associate-*r*100.0%
associate-*l/100.0%
associate-/l*100.0%
*-inverses100.0%
metadata-eval100.0%
metadata-eval100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
associate-*l/100.0%
associate-*r/100.0%
Simplified100.0%
Final simplification63.7%
(FPCore (x y z)
:precision binary64
(if (or (<= z -3.6e+131)
(not (or (<= z -1e+61) (and (not (<= z -1.3e+33)) (<= z 5e-51)))))
(* 4.0 (/ (- x z) y))
(+ 4.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.6e+131) || !((z <= -1e+61) || (!(z <= -1.3e+33) && (z <= 5e-51)))) {
tmp = 4.0 * ((x - 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 <= (-3.6d+131)) .or. (.not. (z <= (-1d+61)) .or. (.not. (z <= (-1.3d+33))) .and. (z <= 5d-51))) then
tmp = 4.0d0 * ((x - 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 <= -3.6e+131) || !((z <= -1e+61) || (!(z <= -1.3e+33) && (z <= 5e-51)))) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.6e+131) or not ((z <= -1e+61) or (not (z <= -1.3e+33) and (z <= 5e-51))): tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.6e+131) || !((z <= -1e+61) || (!(z <= -1.3e+33) && (z <= 5e-51)))) tmp = Float64(4.0 * Float64(Float64(x - 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 <= -3.6e+131) || ~(((z <= -1e+61) || (~((z <= -1.3e+33)) && (z <= 5e-51))))) tmp = 4.0 * ((x - z) / y); else tmp = 4.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.6e+131], N[Not[Or[LessEqual[z, -1e+61], And[N[Not[LessEqual[z, -1.3e+33]], $MachinePrecision], LessEqual[z, 5e-51]]]], $MachinePrecision]], N[(4.0 * N[(N[(x - z), $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 -3.6 \cdot 10^{+131} \lor \neg \left(z \leq -1 \cdot 10^{+61} \lor \neg \left(z \leq -1.3 \cdot 10^{+33}\right) \land z \leq 5 \cdot 10^{-51}\right):\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -3.60000000000000031e131 or -9.99999999999999949e60 < z < -1.2999999999999999e33 or 5.00000000000000004e-51 < z Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.7%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 99.9%
Taylor expanded in y around 0 88.2%
if -3.60000000000000031e131 < z < -9.99999999999999949e60 or -1.2999999999999999e33 < z < 5.00000000000000004e-51Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.8%
associate-*l/99.9%
associate-/l*99.9%
*-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in z around 0 91.9%
Final simplification90.3%
(FPCore (x y z) :precision binary64 (if (or (<= y -5.2e+67) (not (<= y 7.8e+113))) (+ 4.0 (* (/ z y) -4.0)) (* 4.0 (/ (- x z) y))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -5.2e+67) || !(y <= 7.8e+113)) {
tmp = 4.0 + ((z / y) * -4.0);
} 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 <= (-5.2d+67)) .or. (.not. (y <= 7.8d+113))) then
tmp = 4.0d0 + ((z / y) * (-4.0d0))
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 <= -5.2e+67) || !(y <= 7.8e+113)) {
tmp = 4.0 + ((z / y) * -4.0);
} else {
tmp = 4.0 * ((x - z) / y);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -5.2e+67) or not (y <= 7.8e+113): tmp = 4.0 + ((z / y) * -4.0) else: tmp = 4.0 * ((x - z) / y) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -5.2e+67) || !(y <= 7.8e+113)) tmp = Float64(4.0 + Float64(Float64(z / y) * -4.0)); 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 <= -5.2e+67) || ~((y <= 7.8e+113))) tmp = 4.0 + ((z / y) * -4.0); else tmp = 4.0 * ((x - z) / y); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -5.2e+67], N[Not[LessEqual[y, 7.8e+113]], $MachinePrecision]], N[(4.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.2 \cdot 10^{+67} \lor \neg \left(y \leq 7.8 \cdot 10^{+113}\right):\\
\;\;\;\;4 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\end{array}
\end{array}
if y < -5.2000000000000001e67 or 7.80000000000000039e113 < y Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.8%
associate-*l/99.9%
associate-/l*99.9%
*-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 90.9%
*-commutative90.9%
Simplified90.9%
if -5.2000000000000001e67 < y < 7.80000000000000039e113Initial program 100.0%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
distribute-lft-in99.7%
associate-+r+99.7%
*-commutative99.7%
+-commutative99.7%
fma-def99.7%
associate-*r*99.8%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 89.4%
Final simplification89.9%
(FPCore (x y z) :precision binary64 (if (<= y -1.06e+71) 4.0 (if (<= y 1.2e+147) (* 4.0 (/ (- x z) y)) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.06e+71) {
tmp = 4.0;
} else if (y <= 1.2e+147) {
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 <= (-1.06d+71)) then
tmp = 4.0d0
else if (y <= 1.2d+147) 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 <= -1.06e+71) {
tmp = 4.0;
} else if (y <= 1.2e+147) {
tmp = 4.0 * ((x - z) / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.06e+71: tmp = 4.0 elif y <= 1.2e+147: tmp = 4.0 * ((x - z) / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.06e+71) tmp = 4.0; elseif (y <= 1.2e+147) 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 <= -1.06e+71) tmp = 4.0; elseif (y <= 1.2e+147) tmp = 4.0 * ((x - z) / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.06e+71], 4.0, If[LessEqual[y, 1.2e+147], N[(4.0 * N[(N[(x - z), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.06 \cdot 10^{+71}:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 1.2 \cdot 10^{+147}:\\
\;\;\;\;4 \cdot \frac{x - z}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -1.06e71 or 1.20000000000000001e147 < y Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.9%
associate-+r+99.9%
*-commutative99.9%
+-commutative99.9%
fma-def99.9%
associate-*r*99.8%
associate-*l/99.9%
associate-/l*99.9%
*-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 74.6%
if -1.06e71 < y < 1.20000000000000001e147Initial program 100.0%
associate-*l/99.7%
+-commutative99.7%
associate--l+99.7%
distribute-lft-in99.7%
associate-+r+99.7%
*-commutative99.7%
+-commutative99.7%
fma-def99.7%
associate-*r*99.7%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Taylor expanded in y around 0 87.8%
Final simplification83.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.95e+131) (not (<= z 1.3e-42))) (* z (/ -4.0 y)) 4.0))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.95e+131) || !(z <= 1.3e-42)) {
tmp = 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 ((z <= (-2.95d+131)) .or. (.not. (z <= 1.3d-42))) then
tmp = 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 ((z <= -2.95e+131) || !(z <= 1.3e-42)) {
tmp = z * (-4.0 / y);
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.95e+131) or not (z <= 1.3e-42): tmp = z * (-4.0 / y) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.95e+131) || !(z <= 1.3e-42)) tmp = Float64(z * Float64(-4.0 / y)); else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -2.95e+131) || ~((z <= 1.3e-42))) tmp = z * (-4.0 / y); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.95e+131], N[Not[LessEqual[z, 1.3e-42]], $MachinePrecision]], N[(z * N[(-4.0 / y), $MachinePrecision]), $MachinePrecision], 4.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.95 \cdot 10^{+131} \lor \neg \left(z \leq 1.3 \cdot 10^{-42}\right):\\
\;\;\;\;z \cdot \frac{-4}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if z < -2.94999999999999992e131 or 1.3e-42 < z Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.7%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 99.9%
Taylor expanded in y around 0 87.4%
Taylor expanded in x around 0 68.7%
*-commutative68.7%
associate-*l/68.7%
associate-*r/68.6%
Simplified68.6%
if -2.94999999999999992e131 < z < 1.3e-42Initial program 100.0%
associate-*l/99.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.8%
associate-*l/99.9%
associate-/l*99.9%
*-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in y around inf 48.1%
Final simplification56.4%
(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.8%
+-commutative99.8%
associate--l+99.8%
distribute-lft-in99.8%
associate-+r+99.8%
*-commutative99.8%
+-commutative99.8%
fma-def99.8%
associate-*r*99.8%
associate-*l/99.8%
associate-/l*99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 34.4%
Final simplification34.4%
herbie shell --seed 2023171
(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)))