
(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%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (/ (* x 4.0) z)))
(if (<= x -3.7e-63)
t_0
(if (<= x 2.05e-251)
-2.0
(if (<= x 7e+17) (/ (* -4.0 y) z) (if (<= x 3e+107) -2.0 t_0))))))
double code(double x, double y, double z) {
double t_0 = (x * 4.0) / z;
double tmp;
if (x <= -3.7e-63) {
tmp = t_0;
} else if (x <= 2.05e-251) {
tmp = -2.0;
} else if (x <= 7e+17) {
tmp = (-4.0 * y) / z;
} else if (x <= 3e+107) {
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 = (x * 4.0d0) / z
if (x <= (-3.7d-63)) then
tmp = t_0
else if (x <= 2.05d-251) then
tmp = -2.0d0
else if (x <= 7d+17) then
tmp = ((-4.0d0) * y) / z
else if (x <= 3d+107) 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 = (x * 4.0) / z;
double tmp;
if (x <= -3.7e-63) {
tmp = t_0;
} else if (x <= 2.05e-251) {
tmp = -2.0;
} else if (x <= 7e+17) {
tmp = (-4.0 * y) / z;
} else if (x <= 3e+107) {
tmp = -2.0;
} else {
tmp = t_0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * 4.0) / z tmp = 0 if x <= -3.7e-63: tmp = t_0 elif x <= 2.05e-251: tmp = -2.0 elif x <= 7e+17: tmp = (-4.0 * y) / z elif x <= 3e+107: tmp = -2.0 else: tmp = t_0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * 4.0) / z) tmp = 0.0 if (x <= -3.7e-63) tmp = t_0; elseif (x <= 2.05e-251) tmp = -2.0; elseif (x <= 7e+17) tmp = Float64(Float64(-4.0 * y) / z); elseif (x <= 3e+107) tmp = -2.0; else tmp = t_0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * 4.0) / z; tmp = 0.0; if (x <= -3.7e-63) tmp = t_0; elseif (x <= 2.05e-251) tmp = -2.0; elseif (x <= 7e+17) tmp = (-4.0 * y) / z; elseif (x <= 3e+107) tmp = -2.0; 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]}, If[LessEqual[x, -3.7e-63], t$95$0, If[LessEqual[x, 2.05e-251], -2.0, If[LessEqual[x, 7e+17], N[(N[(-4.0 * y), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[x, 3e+107], -2.0, t$95$0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot 4}{z}\\
\mathbf{if}\;x \leq -3.7 \cdot 10^{-63}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;x \leq 2.05 \cdot 10^{-251}:\\
\;\;\;\;-2\\
\mathbf{elif}\;x \leq 7 \cdot 10^{+17}:\\
\;\;\;\;\frac{-4 \cdot y}{z}\\
\mathbf{elif}\;x \leq 3 \cdot 10^{+107}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if x < -3.70000000000000012e-63 or 3.00000000000000023e107 < 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 x around inf 65.1%
associate-*r/65.1%
*-commutative65.1%
Simplified65.1%
if -3.70000000000000012e-63 < x < 2.0499999999999999e-251 or 7e17 < x < 3.00000000000000023e107Initial 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 56.5%
if 2.0499999999999999e-251 < x < 7e17Initial program 100.0%
associate--l-100.0%
Simplified100.0%
Taylor expanded in y around inf 56.3%
*-commutative56.3%
Simplified56.3%
Final simplification60.5%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.42e+138) (not (<= y 1.75e+51))) (+ (* -4.0 (/ y z)) -2.0) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.42e+138) || !(y <= 1.75e+51)) {
tmp = (-4.0 * (y / z)) + -2.0;
} 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.42d+138)) .or. (.not. (y <= 1.75d+51))) then
tmp = ((-4.0d0) * (y / z)) + (-2.0d0)
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.42e+138) || !(y <= 1.75e+51)) {
tmp = (-4.0 * (y / z)) + -2.0;
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.42e+138) or not (y <= 1.75e+51): tmp = (-4.0 * (y / z)) + -2.0 else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -1.42e+138) || !(y <= 1.75e+51)) tmp = Float64(Float64(-4.0 * Float64(y / z)) + -2.0); 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.42e+138) || ~((y <= 1.75e+51))) tmp = (-4.0 * (y / z)) + -2.0; else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -1.42e+138], N[Not[LessEqual[y, 1.75e+51]], $MachinePrecision]], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.42 \cdot 10^{+138} \lor \neg \left(y \leq 1.75 \cdot 10^{+51}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z} + -2\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1.42000000000000001e138 or 1.75e51 < 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 x around 0 84.2%
+-commutative84.2%
distribute-rgt-in84.2%
metadata-eval84.2%
Simplified84.2%
if -1.42000000000000001e138 < y < 1.75e51Initial 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.2%
*-commutative88.2%
Simplified88.2%
Final simplification86.7%
(FPCore (x y z) :precision binary64 (if (or (<= y -1.35e+181) (not (<= y 6.1e+136))) (/ (* -4.0 y) z) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -1.35e+181) || !(y <= 6.1e+136)) {
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 <= (-1.35d+181)) .or. (.not. (y <= 6.1d+136))) 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 <= -1.35e+181) || !(y <= 6.1e+136)) {
tmp = (-4.0 * y) / z;
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -1.35e+181) or not (y <= 6.1e+136): 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 <= -1.35e+181) || !(y <= 6.1e+136)) tmp = Float64(Float64(-4.0 * 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 <= -1.35e+181) || ~((y <= 6.1e+136))) 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, -1.35e+181], N[Not[LessEqual[y, 6.1e+136]], $MachinePrecision]], N[(N[(-4.0 * y), $MachinePrecision] / z), $MachinePrecision], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.35 \cdot 10^{+181} \lor \neg \left(y \leq 6.1 \cdot 10^{+136}\right):\\
\;\;\;\;\frac{-4 \cdot y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -1.35000000000000004e181 or 6.0999999999999996e136 < y Initial program 100.0%
associate--l-100.0%
Simplified100.0%
Taylor expanded in y around inf 77.5%
*-commutative77.5%
Simplified77.5%
if -1.35000000000000004e181 < y < 6.0999999999999996e136Initial 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 83.3%
*-commutative83.3%
Simplified83.3%
Final simplification81.9%
(FPCore (x y z) :precision binary64 (if (<= y -3.8e+135) (+ (* -4.0 (/ y z)) -2.0) (if (<= y 4.9e+17) (* -4.0 (- 0.5 (/ x z))) (/ (* -4.0 (- y x)) z))))
double code(double x, double y, double z) {
double tmp;
if (y <= -3.8e+135) {
tmp = (-4.0 * (y / z)) + -2.0;
} else if (y <= 4.9e+17) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = (-4.0 * (y - 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+135)) then
tmp = ((-4.0d0) * (y / z)) + (-2.0d0)
else if (y <= 4.9d+17) then
tmp = (-4.0d0) * (0.5d0 - (x / z))
else
tmp = ((-4.0d0) * (y - x)) / z
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -3.8e+135) {
tmp = (-4.0 * (y / z)) + -2.0;
} else if (y <= 4.9e+17) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = (-4.0 * (y - x)) / z;
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -3.8e+135: tmp = (-4.0 * (y / z)) + -2.0 elif y <= 4.9e+17: tmp = -4.0 * (0.5 - (x / z)) else: tmp = (-4.0 * (y - x)) / z return tmp
function code(x, y, z) tmp = 0.0 if (y <= -3.8e+135) tmp = Float64(Float64(-4.0 * Float64(y / z)) + -2.0); elseif (y <= 4.9e+17) tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); else tmp = Float64(Float64(-4.0 * Float64(y - x)) / z); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -3.8e+135) tmp = (-4.0 * (y / z)) + -2.0; elseif (y <= 4.9e+17) tmp = -4.0 * (0.5 - (x / z)); else tmp = (-4.0 * (y - x)) / z; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -3.8e+135], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision], If[LessEqual[y, 4.9e+17], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * N[(y - x), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -3.8 \cdot 10^{+135}:\\
\;\;\;\;-4 \cdot \frac{y}{z} + -2\\
\mathbf{elif}\;y \leq 4.9 \cdot 10^{+17}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;\frac{-4 \cdot \left(y - x\right)}{z}\\
\end{array}
\end{array}
if y < -3.8000000000000001e135Initial 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 x around 0 89.5%
+-commutative89.5%
distribute-rgt-in89.5%
metadata-eval89.5%
Simplified89.5%
if -3.8000000000000001e135 < y < 4.9e17Initial 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.5%
*-commutative88.5%
Simplified88.5%
if 4.9e17 < 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 z around 0 84.3%
*-commutative84.3%
associate-*l/84.3%
Simplified84.3%
Final simplification87.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.7e-63) (not (<= x 1.2e+110))) (/ (* x 4.0) z) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.7e-63) || !(x <= 1.2e+110)) {
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 ((x <= (-3.7d-63)) .or. (.not. (x <= 1.2d+110))) 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 ((x <= -3.7e-63) || !(x <= 1.2e+110)) {
tmp = (x * 4.0) / z;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.7e-63) or not (x <= 1.2e+110): tmp = (x * 4.0) / z else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.7e-63) || !(x <= 1.2e+110)) tmp = Float64(Float64(x * 4.0) / z); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.7e-63) || ~((x <= 1.2e+110))) tmp = (x * 4.0) / z; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.7e-63], N[Not[LessEqual[x, 1.2e+110]], $MachinePrecision]], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.7 \cdot 10^{-63} \lor \neg \left(x \leq 1.2 \cdot 10^{+110}\right):\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if x < -3.70000000000000012e-63 or 1.20000000000000006e110 < 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 x around inf 65.1%
associate-*r/65.1%
*-commutative65.1%
Simplified65.1%
if -3.70000000000000012e-63 < x < 1.20000000000000006e110Initial 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 47.8%
Final simplification56.0%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.7e-63) (not (<= x 1.8e+106))) (/ 4.0 (/ z x)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.7e-63) || !(x <= 1.8e+106)) {
tmp = 4.0 / (z / x);
} 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 <= (-3.7d-63)) .or. (.not. (x <= 1.8d+106))) then
tmp = 4.0d0 / (z / x)
else
tmp = -2.0d0
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -3.7e-63) || !(x <= 1.8e+106)) {
tmp = 4.0 / (z / x);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.7e-63) or not (x <= 1.8e+106): tmp = 4.0 / (z / x) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.7e-63) || !(x <= 1.8e+106)) tmp = Float64(4.0 / Float64(z / x)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -3.7e-63) || ~((x <= 1.8e+106))) tmp = 4.0 / (z / x); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.7e-63], N[Not[LessEqual[x, 1.8e+106]], $MachinePrecision]], N[(4.0 / N[(z / x), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.7 \cdot 10^{-63} \lor \neg \left(x \leq 1.8 \cdot 10^{+106}\right):\\
\;\;\;\;\frac{4}{\frac{z}{x}}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if x < -3.70000000000000012e-63 or 1.8e106 < 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 x around inf 65.1%
associate-*r/65.1%
*-commutative65.1%
Simplified65.1%
clear-num65.0%
inv-pow65.0%
*-un-lft-identity65.0%
*-commutative65.0%
times-frac65.0%
metadata-eval65.0%
Applied egg-rr65.0%
unpow-165.0%
associate-/r*65.0%
metadata-eval65.0%
Simplified65.0%
if -3.70000000000000012e-63 < x < 1.8e106Initial 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 47.8%
Final simplification55.9%
(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 32.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 2024170
(FPCore (x y z)
:name "Data.Array.Repa.Algorithms.ColorRamp:rampColorHotToCold from repa-algorithms-3.4.0.1, B"
:precision binary64
:alt
(! :herbie-platform default (- (* 4 (/ x z)) (+ 2 (* 4 (/ y z)))))
(/ (* 4.0 (- (- x y) (* z 0.5))) z))