
(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 (* -4.0 (/ y z))))
(if (<= z -3.55e+87)
-2.0
(if (<= z 3.2e-118)
t_0
(if (<= z 9.5e+46) (/ (* x 4.0) z) (if (<= z 5e+104) t_0 -2.0))))))
double code(double x, double y, double z) {
double t_0 = -4.0 * (y / z);
double tmp;
if (z <= -3.55e+87) {
tmp = -2.0;
} else if (z <= 3.2e-118) {
tmp = t_0;
} else if (z <= 9.5e+46) {
tmp = (x * 4.0) / z;
} else if (z <= 5e+104) {
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 = (-4.0d0) * (y / z)
if (z <= (-3.55d+87)) then
tmp = -2.0d0
else if (z <= 3.2d-118) then
tmp = t_0
else if (z <= 9.5d+46) then
tmp = (x * 4.0d0) / z
else if (z <= 5d+104) 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 = -4.0 * (y / z);
double tmp;
if (z <= -3.55e+87) {
tmp = -2.0;
} else if (z <= 3.2e-118) {
tmp = t_0;
} else if (z <= 9.5e+46) {
tmp = (x * 4.0) / z;
} else if (z <= 5e+104) {
tmp = t_0;
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): t_0 = -4.0 * (y / z) tmp = 0 if z <= -3.55e+87: tmp = -2.0 elif z <= 3.2e-118: tmp = t_0 elif z <= 9.5e+46: tmp = (x * 4.0) / z elif z <= 5e+104: tmp = t_0 else: tmp = -2.0 return tmp
function code(x, y, z) t_0 = Float64(-4.0 * Float64(y / z)) tmp = 0.0 if (z <= -3.55e+87) tmp = -2.0; elseif (z <= 3.2e-118) tmp = t_0; elseif (z <= 9.5e+46) tmp = Float64(Float64(x * 4.0) / z); elseif (z <= 5e+104) tmp = t_0; else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) t_0 = -4.0 * (y / z); tmp = 0.0; if (z <= -3.55e+87) tmp = -2.0; elseif (z <= 3.2e-118) tmp = t_0; elseif (z <= 9.5e+46) tmp = (x * 4.0) / z; elseif (z <= 5e+104) tmp = t_0; else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := Block[{t$95$0 = N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision]}, If[LessEqual[z, -3.55e+87], -2.0, If[LessEqual[z, 3.2e-118], t$95$0, If[LessEqual[z, 9.5e+46], N[(N[(x * 4.0), $MachinePrecision] / z), $MachinePrecision], If[LessEqual[z, 5e+104], t$95$0, -2.0]]]]]
\begin{array}{l}
\\
\begin{array}{l}
t_0 := -4 \cdot \frac{y}{z}\\
\mathbf{if}\;z \leq -3.55 \cdot 10^{+87}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 3.2 \cdot 10^{-118}:\\
\;\;\;\;t\_0\\
\mathbf{elif}\;z \leq 9.5 \cdot 10^{+46}:\\
\;\;\;\;\frac{x \cdot 4}{z}\\
\mathbf{elif}\;z \leq 5 \cdot 10^{+104}:\\
\;\;\;\;t\_0\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -3.5499999999999999e87 or 4.9999999999999997e104 < 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 71.0%
if -3.5499999999999999e87 < z < 3.20000000000000004e-118 or 9.5000000000000008e46 < z < 4.9999999999999997e104Initial 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 63.1%
*-commutative63.1%
Simplified63.1%
if 3.20000000000000004e-118 < z < 9.5000000000000008e46Initial 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 64.0%
*-commutative64.0%
associate-*l/64.0%
Simplified64.0%
Final simplification65.8%
(FPCore (x y z) :precision binary64 (if (or (<= x -1.9e+150) (not (<= x 1.5e+17))) (* 4.0 (+ -0.5 (/ x z))) (+ (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if ((x <= -1.9e+150) || !(x <= 1.5e+17)) {
tmp = 4.0 * (-0.5 + (x / z));
} else {
tmp = (-4.0 * (y / z)) + -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 <= (-1.9d+150)) .or. (.not. (x <= 1.5d+17))) then
tmp = 4.0d0 * ((-0.5d0) + (x / z))
else
tmp = ((-4.0d0) * (y / z)) + (-2.0d0)
end if
code = tmp
end function
public static double code(double x, double y, double z) {
double tmp;
if ((x <= -1.9e+150) || !(x <= 1.5e+17)) {
tmp = 4.0 * (-0.5 + (x / z));
} else {
tmp = (-4.0 * (y / z)) + -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if (x <= -1.9e+150) or not (x <= 1.5e+17): tmp = 4.0 * (-0.5 + (x / z)) else: tmp = (-4.0 * (y / z)) + -2.0 return tmp
function code(x, y, z) tmp = 0.0 if ((x <= -1.9e+150) || !(x <= 1.5e+17)) tmp = Float64(4.0 * Float64(-0.5 + Float64(x / z))); else tmp = Float64(Float64(-4.0 * Float64(y / z)) + -2.0); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((x <= -1.9e+150) || ~((x <= 1.5e+17))) tmp = 4.0 * (-0.5 + (x / z)); else tmp = (-4.0 * (y / z)) + -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[x, -1.9e+150], N[Not[LessEqual[x, 1.5e+17]], $MachinePrecision]], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision] + -2.0), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;x \leq -1.9 \cdot 10^{+150} \lor \neg \left(x \leq 1.5 \cdot 10^{+17}\right):\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y}{z} + -2\\
\end{array}
\end{array}
if x < -1.89999999999999995e150 or 1.5e17 < 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 85.8%
sub-neg85.8%
+-commutative85.8%
neg-sub085.8%
associate-+l-85.8%
neg-sub085.8%
neg-mul-185.8%
associate-*r*85.8%
metadata-eval85.8%
sub-neg85.8%
metadata-eval85.8%
Simplified85.8%
if -1.89999999999999995e150 < x < 1.5e17Initial 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 91.8%
+-commutative91.8%
distribute-rgt-in91.8%
metadata-eval91.8%
Simplified91.8%
Final simplification89.6%
(FPCore (x y z) :precision binary64 (if (or (<= z -5.2e+87) (not (<= z 6e+104))) (* 4.0 (+ -0.5 (/ x z))) (* -4.0 (/ (- y x) z))))
double code(double x, double y, double z) {
double tmp;
if ((z <= -5.2e+87) || !(z <= 6e+104)) {
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 ((z <= (-5.2d+87)) .or. (.not. (z <= 6d+104))) 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 ((z <= -5.2e+87) || !(z <= 6e+104)) {
tmp = 4.0 * (-0.5 + (x / z));
} else {
tmp = -4.0 * ((y - x) / z);
}
return tmp;
}
def code(x, y, z): tmp = 0 if (z <= -5.2e+87) or not (z <= 6e+104): 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 ((z <= -5.2e+87) || !(z <= 6e+104)) tmp = Float64(4.0 * Float64(-0.5 + Float64(x / z))); else tmp = Float64(-4.0 * Float64(Float64(y - x) / z)); end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if ((z <= -5.2e+87) || ~((z <= 6e+104))) tmp = 4.0 * (-0.5 + (x / z)); else tmp = -4.0 * ((y - x) / z); end tmp_2 = tmp; end
code[x_, y_, z_] := If[Or[LessEqual[z, -5.2e+87], N[Not[LessEqual[z, 6e+104]], $MachinePrecision]], N[(4.0 * N[(-0.5 + N[(x / z), $MachinePrecision]), $MachinePrecision]), $MachinePrecision], N[(-4.0 * N[(N[(y - x), $MachinePrecision] / z), $MachinePrecision]), $MachinePrecision]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -5.2 \cdot 10^{+87} \lor \neg \left(z \leq 6 \cdot 10^{+104}\right):\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\mathbf{else}:\\
\;\;\;\;-4 \cdot \frac{y - x}{z}\\
\end{array}
\end{array}
if z < -5.19999999999999997e87 or 5.99999999999999937e104 < 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 y around 0 86.9%
sub-neg86.9%
+-commutative86.9%
neg-sub086.9%
associate-+l-86.9%
neg-sub086.9%
neg-mul-186.9%
associate-*r*86.9%
metadata-eval86.9%
sub-neg86.9%
metadata-eval86.9%
Simplified86.9%
if -5.19999999999999997e87 < z < 5.99999999999999937e104Initial 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 89.5%
*-commutative89.5%
Simplified89.5%
Final simplification88.6%
(FPCore (x y z) :precision binary64 (if (or (<= y -3.9e+52) (not (<= y 6.2e+144))) (* -4.0 (/ y z)) (* 4.0 (+ -0.5 (/ x z)))))
double code(double x, double y, double z) {
double tmp;
if ((y <= -3.9e+52) || !(y <= 6.2e+144)) {
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.9d+52)) .or. (.not. (y <= 6.2d+144))) 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.9e+52) || !(y <= 6.2e+144)) {
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.9e+52) or not (y <= 6.2e+144): 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.9e+52) || !(y <= 6.2e+144)) 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.9e+52) || ~((y <= 6.2e+144))) 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.9e+52], N[Not[LessEqual[y, 6.2e+144]], $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.9 \cdot 10^{+52} \lor \neg \left(y \leq 6.2 \cdot 10^{+144}\right):\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;4 \cdot \left(-0.5 + \frac{x}{z}\right)\\
\end{array}
\end{array}
if y < -3.9e52 or 6.2000000000000003e144 < y Initial program 100.0%
remove-double-neg100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
div-sub100.0%
distribute-frac-neg2100.0%
distribute-frac-neg100.0%
sub-neg100.0%
+-commutative100.0%
distribute-neg-out100.0%
remove-double-neg100.0%
sub-neg100.0%
*-commutative100.0%
neg-mul-1100.0%
times-frac100.0%
metadata-eval100.0%
*-inverses100.0%
metadata-eval100.0%
Simplified100.0%
Taylor expanded in y around inf 84.2%
*-commutative84.2%
Simplified84.2%
if -3.9e52 < y < 6.2000000000000003e144Initial 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 78.7%
sub-neg78.7%
+-commutative78.7%
neg-sub078.7%
associate-+l-78.7%
neg-sub078.7%
neg-mul-178.7%
associate-*r*78.7%
metadata-eval78.7%
sub-neg78.7%
metadata-eval78.7%
Simplified78.7%
Final simplification80.5%
(FPCore (x y z) :precision binary64 (if (<= z -4.2e+87) -2.0 (if (<= z 4.8e+104) (* -4.0 (/ y z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -4.2e+87) {
tmp = -2.0;
} else if (z <= 4.8e+104) {
tmp = -4.0 * (y / 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 <= (-4.2d+87)) then
tmp = -2.0d0
else if (z <= 4.8d+104) then
tmp = (-4.0d0) * (y / 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 <= -4.2e+87) {
tmp = -2.0;
} else if (z <= 4.8e+104) {
tmp = -4.0 * (y / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -4.2e+87: tmp = -2.0 elif z <= 4.8e+104: tmp = -4.0 * (y / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -4.2e+87) tmp = -2.0; elseif (z <= 4.8e+104) tmp = Float64(-4.0 * Float64(y / z)); else tmp = -2.0; end return tmp end
function tmp_2 = code(x, y, z) tmp = 0.0; if (z <= -4.2e+87) tmp = -2.0; elseif (z <= 4.8e+104) tmp = -4.0 * (y / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -4.2e+87], -2.0, If[LessEqual[z, 4.8e+104], N[(-4.0 * N[(y / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -4.2 \cdot 10^{+87}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{+104}:\\
\;\;\;\;-4 \cdot \frac{y}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -4.2e87 or 4.8e104 < 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 71.0%
if -4.2e87 < z < 4.8e104Initial 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 56.1%
*-commutative56.1%
Simplified56.1%
Final simplification61.0%
(FPCore (x y z) :precision binary64 (if (<= z -3.85e+87) -2.0 (if (<= z 4.8e+104) (* y (/ -4.0 z)) -2.0)))
double code(double x, double y, double z) {
double tmp;
if (z <= -3.85e+87) {
tmp = -2.0;
} else if (z <= 4.8e+104) {
tmp = 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 <= (-3.85d+87)) then
tmp = -2.0d0
else if (z <= 4.8d+104) then
tmp = 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 <= -3.85e+87) {
tmp = -2.0;
} else if (z <= 4.8e+104) {
tmp = y * (-4.0 / z);
} else {
tmp = -2.0;
}
return tmp;
}
def code(x, y, z): tmp = 0 if z <= -3.85e+87: tmp = -2.0 elif z <= 4.8e+104: tmp = y * (-4.0 / z) else: tmp = -2.0 return tmp
function code(x, y, z) tmp = 0.0 if (z <= -3.85e+87) tmp = -2.0; elseif (z <= 4.8e+104) tmp = Float64(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 <= -3.85e+87) tmp = -2.0; elseif (z <= 4.8e+104) tmp = y * (-4.0 / z); else tmp = -2.0; end tmp_2 = tmp; end
code[x_, y_, z_] := If[LessEqual[z, -3.85e+87], -2.0, If[LessEqual[z, 4.8e+104], N[(y * N[(-4.0 / z), $MachinePrecision]), $MachinePrecision], -2.0]]
\begin{array}{l}
\\
\begin{array}{l}
\mathbf{if}\;z \leq -3.85 \cdot 10^{+87}:\\
\;\;\;\;-2\\
\mathbf{elif}\;z \leq 4.8 \cdot 10^{+104}:\\
\;\;\;\;y \cdot \frac{-4}{z}\\
\mathbf{else}:\\
\;\;\;\;-2\\
\end{array}
\end{array}
if z < -3.85000000000000015e87 or 4.8e104 < 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 71.0%
if -3.85000000000000015e87 < z < 4.8e104Initial 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 56.1%
*-commutative56.1%
Simplified56.1%
Taylor expanded in y around 0 56.1%
associate-*r/56.1%
*-commutative56.1%
associate-*r/55.9%
Simplified55.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 30.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 2024185
(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))