
(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%
+-commutative99.9%
*-commutative99.9%
associate-*r/99.3%
fma-def99.3%
associate--l+99.3%
--rgt-identity99.3%
associate-+l-99.3%
sub-neg99.3%
associate--r+99.3%
neg-sub099.3%
distribute-rgt-neg-in99.3%
fma-neg99.3%
metadata-eval99.3%
remove-double-neg99.3%
Simplified99.3%
Taylor expanded in y around 0 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (+ 1.0 (/ (* z -4.0) y))) (t_1 (+ 1.0 (* 4.0 (/ x y)))))
(if (<= y -16200000.0)
4.0
(if (<= y -1.05e-168)
t_1
(if (<= y -3.7e-186)
t_0
(if (<= y -6.4e-281)
t_1
(if (<= y 2e-241) t_0 (if (<= y 2.4e+62) t_1 4.0))))))))
double code(double x, double y, double z) {
double t_0 = 1.0 + ((z * -4.0) / y);
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (y <= -16200000.0) {
tmp = 4.0;
} else if (y <= -1.05e-168) {
tmp = t_1;
} else if (y <= -3.7e-186) {
tmp = t_0;
} else if (y <= -6.4e-281) {
tmp = t_1;
} else if (y <= 2e-241) {
tmp = t_0;
} else if (y <= 2.4e+62) {
tmp = t_1;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 1.0d0 + ((z * (-4.0d0)) / y)
t_1 = 1.0d0 + (4.0d0 * (x / y))
if (y <= (-16200000.0d0)) then
tmp = 4.0d0
else if (y <= (-1.05d-168)) then
tmp = t_1
else if (y <= (-3.7d-186)) then
tmp = t_0
else if (y <= (-6.4d-281)) then
tmp = t_1
else if (y <= 2d-241) then
tmp = t_0
else if (y <= 2.4d+62) then
tmp = t_1
else
tmp = 4.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double t_0 = 1.0 + ((z * -4.0) / y);
double t_1 = 1.0 + (4.0 * (x / y));
double tmp;
if (y <= -16200000.0) {
tmp = 4.0;
} else if (y <= -1.05e-168) {
tmp = t_1;
} else if (y <= -3.7e-186) {
tmp = t_0;
} else if (y <= -6.4e-281) {
tmp = t_1;
} else if (y <= 2e-241) {
tmp = t_0;
} else if (y <= 2.4e+62) {
tmp = t_1;
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): t_0 = 1.0 + ((z * -4.0) / y) t_1 = 1.0 + (4.0 * (x / y)) tmp = 0 if y <= -16200000.0: tmp = 4.0 elif y <= -1.05e-168: tmp = t_1 elif y <= -3.7e-186: tmp = t_0 elif y <= -6.4e-281: tmp = t_1 elif y <= 2e-241: tmp = t_0 elif y <= 2.4e+62: tmp = t_1 else: tmp = 4.0 return tmp
function code(x, y, z) t_0 = Float64(1.0 + Float64(Float64(z * -4.0) / y)) t_1 = Float64(1.0 + Float64(4.0 * Float64(x / y))) tmp = 0.0 if (y <= -16200000.0) tmp = 4.0; elseif (y <= -1.05e-168) tmp = t_1; elseif (y <= -3.7e-186) tmp = t_0; elseif (y <= -6.4e-281) tmp = t_1; elseif (y <= 2e-241) tmp = t_0; elseif (y <= 2.4e+62) tmp = t_1; else tmp = 4.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 1.0 + ((z * -4.0) / y); t_1 = 1.0 + (4.0 * (x / y)); tmp = 0.0; if (y <= -16200000.0) tmp = 4.0; elseif (y <= -1.05e-168) tmp = t_1; elseif (y <= -3.7e-186) tmp = t_0; elseif (y <= -6.4e-281) tmp = t_1; elseif (y <= 2e-241) tmp = t_0; elseif (y <= 2.4e+62) tmp = t_1; else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(1.0 + N[(N[(z * -4.0), $MachinePrecision] / y), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[y, -16200000.0], 4.0, If[LessEqual[y, -1.05e-168], t$95$1, If[LessEqual[y, -3.7e-186], t$95$0, If[LessEqual[y, -6.4e-281], t$95$1, If[LessEqual[y, 2e-241], t$95$0, If[LessEqual[y, 2.4e+62], t$95$1, 4.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 1 + \frac{z \cdot -4}{y}\\
t_1 := 1 + 4 \cdot \frac{x}{y}\\
\mathbf{if}\;y \leq -16200000:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq -1.05 \cdot 10^{-168}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq -3.7 \cdot 10^{-186}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq -6.4 \cdot 10^{-281}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-241}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;y \leq 2.4 \cdot 10^{+62}:\\
\;\;\;\;t_1\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -1.62e7 or 2.4e62 < y Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
associate-*r/99.7%
fma-def99.7%
associate--l+99.7%
--rgt-identity99.7%
associate-+l-99.7%
sub-neg99.7%
associate--r+99.7%
neg-sub099.7%
distribute-rgt-neg-in99.7%
fma-neg99.7%
metadata-eval99.7%
remove-double-neg99.7%
Simplified99.7%
Taylor expanded in y around inf 68.0%
if -1.62e7 < y < -1.04999999999999997e-168 or -3.7000000000000002e-186 < y < -6.4000000000000001e-281 or 1.9999999999999999e-241 < y < 2.4e62Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.7%
Simplified99.7%
Taylor expanded in x around inf 60.6%
if -1.04999999999999997e-168 < y < -3.7000000000000002e-186 or -6.4000000000000001e-281 < y < 1.9999999999999999e-241Initial program 100.0%
associate-*l/95.2%
+-commutative95.2%
fma-def95.2%
Simplified95.2%
Taylor expanded in z around inf 77.8%
associate-*r/77.8%
metadata-eval77.8%
associate-*r*77.8%
neg-mul-177.8%
associate-*l/77.4%
*-commutative77.4%
associate-*r/77.8%
neg-mul-177.8%
*-commutative77.8%
associate-*l*77.8%
metadata-eval77.8%
Simplified77.8%
Final simplification65.9%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.7e+213) (not (<= z 4.1e+81))) (+ 1.0 (/ (* z -4.0) y)) (+ 4.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.7e+213) || !(z <= 4.1e+81)) {
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 <= (-3.7d+213)) .or. (.not. (z <= 4.1d+81))) 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 <= -3.7e+213) || !(z <= 4.1e+81)) {
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 <= -3.7e+213) or not (z <= 4.1e+81): 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 <= -3.7e+213) || !(z <= 4.1e+81)) 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 <= -3.7e+213) || ~((z <= 4.1e+81))) 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, -3.7e+213], N[Not[LessEqual[z, 4.1e+81]], $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 -3.7 \cdot 10^{+213} \lor \neg \left(z \leq 4.1 \cdot 10^{+81}\right):\\
\;\;\;\;1 + \frac{z \cdot -4}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -3.69999999999999993e213 or 4.10000000000000012e81 < z Initial program 99.9%
associate-*l/99.8%
+-commutative99.8%
fma-def99.8%
Simplified99.8%
Taylor expanded in z around inf 84.4%
associate-*r/84.4%
metadata-eval84.4%
associate-*r*84.4%
neg-mul-184.4%
associate-*l/84.3%
*-commutative84.3%
associate-*r/84.4%
neg-mul-184.4%
*-commutative84.4%
associate-*l*84.4%
metadata-eval84.4%
Simplified84.4%
if -3.69999999999999993e213 < z < 4.10000000000000012e81Initial program 99.9%
+-commutative99.9%
*-commutative99.9%
associate-*r/99.2%
fma-def99.2%
associate--l+99.2%
--rgt-identity99.2%
associate-+l-99.2%
sub-neg99.2%
associate--r+99.2%
neg-sub099.2%
distribute-rgt-neg-in99.2%
fma-neg99.2%
metadata-eval99.2%
remove-double-neg99.2%
Simplified99.2%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 88.1%
*-commutative88.1%
Simplified88.1%
Final simplification87.2%
(FPCore (x y z) :precision binary64 (if (or (<= z -3.7e+213) (not (<= z 4.1e+76))) (+ 4.0 (* (/ z y) -4.0)) (+ 4.0 (* 4.0 (/ x y)))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -3.7e+213) || !(z <= 4.1e+76)) {
tmp = 4.0 + ((z / y) * -4.0);
} 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.7d+213)) .or. (.not. (z <= 4.1d+76))) then
tmp = 4.0d0 + ((z / y) * (-4.0d0))
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.7e+213) || !(z <= 4.1e+76)) {
tmp = 4.0 + ((z / y) * -4.0);
} else {
tmp = 4.0 + (4.0 * (x / y));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -3.7e+213) or not (z <= 4.1e+76): tmp = 4.0 + ((z / y) * -4.0) else: tmp = 4.0 + (4.0 * (x / y)) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -3.7e+213) || !(z <= 4.1e+76)) tmp = Float64(4.0 + Float64(Float64(z / y) * -4.0)); 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.7e+213) || ~((z <= 4.1e+76))) tmp = 4.0 + ((z / y) * -4.0); else tmp = 4.0 + (4.0 * (x / y)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -3.7e+213], N[Not[LessEqual[z, 4.1e+76]], $MachinePrecision]], N[(4.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $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.7 \cdot 10^{+213} \lor \neg \left(z \leq 4.1 \cdot 10^{+76}\right):\\
\;\;\;\;4 + \frac{z}{y} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\end{array}
\end{array}
if z < -3.69999999999999993e213 or 4.0999999999999998e76 < z Initial program 99.9%
+-commutative99.9%
*-commutative99.9%
associate-*r/99.8%
fma-def99.8%
associate--l+99.8%
--rgt-identity99.8%
associate-+l-99.8%
sub-neg99.8%
associate--r+99.8%
neg-sub099.8%
distribute-rgt-neg-in99.8%
fma-neg99.8%
metadata-eval99.8%
remove-double-neg99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 98.5%
*-commutative98.5%
Simplified98.5%
if -3.69999999999999993e213 < z < 4.0999999999999998e76Initial program 99.9%
+-commutative99.9%
*-commutative99.9%
associate-*r/99.2%
fma-def99.2%
associate--l+99.2%
--rgt-identity99.2%
associate-+l-99.2%
sub-neg99.2%
associate--r+99.2%
neg-sub099.2%
distribute-rgt-neg-in99.2%
fma-neg99.2%
metadata-eval99.2%
remove-double-neg99.2%
Simplified99.2%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 88.1%
*-commutative88.1%
Simplified88.1%
Final simplification90.6%
(FPCore (x y z) :precision binary64 (if (<= y -12500000.0) 4.0 (if (<= y 4.4e+61) (+ 1.0 (* 4.0 (/ x y))) 4.0)))
double code(double x, double y, double z) {
double tmp;
if (y <= -12500000.0) {
tmp = 4.0;
} else if (y <= 4.4e+61) {
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 <= (-12500000.0d0)) then
tmp = 4.0d0
else if (y <= 4.4d+61) 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 <= -12500000.0) {
tmp = 4.0;
} else if (y <= 4.4e+61) {
tmp = 1.0 + (4.0 * (x / y));
} else {
tmp = 4.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -12500000.0: tmp = 4.0 elif y <= 4.4e+61: tmp = 1.0 + (4.0 * (x / y)) else: tmp = 4.0 return tmp
function code(x, y, z) tmp = 0.0 if (y <= -12500000.0) tmp = 4.0; elseif (y <= 4.4e+61) 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 <= -12500000.0) tmp = 4.0; elseif (y <= 4.4e+61) tmp = 1.0 + (4.0 * (x / y)); else tmp = 4.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -12500000.0], 4.0, If[LessEqual[y, 4.4e+61], N[(1.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], 4.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -12500000:\\
\;\;\;\;4\\
\mathbf{elif}\;y \leq 4.4 \cdot 10^{+61}:\\
\;\;\;\;1 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4\\
\end{array}
\end{array}
if y < -1.25e7 or 4.4000000000000001e61 < y Initial program 99.8%
+-commutative99.8%
*-commutative99.8%
associate-*r/99.7%
fma-def99.7%
associate--l+99.7%
--rgt-identity99.7%
associate-+l-99.7%
sub-neg99.7%
associate--r+99.7%
neg-sub099.7%
distribute-rgt-neg-in99.7%
fma-neg99.7%
metadata-eval99.7%
remove-double-neg99.7%
Simplified99.7%
Taylor expanded in y around inf 68.0%
if -1.25e7 < y < 4.4000000000000001e61Initial program 100.0%
associate-*l/98.9%
+-commutative98.9%
fma-def98.9%
Simplified98.9%
Taylor expanded in x around inf 55.6%
Final simplification62.0%
(FPCore (x y z) :precision binary64 (if (<= z -2.22e+161) (+ 1.0 (* (- x z) (/ 4.0 y))) (if (<= z 6.2e+76) (+ 4.0 (* 4.0 (/ x y))) (+ 4.0 (* (/ z y) -4.0)))))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.22e+161) {
tmp = 1.0 + ((x - z) * (4.0 / y));
} else if (z <= 6.2e+76) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + ((z / y) * -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.22d+161)) then
tmp = 1.0d0 + ((x - z) * (4.0d0 / y))
else if (z <= 6.2d+76) then
tmp = 4.0d0 + (4.0d0 * (x / y))
else
tmp = 4.0d0 + ((z / y) * (-4.0d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.22e+161) {
tmp = 1.0 + ((x - z) * (4.0 / y));
} else if (z <= 6.2e+76) {
tmp = 4.0 + (4.0 * (x / y));
} else {
tmp = 4.0 + ((z / y) * -4.0);
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.22e+161: tmp = 1.0 + ((x - z) * (4.0 / y)) elif z <= 6.2e+76: tmp = 4.0 + (4.0 * (x / y)) else: tmp = 4.0 + ((z / y) * -4.0) return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.22e+161) tmp = Float64(1.0 + Float64(Float64(x - z) * Float64(4.0 / y))); elseif (z <= 6.2e+76) tmp = Float64(4.0 + Float64(4.0 * Float64(x / y))); else tmp = Float64(4.0 + Float64(Float64(z / y) * -4.0)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.22e+161) tmp = 1.0 + ((x - z) * (4.0 / y)); elseif (z <= 6.2e+76) tmp = 4.0 + (4.0 * (x / y)); else tmp = 4.0 + ((z / y) * -4.0); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.22e+161], N[(1.0 + N[(N[(x - z), $MachinePrecision] * N[(4.0 / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 6.2e+76], N[(4.0 + N[(4.0 * N[(x / y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 + N[(N[(z / y), $MachinePrecision] * -4.0), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.22 \cdot 10^{+161}:\\
\;\;\;\;1 + \left(x - z\right) \cdot \frac{4}{y}\\
\mathbf{elif}\;z \leq 6.2 \cdot 10^{+76}:\\
\;\;\;\;4 + 4 \cdot \frac{x}{y}\\
\mathbf{else}:\\
\;\;\;\;4 + \frac{z}{y} \cdot -4\\
\end{array}
\end{array}
if z < -2.22e161Initial program 100.0%
associate-*l/99.9%
+-commutative99.9%
fma-def99.9%
Simplified99.9%
Taylor expanded in y around 0 92.1%
if -2.22e161 < z < 6.20000000000000023e76Initial program 99.9%
+-commutative99.9%
*-commutative99.9%
associate-*r/99.2%
fma-def99.1%
associate--l+99.1%
--rgt-identity99.1%
associate-+l-99.1%
sub-neg99.1%
associate--r+99.1%
neg-sub099.1%
distribute-rgt-neg-in99.1%
fma-neg99.1%
metadata-eval99.1%
remove-double-neg99.1%
Simplified99.1%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around inf 89.0%
*-commutative89.0%
Simplified89.0%
if 6.20000000000000023e76 < z Initial program 99.9%
+-commutative99.9%
*-commutative99.9%
associate-*r/99.8%
fma-def99.8%
associate--l+99.8%
--rgt-identity99.8%
associate-+l-99.8%
sub-neg99.8%
associate--r+99.8%
neg-sub099.8%
distribute-rgt-neg-in99.8%
fma-neg99.8%
metadata-eval99.8%
remove-double-neg99.8%
Simplified99.8%
Taylor expanded in y around 0 100.0%
Taylor expanded in x around 0 100.0%
*-commutative100.0%
Simplified100.0%
Final simplification91.0%
(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.9%
associate-*l/99.3%
+-commutative99.3%
fma-def99.3%
Simplified99.3%
Taylor expanded in z around inf 35.3%
associate-*r/35.3%
metadata-eval35.3%
associate-*r*35.3%
neg-mul-135.3%
associate-*l/35.2%
*-commutative35.2%
associate-*r/35.3%
neg-mul-135.3%
*-commutative35.3%
associate-*l*35.3%
metadata-eval35.3%
Simplified35.3%
Taylor expanded in z around 0 8.2%
Final simplification8.2%
(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%
+-commutative99.9%
*-commutative99.9%
associate-*r/99.3%
fma-def99.3%
associate--l+99.3%
--rgt-identity99.3%
associate-+l-99.3%
sub-neg99.3%
associate--r+99.3%
neg-sub099.3%
distribute-rgt-neg-in99.3%
fma-neg99.3%
metadata-eval99.3%
remove-double-neg99.3%
Simplified99.3%
Taylor expanded in y around inf 39.2%
Final simplification39.2%
herbie shell --seed 2023290
(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)))