
(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 7 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 (/ y z))) (t_1 (* 4.0 (/ x z))))
(if (<= z -1.2e+77)
-2.0
(if (<= z -1.1e-50)
t_1
(if (<= z -9e-110)
t_0
(if (<= z -5.8e-128)
t_1
(if (<= z 3.5e-212) t_0 (if (<= z 1.15e+78) t_1 -2.0))))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double t_1 = 4.0 * (x / z);
double tmp;
if (z <= -1.2e+77) {
tmp = -2.0;
} else if (z <= -1.1e-50) {
tmp = t_1;
} else if (z <= -9e-110) {
tmp = t_0;
} else if (z <= -5.8e-128) {
tmp = t_1;
} else if (z <= 3.5e-212) {
tmp = t_0;
} else if (z <= 1.15e+78) {
tmp = t_1;
} 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) * (y / z)
t_1 = 4.0d0 * (x / z)
if (z <= (-1.2d+77)) then
tmp = -2.0d0
else if (z <= (-1.1d-50)) then
tmp = t_1
else if (z <= (-9d-110)) then
tmp = t_0
else if (z <= (-5.8d-128)) then
tmp = t_1
else if (z <= 3.5d-212) then
tmp = t_0
else if (z <= 1.15d+78) then
tmp = t_1
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 * (y / z);
double t_1 = 4.0 * (x / z);
double tmp;
if (z <= -1.2e+77) {
tmp = -2.0;
} else if (z <= -1.1e-50) {
tmp = t_1;
} else if (z <= -9e-110) {
tmp = t_0;
} else if (z <= -5.8e-128) {
tmp = t_1;
} else if (z <= 3.5e-212) {
tmp = t_0;
} else if (z <= 1.15e+78) {
tmp = t_1;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) t_1 = 4.0 * (x / z) tmp = 0 if z <= -1.2e+77: tmp = -2.0 elif z <= -1.1e-50: tmp = t_1 elif z <= -9e-110: tmp = t_0 elif z <= -5.8e-128: tmp = t_1 elif z <= 3.5e-212: tmp = t_0 elif z <= 1.15e+78: tmp = t_1 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) t_1 = Float64(4.0 * Float64(x / z)) tmp = 0.0 if (z <= -1.2e+77) tmp = -2.0; elseif (z <= -1.1e-50) tmp = t_1; elseif (z <= -9e-110) tmp = t_0; elseif (z <= -5.8e-128) tmp = t_1; elseif (z <= 3.5e-212) tmp = t_0; elseif (z <= 1.15e+78) tmp = t_1; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); t_1 = 4.0 * (x / z); tmp = 0.0; if (z <= -1.2e+77) tmp = -2.0; elseif (z <= -1.1e-50) tmp = t_1; elseif (z <= -9e-110) tmp = t_0; elseif (z <= -5.8e-128) tmp = t_1; elseif (z <= 3.5e-212) tmp = t_0; elseif (z <= 1.15e+78) tmp = t_1; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.2e+77], -2.0, If[LessEqual[z, -1.1e-50], t$95$1, If[LessEqual[z, -9e-110], t$95$0, If[LessEqual[z, -5.8e-128], t$95$1, If[LessEqual[z, 3.5e-212], t$95$0, If[LessEqual[z, 1.15e+78], t$95$1, -2.0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
t_1 := 4 \cdot \frac{x}{z}\\
\mathbf{if}\;z \leq -1.2 \cdot 10^{+77}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -1.1 \cdot 10^{-50}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq -9 \cdot 10^{-110}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq -5.8 \cdot 10^{-128}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;z \leq 3.5 \cdot 10^{-212}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 1.15 \cdot 10^{+78}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.1999999999999999e77 or 1.1500000000000001e78 < z Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in z around inf 70.8%
if -1.1999999999999999e77 < z < -1.0999999999999999e-50 or -9.0000000000000002e-110 < z < -5.8000000000000001e-128 or 3.4999999999999998e-212 < z < 1.1500000000000001e78Initial program 98.9%
*-commutative98.9%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 54.4%
if -1.0999999999999999e-50 < z < -9.0000000000000002e-110 or -5.8000000000000001e-128 < z < 3.4999999999999998e-212Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in y around inf 66.2%
*-commutative66.2%
Simplified66.2%
Final simplification64.0%
(FPCore (x y z)
:precision binary64
(if (or (<= y -3.8e+230)
(not
(or (<= y -1.2e+208) (and (not (<= y -1.25e+133)) (<= y 2.8e-8)))))
(* -4.0 (/ y z))
(* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.8e+230) || !((y <= -1.2e+208) || (!(y <= -1.25e+133) && (y <= 2.8e-8)))) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / 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 <= (-3.8d+230)) .or. (.not. (y <= (-1.2d+208)) .or. (.not. (y <= (-1.25d+133))) .and. (y <= 2.8d-8))) then
tmp = (-4.0d0) * (y / z)
else
tmp = (-4.0d0) * (0.5d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.8e+230) || !((y <= -1.2e+208) || (!(y <= -1.25e+133) && (y <= 2.8e-8)))) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.8e+230) or not ((y <= -1.2e+208) or (not (y <= -1.25e+133) and (y <= 2.8e-8))): tmp = -4.0 * (y / z) else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.8e+230) || !((y <= -1.2e+208) || (!(y <= -1.25e+133) && (y <= 2.8e-8)))) tmp = Float64(-4.0 * Float64(y / z)); else tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.8e+230) || ~(((y <= -1.2e+208) || (~((y <= -1.25e+133)) && (y <= 2.8e-8))))) tmp = -4.0 * (y / z); else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.8e+230], N[Not[Or[LessEqual[y, -1.2e+208], And[N[Not[LessEqual[y, -1.25e+133]], $MachinePrecision], LessEqual[y, 2.8e-8]]]], $MachinePrecision]], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{+230} \lor \neg \left(y \leq -1.2 \cdot 10^{+208} \lor \neg \left(y \leq -1.25 \cdot 10^{+133}\right) \land y \leq 2.8 \cdot 10^{-8}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -3.8e230 or -1.19999999999999993e208 < y < -1.2499999999999999e133 or 2.7999999999999999e-8 < y Initial program 99.0%
*-commutative99.0%
associate-/l*99.5%
associate--l-99.5%
Simplified99.5%
Taylor expanded in y around inf 73.4%
*-commutative73.4%
Simplified73.4%
if -3.8e230 < y < -1.19999999999999993e208 or -1.2499999999999999e133 < y < 2.7999999999999999e-8Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
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 88.0%
neg-mul-188.0%
distribute-neg-frac88.0%
Simplified88.0%
Taylor expanded in x around 0 88.0%
mul-1-neg88.0%
unsub-neg88.0%
Simplified88.0%
Final simplification82.8%
(FPCore (x y z) :precision binary64 (if (or (<= z -1e+74) (not (<= z 8.2e+80))) (* 4.0 (- -0.5 (/ y z))) (* 4.0 (/ (- x y) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -1e+74) || !(z <= 8.2e+80)) {
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 <= (-1d+74)) .or. (.not. (z <= 8.2d+80))) 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 <= -1e+74) || !(z <= 8.2e+80)) {
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 <= -1e+74) or not (z <= 8.2e+80): 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 <= -1e+74) || !(z <= 8.2e+80)) 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 <= -1e+74) || ~((z <= 8.2e+80))) 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, -1e+74], N[Not[LessEqual[z, 8.2e+80]], $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 -1 \cdot 10^{+74} \lor \neg \left(z \leq 8.2 \cdot 10^{+80}\right):\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if z < -9.99999999999999952e73 or 8.20000000000000003e80 < z Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around 0 88.5%
associate-*r/88.5%
metadata-eval88.5%
+-commutative88.5%
*-commutative88.5%
fma-undefine88.5%
associate-*r*88.5%
neg-mul-188.5%
associate-/l*88.5%
fma-undefine88.5%
*-commutative88.5%
distribute-neg-in88.5%
sub-neg88.5%
div-sub88.5%
distribute-neg-frac88.5%
associate-/l*88.5%
*-inverses88.5%
metadata-eval88.5%
metadata-eval88.5%
Simplified88.5%
if -9.99999999999999952e73 < z < 8.20000000000000003e80Initial program 99.4%
*-commutative99.4%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 90.6%
Final simplification89.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -4.4e+67) (not (<= x 0.017))) (* -4.0 (- 0.5 (/ x z))) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4.4e+67) || !(x <= 0.017)) {
tmp = -4.0 * (0.5 - (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 <= (-4.4d+67)) .or. (.not. (x <= 0.017d0))) then
tmp = (-4.0d0) * (0.5d0 - (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 <= -4.4e+67) || !(x <= 0.017)) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4.4e+67) or not (x <= 0.017): tmp = -4.0 * (0.5 - (x / z)) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4.4e+67) || !(x <= 0.017)) tmp = Float64(-4.0 * Float64(0.5 - 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 <= -4.4e+67) || ~((x <= 0.017))) tmp = -4.0 * (0.5 - (x / z)); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4.4e+67], N[Not[LessEqual[x, 0.017]], $MachinePrecision]], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.4 \cdot 10^{+67} \lor \neg \left(x \leq 0.017\right):\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -4.4e67 or 0.017000000000000001 < x Initial program 99.1%
remove-double-neg99.1%
neg-mul-199.1%
times-frac99.9%
metadata-eval99.9%
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 86.9%
neg-mul-186.9%
distribute-neg-frac86.9%
Simplified86.9%
Taylor expanded in x around 0 86.9%
mul-1-neg86.9%
unsub-neg86.9%
Simplified86.9%
if -4.4e67 < x < 0.017000000000000001Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around 0 90.5%
associate-*r/90.5%
metadata-eval90.5%
+-commutative90.5%
*-commutative90.5%
fma-undefine90.5%
associate-*r*90.5%
neg-mul-190.5%
associate-/l*90.5%
fma-undefine90.5%
*-commutative90.5%
distribute-neg-in90.5%
sub-neg90.5%
div-sub90.5%
distribute-neg-frac90.5%
associate-/l*90.5%
*-inverses90.5%
metadata-eval90.5%
metadata-eval90.5%
Simplified90.5%
Final simplification88.9%
(FPCore (x y z) :precision binary64 (if (<= z -1.35e+71) -2.0 (if (<= z 3.7e+80) (* 4.0 (/ x z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -1.35e+71) {
tmp = -2.0;
} else if (z <= 3.7e+80) {
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 <= (-1.35d+71)) then
tmp = -2.0d0
else if (z <= 3.7d+80) 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 <= -1.35e+71) {
tmp = -2.0;
} else if (z <= 3.7e+80) {
tmp = 4.0 * (x / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -1.35e+71: tmp = -2.0 elif z <= 3.7e+80: tmp = 4.0 * (x / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -1.35e+71) tmp = -2.0; elseif (z <= 3.7e+80) 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 <= -1.35e+71) tmp = -2.0; elseif (z <= 3.7e+80) tmp = 4.0 * (x / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -1.35e+71], -2.0, If[LessEqual[z, 3.7e+80], N[(4.0 * N[(x / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -1.35 \cdot 10^{+71}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 3.7 \cdot 10^{+80}:\\
\;\;\;\;4 \cdot \frac{x}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.34999999999999998e71 or 3.69999999999999996e80 < z Initial program 100.0%
*-commutative100.0%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in z around inf 70.8%
if -1.34999999999999998e71 < z < 3.69999999999999996e80Initial program 99.4%
*-commutative99.4%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 47.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 99.6%
*-commutative99.6%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 34.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 2024091
(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))