
(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 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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ y z))) (t_1 (* (/ x z) 4.0)))
(if (<= y -1.6e+70)
t_0
(if (<= y -2.15e-152)
t_1
(if (<= y 1.14e-215)
-2.0
(if (<= y 1.4e-91)
t_1
(if (<= y 2.35e-42) -2.0 (if (<= y 0.00035) t_1 t_0))))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double t_1 = (x / z) * 4.0;
double tmp;
if (y <= -1.6e+70) {
tmp = t_0;
} else if (y <= -2.15e-152) {
tmp = t_1;
} else if (y <= 1.14e-215) {
tmp = -2.0;
} else if (y <= 1.4e-91) {
tmp = t_1;
} else if (y <= 2.35e-42) {
tmp = -2.0;
} else if (y <= 0.00035) {
tmp = t_1;
} 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) * (y / z)
t_1 = (x / z) * 4.0d0
if (y <= (-1.6d+70)) then
tmp = t_0
else if (y <= (-2.15d-152)) then
tmp = t_1
else if (y <= 1.14d-215) then
tmp = -2.0d0
else if (y <= 1.4d-91) then
tmp = t_1
else if (y <= 2.35d-42) then
tmp = -2.0d0
else if (y <= 0.00035d0) then
tmp = t_1
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 * (y / z);
double t_1 = (x / z) * 4.0;
double tmp;
if (y <= -1.6e+70) {
tmp = t_0;
} else if (y <= -2.15e-152) {
tmp = t_1;
} else if (y <= 1.14e-215) {
tmp = -2.0;
} else if (y <= 1.4e-91) {
tmp = t_1;
} else if (y <= 2.35e-42) {
tmp = -2.0;
} else if (y <= 0.00035) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) t_1 = (x / z) * 4.0 tmp = 0 if y <= -1.6e+70: tmp = t_0 elif y <= -2.15e-152: tmp = t_1 elif y <= 1.14e-215: tmp = -2.0 elif y <= 1.4e-91: tmp = t_1 elif y <= 2.35e-42: tmp = -2.0 elif y <= 0.00035: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) t_1 = Float64(Float64(x / z) * 4.0) tmp = 0.0 if (y <= -1.6e+70) tmp = t_0; elseif (y <= -2.15e-152) tmp = t_1; elseif (y <= 1.14e-215) tmp = -2.0; elseif (y <= 1.4e-91) tmp = t_1; elseif (y <= 2.35e-42) tmp = -2.0; elseif (y <= 0.00035) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); t_1 = (x / z) * 4.0; tmp = 0.0; if (y <= -1.6e+70) tmp = t_0; elseif (y <= -2.15e-152) tmp = t_1; elseif (y <= 1.14e-215) tmp = -2.0; elseif (y <= 1.4e-91) tmp = t_1; elseif (y <= 2.35e-42) tmp = -2.0; elseif (y <= 0.00035) tmp = t_1; else tmp = t_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[(N[(x / z), $MachinePrecision] * 4.0), $MachinePrecision]}, If[LessEqual[y, -1.6e+70], t$95$0, If[LessEqual[y, -2.15e-152], t$95$1, If[LessEqual[y, 1.14e-215], -2.0, If[LessEqual[y, 1.4e-91], t$95$1, If[LessEqual[y, 2.35e-42], -2.0, If[LessEqual[y, 0.00035], t$95$1, t$95$0]]]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
t_1 := \frac{x}{z} \cdot 4\\
\mathbf{if}\;y \leq -1.6 \cdot 10^{+70}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -2.15 \cdot 10^{-152}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.14 \cdot 10^{-215}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 1.4 \cdot 10^{-91}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 2.35 \cdot 10^{-42}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 0.00035:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.6000000000000001e70 or 3.49999999999999996e-4 < y Initial 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 inf 68.6%
*-commutative68.6%
Simplified68.6%
if -1.6000000000000001e70 < y < -2.1499999999999999e-152 or 1.14000000000000001e-215 < y < 1.4e-91 or 2.35e-42 < y < 3.49999999999999996e-4Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
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 x around inf 57.4%
*-commutative57.4%
Simplified57.4%
if -2.1499999999999999e-152 < y < 1.14000000000000001e-215 or 1.4e-91 < y < 2.35e-42Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
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 z around inf 62.6%
Final simplification63.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -2.1e+62) (not (<= x 0.00065))) (* -4.0 (/ (- y x) z)) (* -4.0 (- (/ y z) -0.5))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -2.1e+62) || !(x <= 0.00065)) {
tmp = -4.0 * ((y - x) / z);
} else {
tmp = -4.0 * ((y / z) - -0.5);
}
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 <= (-2.1d+62)) .or. (.not. (x <= 0.00065d0))) then
tmp = (-4.0d0) * ((y - x) / z)
else
tmp = (-4.0d0) * ((y / z) - (-0.5d0))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -2.1e+62) || !(x <= 0.00065)) {
tmp = -4.0 * ((y - x) / z);
} else {
tmp = -4.0 * ((y / z) - -0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -2.1e+62) or not (x <= 0.00065): tmp = -4.0 * ((y - x) / z) else: tmp = -4.0 * ((y / z) - -0.5) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -2.1e+62) || !(x <= 0.00065)) tmp = Float64(-4.0 * Float64(Float64(y - x) / z)); else tmp = Float64(-4.0 * Float64(Float64(y / z) - -0.5)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -2.1e+62) || ~((x <= 0.00065))) tmp = -4.0 * ((y - x) / z); else tmp = -4.0 * ((y / z) - -0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -2.1e+62], N[Not[LessEqual[x, 0.00065]], $MachinePrecision]], N[(-4.0 * N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(y / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -2.1 \cdot 10^{+62} \lor \neg \left(x \leq 0.00065\right):\\
\;\;\;\;-4 \cdot \frac{y - x}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(\frac{y}{z} - -0.5\right)\\
\end{array}
\end{array}
if x < -2.1e62 or 6.4999999999999997e-4 < x Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
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 z around 0 86.3%
if -2.1e62 < x < 6.4999999999999997e-4Initial 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 inf 93.2%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.45e+74) (not (<= y 3.65e+102))) (* -4.0 (- (/ y z) -0.5)) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.45e+74) || !(y <= 3.65e+102)) {
tmp = -4.0 * ((y / z) - -0.5);
} 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 <= (-1.45d+74)) .or. (.not. (y <= 3.65d+102))) then
tmp = (-4.0d0) * ((y / z) - (-0.5d0))
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 <= -1.45e+74) || !(y <= 3.65e+102)) {
tmp = -4.0 * ((y / z) - -0.5);
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.45e+74) or not (y <= 3.65e+102): tmp = -4.0 * ((y / z) - -0.5) else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.45e+74) || !(y <= 3.65e+102)) tmp = Float64(-4.0 * Float64(Float64(y / z) - -0.5)); 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 <= -1.45e+74) || ~((y <= 3.65e+102))) tmp = -4.0 * ((y / z) - -0.5); else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.45e+74], N[Not[LessEqual[y, 3.65e+102]], $MachinePrecision]], N[(-4.0 * N[(N[(y / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.45 \cdot 10^{+74} \lor \neg \left(y \leq 3.65 \cdot 10^{+102}\right):\\
\;\;\;\;-4 \cdot \left(\frac{y}{z} - -0.5\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1.4500000000000001e74 or 3.64999999999999995e102 < y Initial 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 inf 90.9%
if -1.4500000000000001e74 < y < 3.64999999999999995e102Initial 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 89.7%
Final simplification90.2%
(FPCore (x y z) :precision binary64 (if (or (<= y -6.5e+92) (not (<= y 2.75e+160))) (* -4.0 (/ y z)) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -6.5e+92) || !(y <= 2.75e+160)) {
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 <= (-6.5d+92)) .or. (.not. (y <= 2.75d+160))) 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 <= -6.5e+92) || !(y <= 2.75e+160)) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -6.5e+92) or not (y <= 2.75e+160): 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 <= -6.5e+92) || !(y <= 2.75e+160)) 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 <= -6.5e+92) || ~((y <= 2.75e+160))) 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, -6.5e+92], N[Not[LessEqual[y, 2.75e+160]], $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 -6.5 \cdot 10^{+92} \lor \neg \left(y \leq 2.75 \cdot 10^{+160}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -6.49999999999999999e92 or 2.75e160 < y Initial 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 inf 83.4%
*-commutative83.4%
Simplified83.4%
if -6.49999999999999999e92 < y < 2.75e160Initial 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 87.2%
Final simplification86.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -8.4e+64) (not (<= x 3.6e-5))) (* (/ x z) 4.0) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -8.4e+64) || !(x <= 3.6e-5)) {
tmp = (x / 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 ((x <= (-8.4d+64)) .or. (.not. (x <= 3.6d-5))) then
tmp = (x / 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 ((x <= -8.4e+64) || !(x <= 3.6e-5)) {
tmp = (x / z) * 4.0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -8.4e+64) or not (x <= 3.6e-5): tmp = (x / z) * 4.0 else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -8.4e+64) || !(x <= 3.6e-5)) tmp = Float64(Float64(x / z) * 4.0); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -8.4e+64) || ~((x <= 3.6e-5))) tmp = (x / z) * 4.0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -8.4e+64], N[Not[LessEqual[x, 3.6e-5]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] * 4.0), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -8.4 \cdot 10^{+64} \lor \neg \left(x \leq 3.6 \cdot 10^{-5}\right):\\
\;\;\;\;\frac{x}{z} \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if x < -8.4000000000000001e64 or 3.60000000000000009e-5 < x Initial program 99.9%
remove-double-neg99.9%
neg-mul-199.9%
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 x around inf 68.2%
*-commutative68.2%
Simplified68.2%
if -8.4000000000000001e64 < x < 3.60000000000000009e-5Initial 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 z around inf 50.4%
Final simplification58.0%
(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%
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 z around inf 34.5%
(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 2024111
(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))