
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
Sampling outcomes in binary64 precision:
Herbie found 7 alternatives:
| Alternative | Accuracy | Speedup |
|---|
(FPCore (x y z) :precision binary64 (/ (* 4.0 (- (- x y) (* z 0.5))) z))
double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (4.0d0 * ((x - y) - (z * 0.5d0))) / z
end function
public static double code(double x, double y, double z) {
return (4.0 * ((x - y) - (z * 0.5))) / z;
}
def code(x, y, z): return (4.0 * ((x - y) - (z * 0.5))) / z
function code(x, y, z) return Float64(Float64(4.0 * Float64(Float64(x - y) - Float64(z * 0.5))) / z) end
function tmp = code(x, y, z) tmp = (4.0 * ((x - y) - (z * 0.5))) / z; end
code[x_, y_, z_] := N[(N[(4.0 * N[(N[(x - y), $MachinePrecision] - N[(z * 0.5), $MachinePrecision]), $MachinePrecision]), $MachinePrecision] / z), $MachinePrecision]
\begin{array}{l}
\\
\frac{4 \cdot \left(\left(x - y\right) - z \cdot 0.5\right)}{z}
\end{array}
(FPCore (x y z) :precision binary64 (* -4.0 (- (/ (- y x) z) -0.5)))
double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
code = (-4.0d0) * (((y - x) / z) - (-0.5d0))
end function
public static double code(double x, double y, double z) {
return -4.0 * (((y - x) / z) - -0.5);
}
def code(x, y, z): return -4.0 * (((y - x) / z) - -0.5)
function code(x, y, z) return Float64(-4.0 * Float64(Float64(Float64(y - x) / z) - -0.5)) end
function tmp = code(x, y, z) tmp = -4.0 * (((y - x) / z) - -0.5); end
code[x_, y_, z_] := N[(-4.0 * N[(N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision] - -0.5), $MachinePrecision]), $MachinePrecision]
\begin{array}{l}
\\
-4 \cdot \left(\frac{y - x}{z} - -0.5\right)
\end{array}
Initial program 99.6%
remove-double-neg99.6%
neg-mul-199.6%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Final simplification100.0%
(FPCore (x y z)
:precision binary64
(let* ((t_0 (* -4.0 (/ y z))) (t_1 (* (/ x z) 4.0)))
(if (<= y -1.56e+119)
t_0
(if (<= y -6.8e-74)
t_1
(if (<= y 1.9e-162)
-2.0
(if (<= y 7.2e-83)
t_1
(if (<= y 1.45e-19)
-2.0
(if (<= y 1.36e+45) t_1 (if (<= y 5e+57) -2.0 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.56e+119) {
tmp = t_0;
} else if (y <= -6.8e-74) {
tmp = t_1;
} else if (y <= 1.9e-162) {
tmp = -2.0;
} else if (y <= 7.2e-83) {
tmp = t_1;
} else if (y <= 1.45e-19) {
tmp = -2.0;
} else if (y <= 1.36e+45) {
tmp = t_1;
} else if (y <= 5e+57) {
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) :: t_1
real(8) :: tmp
t_0 = (-4.0d0) * (y / z)
t_1 = (x / z) * 4.0d0
if (y <= (-1.56d+119)) then
tmp = t_0
else if (y <= (-6.8d-74)) then
tmp = t_1
else if (y <= 1.9d-162) then
tmp = -2.0d0
else if (y <= 7.2d-83) then
tmp = t_1
else if (y <= 1.45d-19) then
tmp = -2.0d0
else if (y <= 1.36d+45) then
tmp = t_1
else if (y <= 5d+57) 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 = -4.0 * (y / z);
double t_1 = (x / z) * 4.0;
double tmp;
if (y <= -1.56e+119) {
tmp = t_0;
} else if (y <= -6.8e-74) {
tmp = t_1;
} else if (y <= 1.9e-162) {
tmp = -2.0;
} else if (y <= 7.2e-83) {
tmp = t_1;
} else if (y <= 1.45e-19) {
tmp = -2.0;
} else if (y <= 1.36e+45) {
tmp = t_1;
} else if (y <= 5e+57) {
tmp = -2.0;
} 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.56e+119: tmp = t_0 elif y <= -6.8e-74: tmp = t_1 elif y <= 1.9e-162: tmp = -2.0 elif y <= 7.2e-83: tmp = t_1 elif y <= 1.45e-19: tmp = -2.0 elif y <= 1.36e+45: tmp = t_1 elif y <= 5e+57: tmp = -2.0 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.56e+119) tmp = t_0; elseif (y <= -6.8e-74) tmp = t_1; elseif (y <= 1.9e-162) tmp = -2.0; elseif (y <= 7.2e-83) tmp = t_1; elseif (y <= 1.45e-19) tmp = -2.0; elseif (y <= 1.36e+45) tmp = t_1; elseif (y <= 5e+57) tmp = -2.0; 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.56e+119) tmp = t_0; elseif (y <= -6.8e-74) tmp = t_1; elseif (y <= 1.9e-162) tmp = -2.0; elseif (y <= 7.2e-83) tmp = t_1; elseif (y <= 1.45e-19) tmp = -2.0; elseif (y <= 1.36e+45) tmp = t_1; elseif (y <= 5e+57) tmp = -2.0; 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.56e+119], t$95$0, If[LessEqual[y, -6.8e-74], t$95$1, If[LessEqual[y, 1.9e-162], -2.0, If[LessEqual[y, 7.2e-83], t$95$1, If[LessEqual[y, 1.45e-19], -2.0, If[LessEqual[y, 1.36e+45], t$95$1, If[LessEqual[y, 5e+57], -2.0, 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.56 \cdot 10^{+119}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;y \leq -6.8 \cdot 10^{-74}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.9 \cdot 10^{-162}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 7.2 \cdot 10^{-83}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 1.45 \cdot 10^{-19}:\\
\;\;\;\;-2\\
\mathbf{elif}\;y \leq 1.36 \cdot 10^{+45}:\\
\;\;\;\;t\_1\\
\mathbf{elif}\;y \leq 5 \cdot 10^{+57}:\\
\;\;\;\;-2\\
\mathbf{else}:\\
\;\;\;\;t\_0\\
\end{array}
\end{array}
if y < -1.56e119 or 4.99999999999999972e57 < y Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in y around inf 77.8%
*-commutative77.8%
Simplified77.8%
if -1.56e119 < y < -6.8000000000000001e-74 or 1.90000000000000002e-162 < y < 7.20000000000000025e-83 or 1.45e-19 < y < 1.36e45Initial program 98.6%
*-commutative98.6%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 55.1%
if -6.8000000000000001e-74 < y < 1.90000000000000002e-162 or 7.20000000000000025e-83 < y < 1.45e-19 or 1.36e45 < y < 4.99999999999999972e57Initial program 99.9%
*-commutative99.9%
associate-/l*99.8%
associate--l-99.8%
Simplified99.8%
Taylor expanded in z around inf 62.8%
Final simplification66.0%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.4e+119) (not (<= y 2.65e+82))) (* -4.0 (/ y z)) (* -4.0 (- 0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e+119) || !(y <= 2.65e+82)) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((y <= (-3.4d+119)) .or. (.not. (y <= 2.65d+82))) then
tmp = (-4.0d0) * (y / z)
else
tmp = (-4.0d0) * (0.5d0 - (x / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((y <= -3.4e+119) || !(y <= 2.65e+82)) {
tmp = -4.0 * (y / z);
} else {
tmp = -4.0 * (0.5 - (x / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (y <= -3.4e+119) or not (y <= 2.65e+82): tmp = -4.0 * (y / z) else: tmp = -4.0 * (0.5 - (x / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((y <= -3.4e+119) || !(y <= 2.65e+82)) tmp = Float64(-4.0 * Float64(y / z)); else tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((y <= -3.4e+119) || ~((y <= 2.65e+82))) tmp = -4.0 * (y / z); else tmp = -4.0 * (0.5 - (x / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[y, -3.4e+119], N[Not[LessEqual[y, 2.65e+82]], $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.4 \cdot 10^{+119} \lor \neg \left(y \leq 2.65 \cdot 10^{+82}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -3.40000000000000013e119 or 2.64999999999999989e82 < y Initial program 99.9%
*-commutative99.9%
associate-/l*99.6%
associate--l-99.6%
Simplified99.6%
Taylor expanded in y around inf 79.7%
*-commutative79.7%
Simplified79.7%
if -3.40000000000000013e119 < y < 2.64999999999999989e82Initial program 99.4%
remove-double-neg99.4%
neg-mul-199.4%
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.8%
neg-mul-188.8%
distribute-neg-frac88.8%
Simplified88.8%
Taylor expanded in x around 0 88.8%
mul-1-neg88.8%
unsub-neg88.8%
Simplified88.8%
Final simplification85.7%
(FPCore (x y z) :precision binary64 (if (or (<= x -95000000.0) (not (<= x 2.7e+116))) (* -4.0 (- 0.5 (/ x z))) (* 4.0 (- -0.5 (/ y z)))))
double code(double x, double y, double z) {
double tmp;
if ((x <= -95000000.0) || !(x <= 2.7e+116)) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if ((x <= (-95000000.0d0)) .or. (.not. (x <= 2.7d+116))) then
tmp = (-4.0d0) * (0.5d0 - (x / z))
else
tmp = 4.0d0 * ((-0.5d0) - (y / z))
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -95000000.0) || !(x <= 2.7e+116)) {
tmp = -4.0 * (0.5 - (x / z));
} else {
tmp = 4.0 * (-0.5 - (y / z));
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -95000000.0) or not (x <= 2.7e+116): tmp = -4.0 * (0.5 - (x / z)) else: tmp = 4.0 * (-0.5 - (y / z)) return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -95000000.0) || !(x <= 2.7e+116)) tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); else tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -95000000.0) || ~((x <= 2.7e+116))) tmp = -4.0 * (0.5 - (x / z)); else tmp = 4.0 * (-0.5 - (y / z)); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -95000000.0], N[Not[LessEqual[x, 2.7e+116]], $MachinePrecision]], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -95000000 \lor \neg \left(x \leq 2.7 \cdot 10^{+116}\right):\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\end{array}
\end{array}
if x < -9.5e7 or 2.7e116 < x Initial program 99.0%
remove-double-neg99.0%
neg-mul-199.0%
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 89.7%
neg-mul-189.7%
distribute-neg-frac89.7%
Simplified89.7%
Taylor expanded in x around 0 89.7%
mul-1-neg89.7%
unsub-neg89.7%
Simplified89.7%
if -9.5e7 < x < 2.7e116Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around 0 93.9%
associate-*r/93.9%
metadata-eval93.9%
+-commutative93.9%
*-commutative93.9%
fma-undefine93.9%
associate-*r*93.9%
neg-mul-193.9%
associate-/l*93.9%
fma-undefine93.9%
*-commutative93.9%
distribute-neg-in93.9%
sub-neg93.9%
div-sub93.9%
distribute-neg-frac93.9%
associate-/l*93.9%
*-inverses93.9%
metadata-eval93.9%
metadata-eval93.9%
Simplified93.9%
Final simplification92.2%
(FPCore (x y z) :precision binary64 (if (<= x -10400000.0) (* -4.0 (- 0.5 (/ x z))) (if (<= x 4.8e+84) (* 4.0 (- -0.5 (/ y z))) (* 4.0 (/ (- x y) z)))))
double code(double x, double y, double z) {
double tmp;
if (x <= -10400000.0) {
tmp = -4.0 * (0.5 - (x / z));
} else if (x <= 4.8e+84) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
real(8) function code(x, y, z)
real(8), intent (in) :: x
real(8), intent (in) :: y
real(8), intent (in) :: z
real(8) :: tmp
if (x <= (-10400000.0d0)) then
tmp = (-4.0d0) * (0.5d0 - (x / z))
else if (x <= 4.8d+84) then
tmp = 4.0d0 * ((-0.5d0) - (y / z))
else
tmp = 4.0d0 * ((x - y) / z)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if (x <= -10400000.0) {
tmp = -4.0 * (0.5 - (x / z));
} else if (x <= 4.8e+84) {
tmp = 4.0 * (-0.5 - (y / z));
} else {
tmp = 4.0 * ((x - y) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if x <= -10400000.0: tmp = -4.0 * (0.5 - (x / z)) elif x <= 4.8e+84: tmp = 4.0 * (-0.5 - (y / z)) else: tmp = 4.0 * ((x - y) / z) return tmp
function code(x, y, z) tmp = 0.0 if (x <= -10400000.0) tmp = Float64(-4.0 * Float64(0.5 - Float64(x / z))); elseif (x <= 4.8e+84) tmp = Float64(4.0 * Float64(-0.5 - Float64(y / z))); else tmp = Float64(4.0 * Float64(Float64(x - y) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (x <= -10400000.0) tmp = -4.0 * (0.5 - (x / z)); elseif (x <= 4.8e+84) tmp = 4.0 * (-0.5 - (y / z)); else tmp = 4.0 * ((x - y) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[x, -10400000.0], N[(-4.0 * N[(0.5 - N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], If[LessEqual[x, 4.8e+84], N[(4.0 * N[(-0.5 - N[(y / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(4.0 * N[(N[(x - y), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -10400000:\\
\;\;\;\;-4 \cdot \left(0.5 - \frac{x}{z}\right)\\
\mathbf{elif}\;x \leq 4.8 \cdot 10^{+84}:\\
\;\;\;\;4 \cdot \left(-0.5 - \frac{y}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \frac{x - y}{z}\\
\end{array}
\end{array}
if x < -1.04e7Initial program 98.5%
remove-double-neg98.5%
neg-mul-198.5%
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 87.7%
neg-mul-187.7%
distribute-neg-frac87.7%
Simplified87.7%
Taylor expanded in x around 0 87.7%
mul-1-neg87.7%
unsub-neg87.7%
Simplified87.7%
if -1.04e7 < x < 4.7999999999999999e84Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around 0 95.0%
associate-*r/95.0%
metadata-eval95.0%
+-commutative95.0%
*-commutative95.0%
fma-undefine95.0%
associate-*r*95.0%
neg-mul-195.0%
associate-/l*95.0%
fma-undefine95.0%
*-commutative95.0%
distribute-neg-in95.0%
sub-neg95.0%
div-sub95.0%
distribute-neg-frac95.0%
associate-/l*95.0%
*-inverses95.0%
metadata-eval95.0%
metadata-eval95.0%
Simplified95.0%
if 4.7999999999999999e84 < x Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around 0 91.2%
Final simplification92.4%
(FPCore (x y z) :precision binary64 (if (or (<= x -4.5e+69) (not (<= x 5.6e+82))) (* (/ x z) 4.0) -2.0))
double code(double x, double y, double z) {
double tmp;
if ((x <= -4.5e+69) || !(x <= 5.6e+82)) {
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 <= (-4.5d+69)) .or. (.not. (x <= 5.6d+82))) 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 <= -4.5e+69) || !(x <= 5.6e+82)) {
tmp = (x / z) * 4.0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -4.5e+69) or not (x <= 5.6e+82): tmp = (x / z) * 4.0 else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -4.5e+69) || !(x <= 5.6e+82)) 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 <= -4.5e+69) || ~((x <= 5.6e+82))) tmp = (x / z) * 4.0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -4.5e+69], N[Not[LessEqual[x, 5.6e+82]], $MachinePrecision]], N[(N[(x / z), $MachinePrecision] * 4.0), $MachinePrecision], -2.0]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -4.5 \cdot 10^{+69} \lor \neg \left(x \leq 5.6 \cdot 10^{+82}\right):\\
\;\;\;\;\frac{x}{z} \cdot 4\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if x < -4.4999999999999999e69 or 5.6000000000000001e82 < x Initial program 98.9%
*-commutative98.9%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in x around inf 74.0%
if -4.4999999999999999e69 < x < 5.6000000000000001e82Initial program 100.0%
*-commutative100.0%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 46.0%
Final simplification56.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 99.6%
*-commutative99.6%
associate-/l*99.7%
associate--l-99.7%
Simplified99.7%
Taylor expanded in z around inf 34.4%
Final simplification34.4%
(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 2024055
(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))