
(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)) 2.0))
double code(double x, double y, double z) {
return (4.0 * ((x - y) / z)) - 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 = (4.0d0 * ((x - y) / z)) - 2.0d0
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) / z)) - 2.0;
}
def code(x, y, z): return (4.0 * ((x - y) / z)) - 2.0
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) / z)) - 2.0) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) / z)) - 2.0; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision] - 2.0), $MachinePrecision]
\begin{array}{l}
\\
4 \cdot \frac{x - y}{z} - 2
\end{array}
Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* (/ y z) -4.0)))
(if (<= z -1.05e-13)
-2.0
(if (<= z 8e-271)
t_0
(if (<= z 1.9e-199) (* 4.0 (/ x z)) (if (<= z 7.5e+14) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = (y / z) * -4.0;
double tmp;
if (z <= -1.05e-13) {
tmp = -2.0;
} else if (z <= 8e-271) {
tmp = t_0;
} else if (z <= 1.9e-199) {
tmp = 4.0 * (x / z);
} else if (z <= 7.5e+14) {
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) :: tmp
t_0 = (y / z) * (-4.0d0)
if (z <= (-1.05d-13)) then
tmp = -2.0d0
else if (z <= 8d-271) then
tmp = t_0
else if (z <= 1.9d-199) then
tmp = 4.0d0 * (x / z)
else if (z <= 7.5d+14) 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 = (y / z) * -4.0;
double tmp;
if (z <= -1.05e-13) {
tmp = -2.0;
} else if (z <= 8e-271) {
tmp = t_0;
} else if (z <= 1.9e-199) {
tmp = 4.0 * (x / z);
} else if (z <= 7.5e+14) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = (y / z) * -4.0 tmp = 0 if z <= -1.05e-13: tmp = -2.0 elif z <= 8e-271: tmp = t_0 elif z <= 1.9e-199: tmp = 4.0 * (x / z) elif z <= 7.5e+14: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(y / z) * -4.0) tmp = 0.0 if (z <= -1.05e-13) tmp = -2.0; elseif (z <= 8e-271) tmp = t_0; elseif (z <= 1.9e-199) tmp = Float64(4.0 * Float64(x / z)); elseif (z <= 7.5e+14) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (y / z) * -4.0; tmp = 0.0; if (z <= -1.05e-13) tmp = -2.0; elseif (z <= 8e-271) tmp = t_0; elseif (z <= 1.9e-199) tmp = 4.0 * (x / z); elseif (z <= 7.5e+14) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(y / z), $MachinePrecision] * -4.0), $MachinePrecision]}, If[LessEqual[z, -1.05e-13], -2.0, If[LessEqual[z, 8e-271], t$95$0, If[LessEqual[z, 1.9e-199], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 7.5e+14], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{y}{z} \cdot -4\\
\mathbf{if}\;z \leq -1.05 \cdot 10^{-13}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 8 \cdot 10^{-271}:\\
\;\;\;\;t_0\\
\mathbf{elif}\;z \leq 1.9 \cdot 10^{-199}:\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{elif}\;z \leq 7.5 \cdot 10^{+14}:\\
\;\;\;\;t_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.04999999999999994e-13 or 7.5e14 < z Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 62.3%
if -1.04999999999999994e-13 < z < 7.9999999999999997e-271 or 1.8999999999999999e-199 < z < 7.5e14Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 64.1%
if 7.9999999999999997e-271 < z < 1.8999999999999999e-199Initial program 99.9%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in x around inf 68.8%
Final simplification63.5%
(FPCore (x y z) :precision binary64 (if (<= x -1.3e+26) (/ 4.0 (/ z (- x y))) (if (<= x 8.4e-5) (* 4.0 (/ (- (* z -0.5) y) z)) (* (- x y) (/ 4.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.3e+26) {
tmp = 4.0 / (z / (x - y));
} else if (x <= 8.4e-5) {
tmp = 4.0 * (((z * -0.5) - y) / z);
} else {
tmp = (x - y) * (4.0 / 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.3d+26)) then
tmp = 4.0d0 / (z / (x - y))
else if (x <= 8.4d-5) then
tmp = 4.0d0 * (((z * (-0.5d0)) - y) / z)
else
tmp = (x - y) * (4.0d0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.3e+26) {
tmp = 4.0 / (z / (x - y));
} else if (x <= 8.4e-5) {
tmp = 4.0 * (((z * -0.5) - y) / z);
} else {
tmp = (x - y) * (4.0 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.3e+26: tmp = 4.0 / (z / (x - y)) elif x <= 8.4e-5: tmp = 4.0 * (((z * -0.5) - y) / z) else: tmp = (x - y) * (4.0 / z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.3e+26) tmp = Float64(4.0 / Float64(z / Float64(x - y))); elseif (x <= 8.4e-5) tmp = Float64(4.0 * Float64(Float64(Float64(z * -0.5) - y) / z)); else tmp = Float64(Float64(x - y) * Float64(4.0 / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.3e+26) tmp = 4.0 / (z / (x - y)); elseif (x <= 8.4e-5) tmp = 4.0 * (((z * -0.5) - y) / z); else tmp = (x - y) * (4.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.3e+26], N[(4.0 / N[(z / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 8.4e-5], N[(4.0 * N[(N[(N[(z * -0.5), $MachinePrecision] - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.3 \cdot 10^{+26}:\\
\;\;\;\;\frac{4}{\frac{z}{x - y}}\\
\mathbf{elif}\;x \leq 8.4 \cdot 10^{-5}:\\
\;\;\;\;4 \cdot \frac{z \cdot -0.5 - y}{z}\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\end{array}
\end{array}
if x < -1.30000000000000001e26Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 84.3%
associate-*r/84.3%
associate-*l/84.1%
*-commutative84.1%
Simplified84.1%
associate-*r/84.3%
*-commutative84.3%
associate-/l*84.3%
Applied egg-rr84.3%
if -1.30000000000000001e26 < x < 8.39999999999999954e-5Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 92.7%
*-commutative92.7%
Simplified92.7%
if 8.39999999999999954e-5 < x Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 89.1%
associate-*r/89.1%
associate-*l/88.9%
*-commutative88.9%
Simplified88.9%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -1e+115) (not (<= x 1.85e+179))) (* 4.0 (/ x z)) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1e+115) || !(x <= 1.85e+179)) {
tmp = 4.0 * (x / z);
} else {
tmp = 4.0 * (-0.5 - (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 <= (-1d+115)) .or. (.not. (x <= 1.85d+179))) then
tmp = 4.0d0 * (x / z)
else
tmp = 4.0d0 * ((-0.5d0) - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1e+115) || !(x <= 1.85e+179)) {
tmp = 4.0 * (x / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1e+115) or not (x <= 1.85e+179): tmp = 4.0 * (x / z) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1e+115) || !(x <= 1.85e+179)) tmp = Float64(4.0 * Float64(x / z)); else tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1e+115) || ~((x <= 1.85e+179))) tmp = 4.0 * (x / z); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1e+115], N[Not[LessEqual[x, 1.85e+179]], $MachinePrecision]], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1 \cdot 10^{+115} \lor \neg \left(x \leq 1.85 \cdot 10^{+179}\right):\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -1e115 or 1.85e179 < x Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around inf 88.1%
if -1e115 < x < 1.85e179Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 84.5%
div-sub84.5%
associate-/l*84.5%
*-inverses84.5%
metadata-eval84.5%
Simplified84.5%
Final simplification85.3%
(FPCore (x y z) :precision binary64 (if (or (<= x -5e+25) (not (<= x 7.6e-9))) (* (- x y) (/ 4.0 z)) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+25) || !(x <= 7.6e-9)) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = 4.0 * (-0.5 - (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 <= (-5d+25)) .or. (.not. (x <= 7.6d-9))) then
tmp = (x - y) * (4.0d0 / z)
else
tmp = 4.0d0 * ((-0.5d0) - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -5e+25) || !(x <= 7.6e-9)) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -5e+25) or not (x <= 7.6e-9): tmp = (x - y) * (4.0 / z) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -5e+25) || !(x <= 7.6e-9)) tmp = Float64(Float64(x - y) * Float64(4.0 / z)); else tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -5e+25) || ~((x <= 7.6e-9))) tmp = (x - y) * (4.0 / z); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -5e+25], N[Not[LessEqual[x, 7.6e-9]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -5 \cdot 10^{+25} \lor \neg \left(x \leq 7.6 \cdot 10^{-9}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -5.00000000000000024e25 or 7.60000000000000023e-9 < x Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 86.8%
associate-*r/86.8%
associate-*l/86.6%
*-commutative86.6%
Simplified86.6%
if -5.00000000000000024e25 < x < 7.60000000000000023e-9Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 92.7%
div-sub92.7%
associate-/l*92.7%
*-inverses92.7%
metadata-eval92.7%
Simplified92.7%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (<= x -1.52e+26) (/ 4.0 (/ z (- x y))) (if (<= x 7.1e-16) (* 4.0 (- -0.5 (/ y z))) (* (- x y) (/ 4.0 z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -1.52e+26) {
tmp = 4.0 / (z / (x - y));
} else if (x <= 7.1e-16) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = (x - y) * (4.0 / 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.52d+26)) then
tmp = 4.0d0 / (z / (x - y))
else if (x <= 7.1d-16) then
tmp = 4.0d0 * ((-0.5d0) - (y / z))
else
tmp = (x - y) * (4.0d0 / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -1.52e+26) {
tmp = 4.0 / (z / (x - y));
} else if (x <= 7.1e-16) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = (x - y) * (4.0 / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -1.52e+26: tmp = 4.0 / (z / (x - y)) elif x <= 7.1e-16: tmp = 4.0 * (-0.5 - (y / z)) else: tmp = (x - y) * (4.0 / z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -1.52e+26) tmp = Float64(4.0 / Float64(z / Float64(x - y))); elseif (x <= 7.1e-16) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); else tmp = Float64(Float64(x - y) * Float64(4.0 / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -1.52e+26) tmp = 4.0 / (z / (x - y)); elseif (x <= 7.1e-16) tmp = 4.0 * (-0.5 - (y / z)); else tmp = (x - y) * (4.0 / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -1.52e+26], N[(4.0 / N[(z / N[(x - y), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.1e-16], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.52 \cdot 10^{+26}:\\
\;\;\;\;\frac{4}{\frac{z}{x - y}}\\
\mathbf{elif}\;x \leq 7.1 \cdot 10^{-16}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\end{array}
\end{array}
if x < -1.52e26Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around 0 84.3%
associate-*r/84.3%
associate-*l/84.1%
*-commutative84.1%
Simplified84.1%
associate-*r/84.3%
*-commutative84.3%
associate-/l*84.3%
Applied egg-rr84.3%
if -1.52e26 < x < 7.1e-16Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in x around 0 92.7%
div-sub92.7%
associate-/l*92.7%
*-inverses92.7%
metadata-eval92.7%
Simplified92.7%
if 7.1e-16 < x Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in z around 0 89.1%
associate-*r/89.1%
associate-*l/88.9%
*-commutative88.9%
Simplified88.9%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (<= z -1e-12) -2.0 (if (<= z 65000000000000.0) (* (/ y z) -4.0) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1e-12) {
tmp = -2.0;
} else if (z <= 65000000000000.0) {
tmp = (y / z) * -4.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) :: tmp
if (z <= (-1d-12)) then
tmp = -2.0d0
else if (z <= 65000000000000.0d0) then
tmp = (y / z) * (-4.0d0)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (z <= -1e-12) {
tmp = -2.0;
} else if (z <= 65000000000000.0) {
tmp = (y / z) * -4.0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1e-12: tmp = -2.0 elif z <= 65000000000000.0: tmp = (y / z) * -4.0 else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1e-12) tmp = -2.0; elseif (z <= 65000000000000.0) tmp = Float64(Float64(y / z) * -4.0); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -1e-12) tmp = -2.0; elseif (z <= 65000000000000.0) tmp = (y / z) * -4.0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1e-12], -2.0, If[LessEqual[z, 65000000000000.0], N[(N[(y / z), $MachinePrecision] * -4.0), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1 \cdot 10^{-12}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 65000000000000:\\
\;\;\;\;\frac{y}{z} \cdot -4\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -9.9999999999999998e-13 or 6.5e13 < z Initial program 100.0%
associate-*l/99.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 62.3%
if -9.9999999999999998e-13 < z < 6.5e13Initial program 100.0%
associate-*l/99.8%
sub-neg99.8%
distribute-rgt-neg-in99.8%
metadata-eval99.8%
Simplified99.8%
Taylor expanded in y around inf 61.3%
Final simplification61.8%
(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.7%
sub-neg99.7%
distribute-rgt-neg-in99.7%
metadata-eval99.7%
Simplified99.7%
Taylor expanded in z around inf 33.0%
Final simplification33.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 2023312
(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))