
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
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 - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 8 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
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 - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (fma (- x y) (/ 4.0 z) -2.0))
double code(double x, double y, double z) {
return fma((x - y), (4.0 / z), -2.0);
}
function code(x, y, z) return fma(Float64(x - y), Float64(4.0 / z), -2.0) end
code[x_, y_, z_] := N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision] + -2.0), $MachinePrecision]
\begin{array}{l}
\\
\mathsf{fma}\left(x - y, \frac{4}{z}, -2\right)
\end{array}
Initial program 99.6%
*-commutative99.6%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.8%
fma-neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate-/r/99.8%
distribute-lft-neg-in99.8%
distribute-frac-neg99.8%
*-commutative99.8%
distribute-lft-neg-in99.8%
associate-/l*99.8%
metadata-eval99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Final simplification99.8%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))) (t_1 (* -4.0 (/ y z))))
(if (<= x -1.05e+68)
t_0
(if (<= x -2.1e-115)
t_1
(if (<= x 3e-226)
-2.0
(if (<= x 2.1e-98) t_1 (if (<= x 2400000.0) -2.0 t_0)))))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -1.05e+68) {
tmp = t_0;
} else if (x <= -2.1e-115) {
tmp = t_1;
} else if (x <= 3e-226) {
tmp = -2.0;
} else if (x <= 2.1e-98) {
tmp = t_1;
} else if (x <= 2400000.0) {
tmp = -2.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 * (x / z)
t_1 = (-4.0d0) * (y / z)
if (x <= (-1.05d+68)) then
tmp = t_0
else if (x <= (-2.1d-115)) then
tmp = t_1
else if (x <= 3d-226) then
tmp = -2.0d0
else if (x <= 2.1d-98) then
tmp = t_1
else if (x <= 2400000.0d0) then
tmp = -2.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 / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -1.05e+68) {
tmp = t_0;
} else if (x <= -2.1e-115) {
tmp = t_1;
} else if (x <= 3e-226) {
tmp = -2.0;
} else if (x <= 2.1e-98) {
tmp = t_1;
} else if (x <= 2400000.0) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) t_1 = -4.0 * (y / z) tmp = 0 if x <= -1.05e+68: tmp = t_0 elif x <= -2.1e-115: tmp = t_1 elif x <= 3e-226: tmp = -2.0 elif x <= 2.1e-98: tmp = t_1 elif x <= 2400000.0: tmp = -2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (x <= -1.05e+68) tmp = t_0; elseif (x <= -2.1e-115) tmp = t_1; elseif (x <= 3e-226) tmp = -2.0; elseif (x <= 2.1e-98) tmp = t_1; elseif (x <= 2400000.0) tmp = -2.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / z); t_1 = -4.0 * (y / z); tmp = 0.0; if (x <= -1.05e+68) tmp = t_0; elseif (x <= -2.1e-115) tmp = t_1; elseif (x <= 3e-226) tmp = -2.0; elseif (x <= 2.1e-98) tmp = t_1; elseif (x <= 2400000.0) tmp = -2.0; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -1.05e+68], t$95$0, If[LessEqual[x, -2.1e-115], t$95$1, If[LessEqual[x, 3e-226], -2.0, If[LessEqual[x, 2.1e-98], t$95$1, If[LessEqual[x, 2400000.0], -2.0, t$95$0]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -1.05 \cdot 10^{+68}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;x \leq -2.1 \cdot 10^{-115}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 3 \cdot 10^{-226}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 2.1 \cdot 10^{-98}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;x \leq 2400000:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t_0\\
\end{array}
\end{array}
if x < -1.05e68 or 2.4e6 < x Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 69.4%
if -1.05e68 < x < -2.10000000000000002e-115 or 2.99999999999999995e-226 < x < 2.09999999999999992e-98Initial program 98.7%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 58.4%
if -2.10000000000000002e-115 < x < 2.99999999999999995e-226 or 2.09999999999999992e-98 < x < 2.4e6Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 59.1%
Final simplification63.4%
(FPCore (x y z) :precision binary64 (if (or (<= z -520000000000.0) (not (<= z 1.45e+15))) (- (* -4.0 (/ y z)) 2.0) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -520000000000.0) || !(z <= 1.45e+15)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = 4.0 * ((x - y) / 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 <= (-520000000000.0d0)) .or. (.not. (z <= 1.45d+15))) then
tmp = ((-4.0d0) * (y / z)) - 2.0d0
else
tmp = 4.0d0 * ((x - y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((z <= -520000000000.0) || !(z <= 1.45e+15)) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -520000000000.0) or not (z <= 1.45e+15): tmp = (-4.0 * (y / z)) - 2.0 else: tmp = 4.0 * ((x - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -520000000000.0) || !(z <= 1.45e+15)) tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); else tmp = Float64(4.0 * Float64(Float64(x - y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -520000000000.0) || ~((z <= 1.45e+15))) tmp = (-4.0 * (y / z)) - 2.0; else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -520000000000.0], N[Not[LessEqual[z, 1.45e+15]], $MachinePrecision]], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -520000000000 \lor \neg \left(z \leq 1.45 \cdot 10^{+15}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -5.2e11 or 1.45e15 < z Initial program 99.9%
*-commutative99.9%
associate-/l*99.9%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.8%
fma-neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate-/r/99.8%
distribute-lft-neg-in99.8%
distribute-frac-neg99.8%
*-commutative99.8%
distribute-lft-neg-in99.8%
associate-/l*99.8%
metadata-eval99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 82.3%
if -5.2e11 < z < 1.45e15Initial program 99.3%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 95.1%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (<= z -2.05e+187) -2.0 (if (<= z 6.5e+143) (* 4.0 (/ (- x y) z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.05e+187) {
tmp = -2.0;
} else if (z <= 6.5e+143) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = -2.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.05d+187)) then
tmp = -2.0d0
else if (z <= 6.5d+143) then
tmp = 4.0d0 * ((x - y) / z)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -2.05e+187) {
tmp = -2.0;
} else if (z <= 6.5e+143) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.05e+187: tmp = -2.0 elif z <= 6.5e+143: tmp = 4.0 * ((x - y) / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.05e+187) tmp = -2.0; elseif (z <= 6.5e+143) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.05e+187) tmp = -2.0; elseif (z <= 6.5e+143) tmp = 4.0 * ((x - y) / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.05e+187], -2.0, If[LessEqual[z, 6.5e+143], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.05 \cdot 10^{+187}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 6.5 \cdot 10^{+143}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.05e187 or 6.4999999999999997e143 < z Initial program 99.9%
associate-*l/99.8%
/-rgt-identity99.8%
metadata-eval99.8%
metadata-eval99.8%
/-rgt-identity99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around inf 82.3%
if -2.05e187 < z < 6.4999999999999997e143Initial program 99.6%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 82.7%
Final simplification82.6%
(FPCore (x y z) :precision binary64 (if (<= x -3e+44) (* 4.0 (/ (- x y) z)) (if (<= x 8e-31) (- (* -4.0 (/ y z)) 2.0) (- (* 4.0 (/ x z)) 2.0))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3e+44) {
tmp = 4.0 * ((x - y) / z);
} else if (x <= 8e-31) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (4.0 * (x / z)) - 2.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 <= (-3d+44)) then
tmp = 4.0d0 * ((x - y) / z)
else if (x <= 8d-31) then
tmp = ((-4.0d0) * (y / z)) - 2.0d0
else
tmp = (4.0d0 * (x / z)) - 2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -3e+44) {
tmp = 4.0 * ((x - y) / z);
} else if (x <= 8e-31) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = (4.0 * (x / z)) - 2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -3e+44: tmp = 4.0 * ((x - y) / z) elif x <= 8e-31: tmp = (-4.0 * (y / z)) - 2.0 else: tmp = (4.0 * (x / z)) - 2.0 return tmp
function code(x, y, z) tmp = 0.0 if (x <= -3e+44) tmp = Float64(4.0 * Float64(Float64(x - y) / z)); elseif (x <= 8e-31) tmp = Float64(Float64(-4.0 * Float64(y / z)) - 2.0); else tmp = Float64(Float64(4.0 * Float64(x / z)) - 2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -3e+44) tmp = 4.0 * ((x - y) / z); elseif (x <= 8e-31) tmp = (-4.0 * (y / z)) - 2.0; else tmp = (4.0 * (x / z)) - 2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -3e+44], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8e-31], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3 \cdot 10^{+44}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{elif}\;x \leq 8 \cdot 10^{-31}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\end{array}
\end{array}
if x < -2.99999999999999987e44Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 90.3%
if -2.99999999999999987e44 < x < 8.000000000000001e-31Initial program 99.3%
*-commutative99.3%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.9%
associate-/r/99.8%
fma-neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate-/r/99.8%
distribute-lft-neg-in99.8%
distribute-frac-neg99.8%
*-commutative99.8%
distribute-lft-neg-in99.8%
associate-/l*99.8%
metadata-eval99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around 0 90.1%
if 8.000000000000001e-31 < x Initial program 100.0%
*-commutative100.0%
associate-/l*100.0%
div-sub100.0%
*-lft-identity100.0%
metadata-eval100.0%
associate-/l*99.8%
associate-/r/99.8%
fma-neg99.8%
metadata-eval99.8%
/-rgt-identity99.8%
associate-/r/99.8%
distribute-lft-neg-in99.8%
distribute-frac-neg99.8%
*-commutative99.8%
distribute-lft-neg-in99.8%
associate-/l*99.8%
metadata-eval99.8%
*-inverses99.8%
metadata-eval99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around 0 91.1%
Final simplification90.4%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.25e-37) (not (<= y 1.35e+94))) (* -4.0 (/ y z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.25e-37) || !(y <= 1.35e+94)) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.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.25d-37)) .or. (.not. (y <= 1.35d+94))) then
tmp = (-4.0d0) * (y / z)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -1.25e-37) || !(y <= 1.35e+94)) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.25e-37) or not (y <= 1.35e+94): tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.25e-37) || !(y <= 1.35e+94)) tmp = Float64(-4.0 * Float64(y / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -1.25e-37) || ~((y <= 1.35e+94))) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.25e-37], N[Not[LessEqual[y, 1.35e+94]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.25 \cdot 10^{-37} \lor \neg \left(y \leq 1.35 \cdot 10^{+94}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if y < -1.2499999999999999e-37 or 1.3500000000000001e94 < y Initial program 99.3%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in y around inf 61.5%
if -1.2499999999999999e-37 < y < 1.3500000000000001e94Initial program 100.0%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 46.1%
Final simplification53.6%
(FPCore (x y z) :precision binary64 (* (/ 4.0 z) (+ (- x y) (* z -0.5))))
double code(double x, double y, double z) {
return (4.0 / z) * ((x - y) + (z * -0.5));
}
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 / z) * ((x - y) + (z * (-0.5d0)))
end function
public static double code(double x, double y, double z) {
return (4.0 / z) * ((x - y) + (z * -0.5));
}
def code(x, y, z): return (4.0 / z) * ((x - y) + (z * -0.5))
function code(x, y, z) return Float64(Float64(4.0 / z) * Float64(Float64(x - y) + Float64(z * -0.5))) end
function tmp = code(x, y, z) tmp = (4.0 / z) * ((x - y) + (z * -0.5)); end
code[x_, y_, z_] := N[(N[(4.0 / z), $MachinePrecision] * N[(N[(x - y), $MachinePrecision] + N[(z * -0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
\frac{4}{z} \cdot \left(\left(x - y\right) + z \cdot -0.5\right)
\end{array}
Initial program 99.6%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Final simplification99.7%
(FPCore (x y z) :precision binary64 -2.0)
double code(double x, double y, double z) {
return -2.0;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = -2.0d0
end function
public static double code(double x, double y, double z) {
return -2.0;
}
def code(x, y, z): return -2.0
function code(x, y, z) return -2.0 end
function tmp = code(x, y, z) tmp = -2.0; end
code[x_, y_, z_] := -2.0
\begin{array}{l}
\\
-2
\end{array}
Initial program 99.6%
associate-*l/99.7%
/-rgt-identity99.7%
metadata-eval99.7%
metadata-eval99.7%
/-rgt-identity99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 32.1%
Final simplification32.1%
(FPCore (x y z) :precision binary64 (- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z)))))
double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
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)) - (2.0d0 + (4.0d0 * (y / z)))
end function
public static double code(double x, double y, double z) {
return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)));
}
def code(x, y, z): return (4.0 * (x / z)) - (2.0 + (4.0 * (y / z)))
function code(x, y, z) return Float64(Float64(4.0 * Float64(x / z)) - Float64(2.0 + Float64(4.0 * Float64(y / z)))) end
function tmp = code(x, y, z) tmp = (4.0 * (x / z)) - (2.0 + (4.0 * (y / z))); end
code[x_, y_, z_] := N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - N[(2.0 + N[(4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \frac{x}{z} - \left(2 + 4 \cdot \frac{y}{z}\right)
\end{array}
herbie shell --seed 2024019
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:herbie-target
(- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))