
(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 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 (<= z -1.2e+14)
-2.0
(if (<= z -5.6e-248)
t_0
(if (<= z 2.5e-170) (* -4.0 (/ y z)) (if (<= z 1.45e+91) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = (x * 4.0) / z;
double tmp;
if (z <= -1.2e+14) {
tmp = -2.0;
} else if (z <= -5.6e-248) {
tmp = t_0;
} else if (z <= 2.5e-170) {
tmp = -4.0 * (y / z);
} else if (z <= 1.45e+91) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = (x * 4.0d0) / z
if (z <= (-1.2d+14)) then
tmp = -2.0d0
else if (z <= (-5.6d-248)) then
tmp = t_0
else if (z <= 2.5d-170) then
tmp = (-4.0d0) * (y / z)
else if (z <= 1.45d+91) then
tmp = t_0
else
tmp = -2.0d0
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 (z <= -1.2e+14) {
tmp = -2.0;
} else if (z <= -5.6e-248) {
tmp = t_0;
} else if (z <= 2.5e-170) {
tmp = -4.0 * (y / z);
} else if (z <= 1.45e+91) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = (x * 4.0) / z tmp = 0 if z <= -1.2e+14: tmp = -2.0 elif z <= -5.6e-248: tmp = t_0 elif z <= 2.5e-170: tmp = -4.0 * (y / z) elif z <= 1.45e+91: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(Float64(x * 4.0) / z) tmp = 0.0 if (z <= -1.2e+14) tmp = -2.0; elseif (z <= -5.6e-248) tmp = t_0; elseif (z <= 2.5e-170) tmp = Float64(-4.0 * Float64(y / z)); elseif (z <= 1.45e+91) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = (x * 4.0) / z; tmp = 0.0; if (z <= -1.2e+14) tmp = -2.0; elseif (z <= -5.6e-248) tmp = t_0; elseif (z <= 2.5e-170) tmp = -4.0 * (y / z); elseif (z <= 1.45e+91) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision]}, If[LessEqual[z, -1.2e+14], -2.0, If[LessEqual[z, -5.6e-248], t$95$0, If[LessEqual[z, 2.5e-170], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.45e+91], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := \frac{x \cdot 4}{z}\\
\mathbf{if}\;z \leq -1.2 \cdot 10^{+14}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -5.6 \cdot 10^{-248}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 2.5 \cdot 10^{-170}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq 1.45 \cdot 10^{+91}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.2e14 or 1.45000000000000007e91 < z 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 66.2%
if -1.2e14 < z < -5.6000000000000002e-248 or 2.50000000000000005e-170 < z < 1.45000000000000007e91Initial 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 53.5%
associate-*r/53.5%
*-commutative53.5%
Simplified53.5%
if -5.6000000000000002e-248 < z < 2.50000000000000005e-170Initial 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 77.6%
*-commutative77.6%
Simplified77.6%
Final simplification62.5%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 z))))
(if (<= z -1.75e+16)
-2.0
(if (<= z -6.8e-248)
t_0
(if (<= z 4.6e-169) (* -4.0 (/ y z)) (if (<= z 1.65e+91) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / z);
double tmp;
if (z <= -1.75e+16) {
tmp = -2.0;
} else if (z <= -6.8e-248) {
tmp = t_0;
} else if (z <= 4.6e-169) {
tmp = -4.0 * (y / z);
} else if (z <= 1.65e+91) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = x * (4.0d0 / z)
if (z <= (-1.75d+16)) then
tmp = -2.0d0
else if (z <= (-6.8d-248)) then
tmp = t_0
else if (z <= 4.6d-169) then
tmp = (-4.0d0) * (y / z)
else if (z <= 1.65d+91) then
tmp = t_0
else
tmp = -2.0d0
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 (z <= -1.75e+16) {
tmp = -2.0;
} else if (z <= -6.8e-248) {
tmp = t_0;
} else if (z <= 4.6e-169) {
tmp = -4.0 * (y / z);
} else if (z <= 1.65e+91) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / z) tmp = 0 if z <= -1.75e+16: tmp = -2.0 elif z <= -6.8e-248: tmp = t_0 elif z <= 4.6e-169: tmp = -4.0 * (y / z) elif z <= 1.65e+91: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(4.0 / z)) tmp = 0.0 if (z <= -1.75e+16) tmp = -2.0; elseif (z <= -6.8e-248) tmp = t_0; elseif (z <= 4.6e-169) tmp = Float64(-4.0 * Float64(y / z)); elseif (z <= 1.65e+91) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (4.0 / z); tmp = 0.0; if (z <= -1.75e+16) tmp = -2.0; elseif (z <= -6.8e-248) tmp = t_0; elseif (z <= 4.6e-169) tmp = -4.0 * (y / z); elseif (z <= 1.65e+91) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.75e+16], -2.0, If[LessEqual[z, -6.8e-248], t$95$0, If[LessEqual[z, 4.6e-169], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 1.65e+91], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
\mathbf{if}\;z \leq -1.75 \cdot 10^{+16}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -6.8 \cdot 10^{-248}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 4.6 \cdot 10^{-169}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{elif}\;z \leq 1.65 \cdot 10^{+91}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.75e16 or 1.65000000000000009e91 < z 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 66.2%
if -1.75e16 < z < -6.7999999999999996e-248 or 4.6000000000000002e-169 < z < 1.65000000000000009e91Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around inf 53.4%
if -6.7999999999999996e-248 < z < 4.6000000000000002e-169Initial 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 77.6%
*-commutative77.6%
Simplified77.6%
Final simplification62.4%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* x (/ 4.0 z))))
(if (<= z -1.05e+19)
-2.0
(if (<= z -2.65e-248)
t_0
(if (<= z 7.6e-169) (* y (/ -4.0 z)) (if (<= z 2.9e+92) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = x * (4.0 / z);
double tmp;
if (z <= -1.05e+19) {
tmp = -2.0;
} else if (z <= -2.65e-248) {
tmp = t_0;
} else if (z <= 7.6e-169) {
tmp = y * (-4.0 / z);
} else if (z <= 2.9e+92) {
tmp = t_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) :: t_0
real(8) :: tmp
t_0 = x * (4.0d0 / z)
if (z <= (-1.05d+19)) then
tmp = -2.0d0
else if (z <= (-2.65d-248)) then
tmp = t_0
else if (z <= 7.6d-169) then
tmp = y * ((-4.0d0) / z)
else if (z <= 2.9d+92) then
tmp = t_0
else
tmp = -2.0d0
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 (z <= -1.05e+19) {
tmp = -2.0;
} else if (z <= -2.65e-248) {
tmp = t_0;
} else if (z <= 7.6e-169) {
tmp = y * (-4.0 / z);
} else if (z <= 2.9e+92) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = x * (4.0 / z) tmp = 0 if z <= -1.05e+19: tmp = -2.0 elif z <= -2.65e-248: tmp = t_0 elif z <= 7.6e-169: tmp = y * (-4.0 / z) elif z <= 2.9e+92: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(x * Float64(4.0 / z)) tmp = 0.0 if (z <= -1.05e+19) tmp = -2.0; elseif (z <= -2.65e-248) tmp = t_0; elseif (z <= 7.6e-169) tmp = Float64(y * Float64(-4.0 / z)); elseif (z <= 2.9e+92) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = x * (4.0 / z); tmp = 0.0; if (z <= -1.05e+19) tmp = -2.0; elseif (z <= -2.65e-248) tmp = t_0; elseif (z <= 7.6e-169) tmp = y * (-4.0 / z); elseif (z <= 2.9e+92) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -1.05e+19], -2.0, If[LessEqual[z, -2.65e-248], t$95$0, If[LessEqual[z, 7.6e-169], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[z, 2.9e+92], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := x \cdot \frac{4}{z}\\
\mathbf{if}\;z \leq -1.05 \cdot 10^{+19}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq -2.65 \cdot 10^{-248}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 7.6 \cdot 10^{-169}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{elif}\;z \leq 2.9 \cdot 10^{+92}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -1.05e19 or 2.9000000000000001e92 < z 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 66.2%
if -1.05e19 < z < -2.65e-248 or 7.6000000000000001e-169 < z < 2.9000000000000001e92Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in x around inf 53.4%
if -2.65e-248 < z < 7.6000000000000001e-169Initial 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 77.6%
*-commutative77.6%
Simplified77.6%
Taylor expanded in y around 0 77.6%
associate-*r/77.6%
*-commutative77.6%
associate-/l*77.6%
Simplified77.6%
(FPCore (x y z) :precision binary64 (if (or (<= x -9.2e+176) (not (<= x 1.2e+24))) (* (- x y) (/ 4.0 z)) (+ -2.0 (* -4.0 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -9.2e+176) || !(x <= 1.2e+24)) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0 + (-4.0 * (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 <= (-9.2d+176)) .or. (.not. (x <= 1.2d+24))) then
tmp = (x - y) * (4.0d0 / z)
else
tmp = (-2.0d0) + ((-4.0d0) * (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -9.2e+176) || !(x <= 1.2e+24)) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0 + (-4.0 * (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -9.2e+176) or not (x <= 1.2e+24): tmp = (x - y) * (4.0 / z) else: tmp = -2.0 + (-4.0 * (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -9.2e+176) || !(x <= 1.2e+24)) tmp = Float64(Float64(x - y) * Float64(4.0 / z)); else tmp = Float64(-2.0 + Float64(-4.0 * Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -9.2e+176) || ~((x <= 1.2e+24))) tmp = (x - y) * (4.0 / z); else tmp = -2.0 + (-4.0 * (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -9.2e+176], N[Not[LessEqual[x, 1.2e+24]], $MachinePrecision]], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -9.2 \cdot 10^{+176} \lor \neg \left(x \leq 1.2 \cdot 10^{+24}\right):\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\end{array}
\end{array}
if x < -9.19999999999999984e176 or 1.2e24 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 88.3%
if -9.19999999999999984e176 < x < 1.2e24Initial 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 85.8%
+-commutative85.8%
distribute-rgt-in85.8%
metadata-eval85.8%
Simplified85.8%
Final simplification86.5%
(FPCore (x y z) :precision binary64 (if (<= y -1.82e+62) (* (- x y) (/ 4.0 z)) (if (<= y 2e-25) (+ (/ (* x 4.0) z) -2.0) (+ -2.0 (* -4.0 (/ y z))))))
double code(double x, double y, double z) {
double tmp;
if (y <= -1.82e+62) {
tmp = (x - y) * (4.0 / z);
} else if (y <= 2e-25) {
tmp = ((x * 4.0) / z) + -2.0;
} else {
tmp = -2.0 + (-4.0 * (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 <= (-1.82d+62)) then
tmp = (x - y) * (4.0d0 / z)
else if (y <= 2d-25) then
tmp = ((x * 4.0d0) / z) + (-2.0d0)
else
tmp = (-2.0d0) + ((-4.0d0) * (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (y <= -1.82e+62) {
tmp = (x - y) * (4.0 / z);
} else if (y <= 2e-25) {
tmp = ((x * 4.0) / z) + -2.0;
} else {
tmp = -2.0 + (-4.0 * (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if y <= -1.82e+62: tmp = (x - y) * (4.0 / z) elif y <= 2e-25: tmp = ((x * 4.0) / z) + -2.0 else: tmp = -2.0 + (-4.0 * (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if (y <= -1.82e+62) tmp = Float64(Float64(x - y) * Float64(4.0 / z)); elseif (y <= 2e-25) tmp = Float64(Float64(Float64(x * 4.0) / z) + -2.0); else tmp = Float64(-2.0 + Float64(-4.0 * Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (y <= -1.82e+62) tmp = (x - y) * (4.0 / z); elseif (y <= 2e-25) tmp = ((x * 4.0) / z) + -2.0; else tmp = -2.0 + (-4.0 * (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[y, -1.82e+62], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], If[LessEqual[y, 2e-25], N[(N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision] + -2.0), $MachinePrecision], N[(-2.0 + N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;y \leq -1.82 \cdot 10^{+62}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{elif}\;y \leq 2 \cdot 10^{-25}:\\
\;\;\;\;\frac{x \cdot 4}{z} + -2\\
\mathbf{else}:\\
\;\;\;\;-2 + -4 \cdot \frac{y}{z}\\
\end{array}
\end{array}
if y < -1.81999999999999998e62Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around 0 89.5%
if -1.81999999999999998e62 < y < 2.00000000000000008e-25Initial 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 y around 0 91.7%
sub-neg91.7%
+-commutative91.7%
distribute-rgt-in91.7%
distribute-neg-frac91.7%
neg-mul-191.7%
*-commutative91.7%
associate-/l*91.6%
metadata-eval91.6%
distribute-neg-frac91.6%
associate-*r*91.6%
*-commutative91.6%
distribute-frac-neg291.6%
associate-*r/91.6%
metadata-eval91.6%
distribute-neg-frac291.6%
distribute-neg-frac91.6%
metadata-eval91.6%
associate-*r/91.7%
metadata-eval91.7%
Simplified91.7%
if 2.00000000000000008e-25 < 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 85.9%
+-commutative85.9%
distribute-rgt-in85.9%
metadata-eval85.9%
Simplified85.9%
Final simplification89.7%
(FPCore (x y z) :precision binary64 (if (<= z -8.4e+182) -2.0 (if (<= z 5.2e+98) (* (- x y) (/ 4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -8.4e+182) {
tmp = -2.0;
} else if (z <= 5.2e+98) {
tmp = (x - y) * (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 <= (-8.4d+182)) then
tmp = -2.0d0
else if (z <= 5.2d+98) then
tmp = (x - y) * (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 <= -8.4e+182) {
tmp = -2.0;
} else if (z <= 5.2e+98) {
tmp = (x - y) * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -8.4e+182: tmp = -2.0 elif z <= 5.2e+98: tmp = (x - y) * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -8.4e+182) tmp = -2.0; elseif (z <= 5.2e+98) tmp = Float64(Float64(x - y) * Float64(4.0 / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -8.4e+182) tmp = -2.0; elseif (z <= 5.2e+98) tmp = (x - y) * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -8.4e+182], -2.0, If[LessEqual[z, 5.2e+98], N[(N[(x - y), $MachinePrecision] * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -8.4 \cdot 10^{+182}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 5.2 \cdot 10^{+98}:\\
\;\;\;\;\left(x - y\right) \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -8.3999999999999996e182 or 5.1999999999999999e98 < z 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 77.2%
if -8.3999999999999996e182 < z < 5.1999999999999999e98Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 80.2%
(FPCore (x y z) :precision binary64 (if (or (<= x -3.1e+60) (not (<= x 3.3e+35))) (* x (/ 4.0 z)) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -3.1e+60) || !(x <= 3.3e+35)) {
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.1d+60)) .or. (.not. (x <= 3.3d+35))) 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.1e+60) || !(x <= 3.3e+35)) {
tmp = x * (4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -3.1e+60) or not (x <= 3.3e+35): tmp = x * (4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -3.1e+60) || !(x <= 3.3e+35)) 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 ((x <= -3.1e+60) || ~((x <= 3.3e+35))) tmp = x * (4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -3.1e+60], N[Not[LessEqual[x, 3.3e+35]], $MachinePrecision]], N[(x * N[(4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -3.1 \cdot 10^{+60} \lor \neg \left(x \leq 3.3 \cdot 10^{+35}\right):\\
\;\;\;\;x \cdot \frac{4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if x < -3.1000000000000001e60 or 3.3000000000000002e35 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in x around inf 71.3%
if -3.1000000000000001e60 < x < 3.3000000000000002e35Initial 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 47.7%
Final simplification57.4%
(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 35.3%
(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 2024139
(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))