
(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 9 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 (- (/ (- y x) z) -0.5)))
double code(double x, double y, double z) {
return -4.0 * (((y - x) / 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) * (((y - x) / z) - (-0.5d0))
end function
public static double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
def code(x, y, z): return -4.0 * (((y - x) / z) - -0.5)
function code(x, y, z) return Float64(-4.0 * Float64(Float64(Float64(y - x) / z) - -0.5)) end
function tmp = code(x, y, z) tmp = -4.0 * (((y - x) / z) - -0.5); end
code[x_, y_, z_] := N[(-4.0 * N[(N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \left(\frac{y - x}{z} - -0.5\right)
\end{array}
Initial program 99.6%
remove-double-neg99.6%
neg-mul-199.6%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))))
(if (<= x -1.55e-22)
t_0
(if (<= x 1.15e+66) (* -4.0 (/ y z)) (if (<= x 7.8e+180) -2.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double tmp;
if (x <= -1.55e-22) {
tmp = t_0;
} else if (x <= 1.15e+66) {
tmp = -4.0 * (y / z);
} else if (x <= 7.8e+180) {
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) :: tmp
t_0 = 4.0d0 * (x / z)
if (x <= (-1.55d-22)) then
tmp = t_0
else if (x <= 1.15d+66) then
tmp = (-4.0d0) * (y / z)
else if (x <= 7.8d+180) 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 tmp;
if (x <= -1.55e-22) {
tmp = t_0;
} else if (x <= 1.15e+66) {
tmp = -4.0 * (y / z);
} else if (x <= 7.8e+180) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) tmp = 0 if x <= -1.55e-22: tmp = t_0 elif x <= 1.15e+66: tmp = -4.0 * (y / z) elif x <= 7.8e+180: tmp = -2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) tmp = 0.0 if (x <= -1.55e-22) tmp = t_0; elseif (x <= 1.15e+66) tmp = Float64(-4.0 * Float64(y / z)); elseif (x <= 7.8e+180) tmp = -2.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / z); tmp = 0.0; if (x <= -1.55e-22) tmp = t_0; elseif (x <= 1.15e+66) tmp = -4.0 * (y / z); elseif (x <= 7.8e+180) 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]}, If[LessEqual[x, -1.55e-22], t$95$0, If[LessEqual[x, 1.15e+66], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.8e+180], -2.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
\mathbf{if}\;x \leq -1.55 \cdot 10^{-22}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.15 \cdot 10^{+66}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{+180}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -1.55000000000000006e-22 or 7.8000000000000002e180 < x Initial program 99.1%
*-commutative99.1%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around inf 73.5%
if -1.55000000000000006e-22 < x < 1.15e66Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in y around inf 54.3%
*-commutative54.3%
Simplified54.3%
if 1.15e66 < x < 7.8000000000000002e180Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 52.3%
Final simplification62.2%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* 4.0 (/ x z))))
(if (<= x -8.6e-30)
t_0
(if (<= x 7.3e+68) (* y (/ -4.0 z)) (if (<= x 7.8e+180) -2.0 t_0)))))
double code(double x, double y, double z) {
double t_0 = 4.0 * (x / z);
double tmp;
if (x <= -8.6e-30) {
tmp = t_0;
} else if (x <= 7.3e+68) {
tmp = y * (-4.0 / z);
} else if (x <= 7.8e+180) {
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) :: tmp
t_0 = 4.0d0 * (x / z)
if (x <= (-8.6d-30)) then
tmp = t_0
else if (x <= 7.3d+68) then
tmp = y * ((-4.0d0) / z)
else if (x <= 7.8d+180) 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 tmp;
if (x <= -8.6e-30) {
tmp = t_0;
} else if (x <= 7.3e+68) {
tmp = y * (-4.0 / z);
} else if (x <= 7.8e+180) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = 4.0 * (x / z) tmp = 0 if x <= -8.6e-30: tmp = t_0 elif x <= 7.3e+68: tmp = y * (-4.0 / z) elif x <= 7.8e+180: tmp = -2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(4.0 * Float64(x / z)) tmp = 0.0 if (x <= -8.6e-30) tmp = t_0; elseif (x <= 7.3e+68) tmp = Float64(y * Float64(-4.0 / z)); elseif (x <= 7.8e+180) tmp = -2.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = 4.0 * (x / z); tmp = 0.0; if (x <= -8.6e-30) tmp = t_0; elseif (x <= 7.3e+68) tmp = y * (-4.0 / z); elseif (x <= 7.8e+180) 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]}, If[LessEqual[x, -8.6e-30], t$95$0, If[LessEqual[x, 7.3e+68], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 7.8e+180], -2.0, t$95$0]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := 4 \cdot \frac{x}{z}\\
\mathbf{if}\;x \leq -8.6 \cdot 10^{-30}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.3 \cdot 10^{+68}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{elif}\;x \leq 7.8 \cdot 10^{+180}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -8.59999999999999932e-30 or 7.8000000000000002e180 < x Initial program 99.1%
*-commutative99.1%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around inf 73.5%
if -8.59999999999999932e-30 < x < 7.30000000000000034e68Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in y around inf 54.3%
associate-*r/54.3%
*-commutative54.3%
associate-*r/54.2%
Simplified54.2%
if 7.30000000000000034e68 < x < 7.8000000000000002e180Initial program 99.9%
*-commutative99.9%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 52.3%
(FPCore (x y z) :precision binary64 (if (<= y -2.7e+80) (* 4.0 (- -0.5 (/ y z))) (if (<= y 1.35e+52) (* -4.0 (- (- -0.5) (/ x z))) (* 4.0 (/ (- x y) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -2.7e+80) {
tmp = 4.0 * (-0.5 - (y / z));
} else if (y <= 1.35e+52) {
tmp = -4.0 * (-(-0.5) - (x / z));
} 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 (y <= (-2.7d+80)) then
tmp = 4.0d0 * ((-0.5d0) - (y / z))
else if (y <= 1.35d+52) then
tmp = (-4.0d0) * (-(-0.5d0) - (x / z))
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 (y <= -2.7e+80) {
tmp = 4.0 * (-0.5 - (y / z));
} else if (y <= 1.35e+52) {
tmp = -4.0 * (-(-0.5) - (x / z));
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -2.7e+80: tmp = 4.0 * (-0.5 - (y / z)) elif y <= 1.35e+52: tmp = -4.0 * (-(-0.5) - (x / z)) else: tmp = 4.0 * ((x - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -2.7e+80) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); elseif (y <= 1.35e+52) tmp = Float64(-4.0 * Float64(Float64(-(-0.5)) - Float64(x / z))); 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 (y <= -2.7e+80) tmp = 4.0 * (-0.5 - (y / z)); elseif (y <= 1.35e+52) tmp = -4.0 * (-(-0.5) - (x / z)); else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -2.7e+80], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 1.35e+52], N[(-4.0 * N[((--0.5) - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -2.7 \cdot 10^{+80}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{elif}\;y \leq 1.35 \cdot 10^{+52}:\\
\;\;\;\;-4 \cdot \left(\left(--0.5\right) - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if y < -2.69999999999999983e80Initial program 99.9%
*-commutative99.9%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around 0 92.7%
associate-*r/92.7%
metadata-eval92.7%
+-commutative92.7%
*-commutative92.7%
fma-undefine92.7%
associate-*r*92.7%
neg-mul-192.7%
associate-/l*92.7%
fma-undefine92.7%
*-commutative92.7%
distribute-neg-in92.7%
sub-neg92.7%
div-sub92.8%
distribute-neg-frac92.8%
associate-/l*92.8%
*-inverses92.8%
metadata-eval92.8%
metadata-eval92.8%
Simplified92.8%
if -2.69999999999999983e80 < y < 1.35e52Initial program 99.3%
remove-double-neg99.3%
neg-mul-199.3%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around 0 92.7%
neg-mul-192.7%
distribute-neg-frac92.7%
Simplified92.7%
if 1.35e52 < y Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 88.4%
Final simplification91.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -2.2e+139) (not (<= z 3.7e+79))) (* 4.0 (- -0.5 (/ y z))) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -2.2e+139) || !(z <= 3.7e+79)) {
tmp = 4.0 * (-0.5 - (y / z));
} 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.2d+139)) .or. (.not. (z <= 3.7d+79))) then
tmp = 4.0d0 * ((-0.5d0) - (y / z))
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.2e+139) || !(z <= 3.7e+79)) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -2.2e+139) or not (z <= 3.7e+79): tmp = 4.0 * (-0.5 - (y / z)) else: tmp = 4.0 * ((x - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if ((z <= -2.2e+139) || !(z <= 3.7e+79)) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); 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.2e+139) || ~((z <= 3.7e+79))) tmp = 4.0 * (-0.5 - (y / z)); else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -2.2e+139], N[Not[LessEqual[z, 3.7e+79]], $MachinePrecision]], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{+139} \lor \neg \left(z \leq 3.7 \cdot 10^{+79}\right):\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -2.1999999999999999e139 or 3.70000000000000009e79 < z Initial program 98.8%
*-commutative98.8%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around 0 85.8%
associate-*r/85.8%
metadata-eval85.8%
+-commutative85.8%
*-commutative85.8%
fma-undefine85.8%
associate-*r*85.8%
neg-mul-185.8%
associate-/l*85.8%
fma-undefine85.8%
*-commutative85.8%
distribute-neg-in85.8%
sub-neg85.8%
div-sub85.9%
distribute-neg-frac85.9%
associate-/l*85.9%
*-inverses85.9%
metadata-eval85.9%
metadata-eval85.9%
Simplified85.9%
if -2.1999999999999999e139 < z < 3.70000000000000009e79Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 89.8%
Final simplification88.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -6500000.0) (not (<= x 7.8e+180))) (* 4.0 (/ x z)) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -6500000.0) || !(x <= 7.8e+180)) {
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 <= (-6500000.0d0)) .or. (.not. (x <= 7.8d+180))) 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 <= -6500000.0) || !(x <= 7.8e+180)) {
tmp = 4.0 * (x / z);
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -6500000.0) or not (x <= 7.8e+180): 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 <= -6500000.0) || !(x <= 7.8e+180)) 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 <= -6500000.0) || ~((x <= 7.8e+180))) 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, -6500000.0], N[Not[LessEqual[x, 7.8e+180]], $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 -6500000 \lor \neg \left(x \leq 7.8 \cdot 10^{+180}\right):\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -6.5e6 or 7.8000000000000002e180 < x Initial program 99.0%
*-commutative99.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around inf 76.7%
if -6.5e6 < x < 7.8000000000000002e180Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around 0 87.0%
associate-*r/87.0%
metadata-eval87.0%
+-commutative87.0%
*-commutative87.0%
fma-undefine87.0%
associate-*r*87.0%
neg-mul-187.0%
associate-/l*87.0%
fma-undefine87.0%
*-commutative87.0%
distribute-neg-in87.0%
sub-neg87.0%
div-sub87.0%
distribute-neg-frac87.0%
associate-/l*87.0%
*-inverses87.0%
metadata-eval87.0%
metadata-eval87.0%
Simplified87.0%
Final simplification83.0%
(FPCore (x y z) :precision binary64 (if (<= y -5.5e+81) (* 4.0 (- -0.5 (/ y z))) (if (<= y 3e+52) (+ (/ (* x 4.0) z) -2.0) (* 4.0 (/ (- x y) z)))))
double code(double x, double y, double z) {
double tmp;
if (y <= -5.5e+81) {
tmp = 4.0 * (-0.5 - (y / z));
} else if (y <= 3e+52) {
tmp = ((x * 4.0) / 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 (y <= (-5.5d+81)) then
tmp = 4.0d0 * ((-0.5d0) - (y / z))
else if (y <= 3d+52) then
tmp = ((x * 4.0d0) / 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 (y <= -5.5e+81) {
tmp = 4.0 * (-0.5 - (y / z));
} else if (y <= 3e+52) {
tmp = ((x * 4.0) / z) + -2.0;
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -5.5e+81: tmp = 4.0 * (-0.5 - (y / z)) elif y <= 3e+52: tmp = ((x * 4.0) / z) + -2.0 else: tmp = 4.0 * ((x - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -5.5e+81) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); elseif (y <= 3e+52) tmp = Float64(Float64(Float64(x * 4.0) / 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 (y <= -5.5e+81) tmp = 4.0 * (-0.5 - (y / z)); elseif (y <= 3e+52) tmp = ((x * 4.0) / z) + -2.0; else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -5.5e+81], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 3e+52], N[(N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision] + -2.0), $MachinePrecision], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -5.5 \cdot 10^{+81}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{elif}\;y \leq 3 \cdot 10^{+52}:\\
\;\;\;\;\frac{x \cdot 4}{z} + -2\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if y < -5.5000000000000003e81Initial program 99.9%
*-commutative99.9%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around 0 92.7%
associate-*r/92.7%
metadata-eval92.7%
+-commutative92.7%
*-commutative92.7%
fma-undefine92.7%
associate-*r*92.7%
neg-mul-192.7%
associate-/l*92.7%
fma-undefine92.7%
*-commutative92.7%
distribute-neg-in92.7%
sub-neg92.7%
div-sub92.8%
distribute-neg-frac92.8%
associate-/l*92.8%
*-inverses92.8%
metadata-eval92.8%
metadata-eval92.8%
Simplified92.8%
if -5.5000000000000003e81 < y < 3e52Initial program 99.3%
*-commutative99.3%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in y around inf 84.0%
sub-neg84.0%
metadata-eval84.0%
associate-*r/84.0%
metadata-eval84.0%
Simplified84.0%
Taylor expanded in y around 0 92.7%
sub-neg92.7%
metadata-eval92.7%
distribute-lft-in92.7%
associate-*r/92.1%
metadata-eval92.1%
Simplified92.1%
if 3e52 < y Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 88.4%
Final simplification91.4%
(FPCore (x y z) :precision binary64 (if (<= z -2.2e+138) -2.0 (if (<= z 9e+79) (* 4.0 (/ x z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -2.2e+138) {
tmp = -2.0;
} else if (z <= 9e+79) {
tmp = 4.0 * (x / 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.2d+138)) then
tmp = -2.0d0
else if (z <= 9d+79) then
tmp = 4.0d0 * (x / 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.2e+138) {
tmp = -2.0;
} else if (z <= 9e+79) {
tmp = 4.0 * (x / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -2.2e+138: tmp = -2.0 elif z <= 9e+79: tmp = 4.0 * (x / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -2.2e+138) tmp = -2.0; elseif (z <= 9e+79) tmp = Float64(4.0 * Float64(x / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -2.2e+138) tmp = -2.0; elseif (z <= 9e+79) tmp = 4.0 * (x / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -2.2e+138], -2.0, If[LessEqual[z, 9e+79], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -2.2 \cdot 10^{+138}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 9 \cdot 10^{+79}:\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -2.2000000000000001e138 or 8.99999999999999987e79 < z Initial program 98.8%
*-commutative98.8%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 70.0%
if -2.2000000000000001e138 < z < 8.99999999999999987e79Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around inf 50.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%
*-commutative99.6%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around inf 30.8%
(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 2024106
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:alt
(- (* 4.0 (/ x z)) (+ 2.0 (* 4.0 (/ y z))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))