
(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 (/ (* 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}
Initial program 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))) (t_1 (* -4.0 (/ y z))))
(if (<= z -1.95e+101)
-2.0
(if (<= z -4e-26)
t_1
(if (<= z -2.3e-90)
t_0
(if (<= z -1.8e-149)
t_1
(if (<= z -1.35e-205)
t_0
(if (<= z 2.3e-296) t_1 (if (<= z 3.9e+33) t_0 -2.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 (z <= -1.95e+101) {
tmp = -2.0;
} else if (z <= -4e-26) {
tmp = t_1;
} else if (z <= -2.3e-90) {
tmp = t_0;
} else if (z <= -1.8e-149) {
tmp = t_1;
} else if (z <= -1.35e-205) {
tmp = t_0;
} else if (z <= 2.3e-296) {
tmp = t_1;
} else if (z <= 3.9e+33) {
tmp = t_0;
} 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) :: t_0
real(8) :: t_1
real(8) :: tmp
t_0 = 4.0d0 * (x / z)
t_1 = (-4.0d0) * (y / z)
if (z <= (-1.95d+101)) then
tmp = -2.0d0
else if (z <= (-4d-26)) then
tmp = t_1
else if (z <= (-2.3d-90)) then
tmp = t_0
else if (z <= (-1.8d-149)) then
tmp = t_1
else if (z <= (-1.35d-205)) then
tmp = t_0
else if (z <= 2.3d-296) then
tmp = t_1
else if (z <= 3.9d+33) then
tmp = t_0
else
tmp = -2.0d0
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 (z <= -1.95e+101) {
tmp = -2.0;
} else if (z <= -4e-26) {
tmp = t_1;
} else if (z <= -2.3e-90) {
tmp = t_0;
} else if (z <= -1.8e-149) {
tmp = t_1;
} else if (z <= -1.35e-205) {
tmp = t_0;
} else if (z <= 2.3e-296) {
tmp = t_1;
} else if (z <= 3.9e+33) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) t_1 = -4.0 * (y / z) tmp = 0 if z <= -1.95e+101: tmp = -2.0 elif z <= -4e-26: tmp = t_1 elif z <= -2.3e-90: tmp = t_0 elif z <= -1.8e-149: tmp = t_1 elif z <= -1.35e-205: tmp = t_0 elif z <= 2.3e-296: tmp = t_1 elif z <= 3.9e+33: tmp = t_0 else: tmp = -2.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 (z <= -1.95e+101) tmp = -2.0; elseif (z <= -4e-26) tmp = t_1; elseif (z <= -2.3e-90) tmp = t_0; elseif (z <= -1.8e-149) tmp = t_1; elseif (z <= -1.35e-205) tmp = t_0; elseif (z <= 2.3e-296) tmp = t_1; elseif (z <= 3.9e+33) tmp = t_0; else tmp = -2.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 (z <= -1.95e+101) tmp = -2.0; elseif (z <= -4e-26) tmp = t_1; elseif (z <= -2.3e-90) tmp = t_0; elseif (z <= -1.8e-149) tmp = t_1; elseif (z <= -1.35e-205) tmp = t_0; elseif (z <= 2.3e-296) tmp = t_1; elseif (z <= 3.9e+33) tmp = t_0; else tmp = -2.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[z, -1.95e+101], -2.0, If[LessEqual[z, -4e-26], t$95$1, If[LessEqual[z, -2.3e-90], t$95$0, If[LessEqual[z, -1.8e-149], t$95$1, If[LessEqual[z, -1.35e-205], t$95$0, If[LessEqual[z, 2.3e-296], t$95$1, If[LessEqual[z, 3.9e+33], t$95$0, -2.0]]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -1.95 \cdot 10^{+101}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -4 \cdot 10^{-26}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -2.3 \cdot 10^{-90}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq -1.8 \cdot 10^{-149}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq -1.35 \cdot 10^{-205}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 2.3 \cdot 10^{-296}:\\
\;\;\;\;t_1\\
\mathbf{elif}\;z \leq 3.9 \cdot 10^{+33}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.95e101 or 3.9000000000000002e33 < z Initial program 99.9%
associate-*l/99.6%
/-rgt-identity99.6%
metadata-eval99.6%
metadata-eval99.6%
/-rgt-identity99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 69.0%
if -1.95e101 < z < -4.0000000000000002e-26 or -2.2999999999999998e-90 < z < -1.8000000000000001e-149 or -1.35e-205 < z < 2.30000000000000004e-296Initial 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 y around inf 64.9%
if -4.0000000000000002e-26 < z < -2.2999999999999998e-90 or -1.8000000000000001e-149 < z < -1.35e-205 or 2.30000000000000004e-296 < z < 3.9000000000000002e33Initial program 100.0%
associate-*l/99.6%
/-rgt-identity99.6%
metadata-eval99.6%
metadata-eval99.6%
/-rgt-identity99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in x around inf 59.1%
Final simplification64.8%
(FPCore (x y z)
:precision binary64
(if (<= z -1.35e+192)
-2.0
(if (or (<= z -1.7e+179) (and (not (<= z -7.9e+101)) (<= z 1.3e+88)))
(* 4.0 (/ (- x y) z))
-2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.35e+192) {
tmp = -2.0;
} else if ((z <= -1.7e+179) || (!(z <= -7.9e+101) && (z <= 1.3e+88))) {
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 <= (-1.35d+192)) then
tmp = -2.0d0
else if ((z <= (-1.7d+179)) .or. (.not. (z <= (-7.9d+101))) .and. (z <= 1.3d+88)) 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 <= -1.35e+192) {
tmp = -2.0;
} else if ((z <= -1.7e+179) || (!(z <= -7.9e+101) && (z <= 1.3e+88))) {
tmp = 4.0 * ((x - y) / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.35e+192: tmp = -2.0 elif (z <= -1.7e+179) or (not (z <= -7.9e+101) and (z <= 1.3e+88)): tmp = 4.0 * ((x - y) / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.35e+192) tmp = -2.0; elseif ((z <= -1.7e+179) || (!(z <= -7.9e+101) && (z <= 1.3e+88))) 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 <= -1.35e+192) tmp = -2.0; elseif ((z <= -1.7e+179) || (~((z <= -7.9e+101)) && (z <= 1.3e+88))) tmp = 4.0 * ((x - y) / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.35e+192], -2.0, If[Or[LessEqual[z, -1.7e+179], And[N[Not[LessEqual[z, -7.9e+101]], $MachinePrecision], LessEqual[z, 1.3e+88]]], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+192}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -1.7 \cdot 10^{+179} \lor \neg \left(z \leq -7.9 \cdot 10^{+101}\right) \land z \leq 1.3 \cdot 10^{+88}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.34999999999999995e192 or -1.69999999999999998e179 < z < -7.8999999999999998e101 or 1.3e88 < z Initial program 99.9%
associate-*l/99.6%
/-rgt-identity99.6%
metadata-eval99.6%
metadata-eval99.6%
/-rgt-identity99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 75.4%
if -1.34999999999999995e192 < z < -1.69999999999999998e179 or -7.8999999999999998e101 < z < 1.3e88Initial 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 86.9%
Final simplification82.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.15e+18) (not (<= z 1.86e+25))) (- (* -4.0 (/ y z)) 2.0) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.15e+18) || !(z <= 1.86e+25)) {
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 <= (-2.15d+18)) .or. (.not. (z <= 1.86d+25))) 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 <= -2.15e+18) || !(z <= 1.86e+25)) {
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 <= -2.15e+18) or not (z <= 1.86e+25): 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 <= -2.15e+18) || !(z <= 1.86e+25)) 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 <= -2.15e+18) || ~((z <= 1.86e+25))) 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, -2.15e+18], N[Not[LessEqual[z, 1.86e+25]], $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 -2.15 \cdot 10^{+18} \lor \neg \left(z \leq 1.86 \cdot 10^{+25}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -2.15e18 or 1.86e25 < 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.9%
fma-neg99.9%
metadata-eval99.9%
/-rgt-identity99.9%
associate-/r/99.9%
distribute-lft-neg-in99.9%
distribute-frac-neg99.9%
*-commutative99.9%
distribute-lft-neg-in99.9%
associate-/l*99.9%
metadata-eval99.9%
*-inverses99.9%
metadata-eval99.9%
metadata-eval99.9%
Simplified99.9%
Taylor expanded in x around 0 85.6%
if -2.15e18 < z < 1.86e25Initial 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.9%
Final simplification88.2%
(FPCore (x y z) :precision binary64 (if (<= x -1.1e+76) (- (* 4.0 (/ x z)) 2.0) (if (<= x 3.1e+60) (- (* -4.0 (/ y z)) 2.0) (* 4.0 (/ (- x y) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.1e+76) {
tmp = (4.0 * (x / z)) - 2.0;
} else if (x <= 3.1e+60) {
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 (x <= (-1.1d+76)) then
tmp = (4.0d0 * (x / z)) - 2.0d0
else if (x <= 3.1d+60) 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 (x <= -1.1e+76) {
tmp = (4.0 * (x / z)) - 2.0;
} else if (x <= 3.1e+60) {
tmp = (-4.0 * (y / z)) - 2.0;
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.1e+76: tmp = (4.0 * (x / z)) - 2.0 elif x <= 3.1e+60: 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 (x <= -1.1e+76) tmp = Float64(Float64(4.0 * Float64(x / z)) - 2.0); elseif (x <= 3.1e+60) 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 (x <= -1.1e+76) tmp = (4.0 * (x / z)) - 2.0; elseif (x <= 3.1e+60) tmp = (-4.0 * (y / z)) - 2.0; else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.1e+76], N[(N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision], If[LessEqual[x, 3.1e+60], 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}\;x \leq -1.1 \cdot 10^{+76}:\\
\;\;\;\;4 \cdot \frac{x}{z} - 2\\
\mathbf{elif}\;x \leq 3.1 \cdot 10^{+60}:\\
\;\;\;\;-4 \cdot \frac{y}{z} - 2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if x < -1.1e76Initial 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 92.6%
if -1.1e76 < x < 3.1000000000000001e60Initial program 100.0%
*-commutative100.0%
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 89.7%
if 3.1000000000000001e60 < 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 z around 0 86.9%
Final simplification89.4%
(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 100.0%
associate-*l/99.6%
/-rgt-identity99.6%
metadata-eval99.6%
metadata-eval99.6%
/-rgt-identity99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Final simplification99.6%
(FPCore (x y z) :precision binary64 (if (<= z -2.65e+101) -2.0 (if (<= z 5.6e+34) (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.65e+101) {
tmp = -2.0;
} else if (z <= 5.6e+34) {
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 (z <= (-2.65d+101)) then
tmp = -2.0d0
else if (z <= 5.6d+34) 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 (z <= -2.65e+101) {
tmp = -2.0;
} else if (z <= 5.6e+34) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.65e+101: tmp = -2.0 elif z <= 5.6e+34: tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.65e+101) tmp = -2.0; elseif (z <= 5.6e+34) 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 (z <= -2.65e+101) tmp = -2.0; elseif (z <= 5.6e+34) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.65e+101], -2.0, If[LessEqual[z, 5.6e+34], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.65 \cdot 10^{+101}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 5.6 \cdot 10^{+34}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.65000000000000003e101 or 5.60000000000000016e34 < z Initial program 99.9%
associate-*l/99.6%
/-rgt-identity99.6%
metadata-eval99.6%
metadata-eval99.6%
/-rgt-identity99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 69.0%
if -2.65000000000000003e101 < z < 5.60000000000000016e34Initial 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 y around inf 46.4%
Final simplification56.5%
(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 100.0%
associate-*l/99.6%
/-rgt-identity99.6%
metadata-eval99.6%
metadata-eval99.6%
/-rgt-identity99.6%
sub-neg99.6%
distribute-rgt-neg-in99.6%
metadata-eval99.6%
Simplified99.6%
Taylor expanded in z around inf 37.0%
Final simplification37.0%
(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 2024013
(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))