
(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 (- (/ (- 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%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 z))) (t_1 (* -4.0 (/ y z))))
(if (<= x -8.5e+78)
t_0
(if (<= x 1.36e-268)
t_1
(if (<= x 2.2e-170) -2.0 (if (<= x 9e+144) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -8.5e+78) {
tmp = t_0;
} else if (x <= 1.36e-268) {
tmp = t_1;
} else if (x <= 2.2e-170) {
tmp = -2.0;
} else if (x <= 9e+144) {
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 = x * (4.0d0 / z)
t_1 = (-4.0d0) * (y / z)
if (x <= (-8.5d+78)) then
tmp = t_0
else if (x <= 1.36d-268) then
tmp = t_1
else if (x <= 2.2d-170) then
tmp = -2.0d0
else if (x <= 9d+144) 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 = x * (4.0 / z);
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -8.5e+78) {
tmp = t_0;
} else if (x <= 1.36e-268) {
tmp = t_1;
} else if (x <= 2.2e-170) {
tmp = -2.0;
} else if (x <= 9e+144) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / z) t_1 = -4.0 * (y / z) tmp = 0 if x <= -8.5e+78: tmp = t_0 elif x <= 1.36e-268: tmp = t_1 elif x <= 2.2e-170: tmp = -2.0 elif x <= 9e+144: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(4.0 / z)) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (x <= -8.5e+78) tmp = t_0; elseif (x <= 1.36e-268) tmp = t_1; elseif (x <= 2.2e-170) tmp = -2.0; elseif (x <= 9e+144) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (4.0 / z); t_1 = -4.0 * (y / z); tmp = 0.0; if (x <= -8.5e+78) tmp = t_0; elseif (x <= 1.36e-268) tmp = t_1; elseif (x <= 2.2e-170) tmp = -2.0; elseif (x <= 9e+144) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -8.5e+78], t$95$0, If[LessEqual[x, 1.36e-268], t$95$1, If[LessEqual[x, 2.2e-170], -2.0, If[LessEqual[x, 9e+144], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -8.5 \cdot 10^{+78}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 1.36 \cdot 10^{-268}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 2.2 \cdot 10^{-170}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+144}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -8.50000000000000079e78 or 8.99999999999999935e144 < x Initial program 100.0%
Taylor expanded in x around inf 76.1%
*-commutative76.1%
associate-*l/76.1%
associate-*r/75.9%
Simplified75.9%
if -8.50000000000000079e78 < x < 1.3599999999999999e-268 or 2.20000000000000015e-170 < x < 8.99999999999999935e144Initial program 100.0%
Taylor expanded in y around inf 49.9%
*-commutative49.9%
Simplified49.9%
if 1.3599999999999999e-268 < x < 2.20000000000000015e-170Initial program 100.0%
Taylor expanded in z around inf 62.2%
Final simplification60.6%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x 4.0) z)) (t_1 (* -4.0 (/ y z))))
(if (<= x -5.5e+80)
t_0
(if (<= x 7.2e-269)
t_1
(if (<= x 7.2e-171) -2.0 (if (<= x 9e+144) t_1 t_0))))))
double code(double x, double y, double z) {
double t_0 = (x * 4.0) / z;
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -5.5e+80) {
tmp = t_0;
} else if (x <= 7.2e-269) {
tmp = t_1;
} else if (x <= 7.2e-171) {
tmp = -2.0;
} else if (x <= 9e+144) {
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 = (x * 4.0d0) / z
t_1 = (-4.0d0) * (y / z)
if (x <= (-5.5d+80)) then
tmp = t_0
else if (x <= 7.2d-269) then
tmp = t_1
else if (x <= 7.2d-171) then
tmp = -2.0d0
else if (x <= 9d+144) 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 = (x * 4.0) / z;
double t_1 = -4.0 * (y / z);
double tmp;
if (x <= -5.5e+80) {
tmp = t_0;
} else if (x <= 7.2e-269) {
tmp = t_1;
} else if (x <= 7.2e-171) {
tmp = -2.0;
} else if (x <= 9e+144) {
tmp = t_1;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * 4.0) / z t_1 = -4.0 * (y / z) tmp = 0 if x <= -5.5e+80: tmp = t_0 elif x <= 7.2e-269: tmp = t_1 elif x <= 7.2e-171: tmp = -2.0 elif x <= 9e+144: tmp = t_1 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * 4.0) / z) t_1 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (x <= -5.5e+80) tmp = t_0; elseif (x <= 7.2e-269) tmp = t_1; elseif (x <= 7.2e-171) tmp = -2.0; elseif (x <= 9e+144) tmp = t_1; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * 4.0) / z; t_1 = -4.0 * (y / z); tmp = 0.0; if (x <= -5.5e+80) tmp = t_0; elseif (x <= 7.2e-269) tmp = t_1; elseif (x <= 7.2e-171) tmp = -2.0; elseif (x <= 9e+144) tmp = t_1; else tmp = t_0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision]}, Block[{t$95$1 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[x, -5.5e+80], t$95$0, If[LessEqual[x, 7.2e-269], t$95$1, If[LessEqual[x, 7.2e-171], -2.0, If[LessEqual[x, 9e+144], t$95$1, t$95$0]]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot 4}{z}\\
t_1 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;x \leq -5.5 \cdot 10^{+80}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-269}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;x \leq 7.2 \cdot 10^{-171}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+144}:\\
\;\;\;\;t\_1\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -5.49999999999999967e80 or 8.99999999999999935e144 < x Initial program 100.0%
Taylor expanded in x around inf 76.1%
*-commutative76.1%
associate-*l/76.1%
Simplified76.1%
if -5.49999999999999967e80 < x < 7.19999999999999996e-269 or 7.20000000000000006e-171 < x < 8.99999999999999935e144Initial program 100.0%
Taylor expanded in y around inf 49.9%
*-commutative49.9%
Simplified49.9%
if 7.19999999999999996e-269 < x < 7.20000000000000006e-171Initial program 100.0%
Taylor expanded in z around inf 62.2%
Final simplification60.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -3e+97) (not (<= y 1.02e+105))) (* -4.0 (/ y z)) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3e+97) || !(y <= 1.02e+105)) {
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 <= (-3d+97)) .or. (.not. (y <= 1.02d+105))) 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 <= -3e+97) || !(y <= 1.02e+105)) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3e+97) or not (y <= 1.02e+105): 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 <= -3e+97) || !(y <= 1.02e+105)) 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 <= -3e+97) || ~((y <= 1.02e+105))) 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, -3e+97], N[Not[LessEqual[y, 1.02e+105]], $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 \cdot 10^{+97} \lor \neg \left(y \leq 1.02 \cdot 10^{+105}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -2.9999999999999998e97 or 1.02e105 < y Initial program 100.0%
Taylor expanded in y around inf 80.3%
*-commutative80.3%
Simplified80.3%
if -2.9999999999999998e97 < y < 1.02e105Initial 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 84.8%
Final simplification83.5%
(FPCore (x y z) :precision binary64 (if (or (<= x -4e+78) (not (<= x 9e+144))) (* -4.0 (- 0.5 (/ x z))) (* -4.0 (- (/ y z) -0.5))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4e+78) || !(x <= 9e+144)) {
tmp = -4.0 * (0.5 - (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 <= (-4d+78)) .or. (.not. (x <= 9d+144))) then
tmp = (-4.0d0) * (0.5d0 - (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 <= -4e+78) || !(x <= 9e+144)) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = -4.0 * ((y / z) - -0.5);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4e+78) or not (x <= 9e+144): tmp = -4.0 * (0.5 - (x / z)) else: tmp = -4.0 * ((y / z) - -0.5) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4e+78) || !(x <= 9e+144)) tmp = Float64(-4.0 * Float64(0.5 - Float64(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 <= -4e+78) || ~((x <= 9e+144))) tmp = -4.0 * (0.5 - (x / z)); else tmp = -4.0 * ((y / z) - -0.5); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4e+78], N[Not[LessEqual[x, 9e+144]], $MachinePrecision]], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(y / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4 \cdot 10^{+78} \lor \neg \left(x \leq 9 \cdot 10^{+144}\right):\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(\frac{y}{z} - -0.5\right)\\
\end{array}
\end{array}
if x < -4.00000000000000003e78 or 8.99999999999999935e144 < x 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 0 90.5%
if -4.00000000000000003e78 < x < 8.99999999999999935e144Initial 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 87.1%
Final simplification88.4%
(FPCore (x y z) :precision binary64 (if (<= x -3.3e+66) (/ (* 4.0 (- x y)) z) (if (<= x 9e+144) (* -4.0 (- (/ y z) -0.5)) (* -4.0 (- 0.5 (/ x z))))))
double code(double x, double y, double z) {
double tmp;
if (x <= -3.3e+66) {
tmp = (4.0 * (x - y)) / z;
} else if (x <= 9e+144) {
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 (x <= (-3.3d+66)) then
tmp = (4.0d0 * (x - y)) / z
else if (x <= 9d+144) 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 (x <= -3.3e+66) {
tmp = (4.0 * (x - y)) / z;
} else if (x <= 9e+144) {
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 x <= -3.3e+66: tmp = (4.0 * (x - y)) / z elif x <= 9e+144: 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 (x <= -3.3e+66) tmp = Float64(Float64(4.0 * Float64(x - y)) / z); elseif (x <= 9e+144) 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 (x <= -3.3e+66) tmp = (4.0 * (x - y)) / z; elseif (x <= 9e+144) 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[LessEqual[x, -3.3e+66], N[(N[(4.0 * N[(x - y), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[x, 9e+144], 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}\;x \leq -3.3 \cdot 10^{+66}:\\
\;\;\;\;\frac{4 \cdot \left(x - y\right)}{z}\\
\mathbf{elif}\;x \leq 9 \cdot 10^{+144}:\\
\;\;\;\;-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 x < -3.3000000000000001e66Initial program 100.0%
Taylor expanded in z around 0 88.4%
associate-*r/88.4%
Simplified88.4%
if -3.3000000000000001e66 < x < 8.99999999999999935e144Initial 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 87.8%
if 8.99999999999999935e144 < x 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 0 93.0%
Final simplification88.8%
(FPCore (x y z) :precision binary64 (if (<= z -7.5e+51) -2.0 (if (<= z 2.1e+80) (* x (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -7.5e+51) {
tmp = -2.0;
} else if (z <= 2.1e+80) {
tmp = x * (4.0 / 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 <= (-7.5d+51)) then
tmp = -2.0d0
else if (z <= 2.1d+80) then
tmp = x * (4.0d0 / 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 <= -7.5e+51) {
tmp = -2.0;
} else if (z <= 2.1e+80) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -7.5e+51: tmp = -2.0 elif z <= 2.1e+80: tmp = x * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -7.5e+51) tmp = -2.0; elseif (z <= 2.1e+80) tmp = Float64(x * Float64(4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -7.5e+51) tmp = -2.0; elseif (z <= 2.1e+80) tmp = x * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -7.5e+51], -2.0, If[LessEqual[z, 2.1e+80], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -7.5 \cdot 10^{+51}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 2.1 \cdot 10^{+80}:\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -7.4999999999999999e51 or 2.10000000000000001e80 < z Initial program 100.0%
Taylor expanded in z around inf 66.6%
if -7.4999999999999999e51 < z < 2.10000000000000001e80Initial program 100.0%
Taylor expanded in x around inf 46.7%
*-commutative46.7%
associate-*l/46.7%
associate-*r/46.6%
Simplified46.6%
Final simplification54.2%
(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%
Taylor expanded in z around inf 31.5%
Final simplification31.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 2024082
(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))