text:
# 4.5: Derivatives and the Shape of a Graph

$$\newcommand{\vecs}[1]{\overset { \scriptstyle \rightharpoonup} {\mathbf{#1}} }$$

$$\newcommand{\vecd}[1]{\overset{-\!-\!\rightharpoonup}{\vphantom{a}\smash {#1}}}$$

Earlier in this chapter we stated that if a function $$f$$ has a local extremum at a point $$c$$, then $$c$$ must be a critical point of f. However, a function is not guaranteed to have a local extremum at a critical point. For example, $$f(x)=x^3$$ has a critical point at $$x=0$$ since $$f'(x)=3x^2$$ is zero at $$x=0$$, but $$f$$ does not have a local extremum at $$x=0$$. Using the results from the previous section, we are now able to determine whether a critical point of a function actually corresponds to a local extreme value. In this section, we also see how the second derivative provides information about the shape of a graph by describing whether the graph of a function curves upward or curves downward.

## The First Derivative Test

Corollary $$3$$ of the Mean Value Theorem showed that if the derivative of a function is positive over an interval $$I$$ then the function is increasing over $$I$$. On the other hand, if the derivative of the function is negative over an interval $$I$$, then the function is decreasing over $$I$$ as shown in the following figure.

A continuous function $$f$$ has a local maximum at point $$c$$ if and only if $$f$$ switches from increasing to decreasing at point $$c$$. Similarly, $$f$$ has a local minimum at $$c$$ if and only if $$f$$ switches from decreasing to increasing at $$c$$. If $$f$$ is a continuous function over an interval $$I$$ containing $$c$$ and differentiable over $$I$$, except possibly at $$c$$, the only way $$f$$ can switch from increasing to decreasing (or vice versa) at point $$c$$ is if $$f′$$ changes sign as $$x$$ increases through $$c$$. If $$f$$ is differentiable at $$c$$, the only way that $$f′$$. can change sign as $$x$$ increases through $$c$$ is if $$f′(c)=0$$. Therefore, for a function $$f$$ that is continuous over an interval $$I$$ containing $$c$$ and differentiable over $$I$$, except possibly at $$c$$, the only way $$f$$ can switch from increasing to decreasing (or vice versa) is if $$f'(c)=0$$ or $$f′(c)$$ is undefined. Consequently, to locate local extrema for a function $$f$$, we look for points $$c$$ in the domain of $$f$$ such that $$f'(c)=0$$ or $$f′(c)$$ is undefined. Recall that such points are called critical points of $$f$$.

Note that $$f$$ need not have a local extrema at a critical point. The critical points are candidates for local extrema only. In Figure $$\PageIndex{2}$$, we show that if a continuous function $$f$$ has a local extremum, it must occur at a critical point, but a function may not have a local extremum at a critical point. We show that if $$f$$ has a local extremum at a critical point, then the sign of $$f′$$ switches as $$x$$ increases through that point.

Using Figure $$\PageIndex{2}$$, we summarize the main results regarding local extrema.

• If a continuous function $$f$$ has a local extremum, it must occur at a critical point $$c$$.
• The function has a local extremum at the critical point $$c$$ if and only if the derivative $$f′$$ switches sign as $$x$$ increases through $$c$$.
• Therefore, to test whether a function has a local extremum at a critical point $$c$$, we must determine the sign of $$f′(x)$$ to the left and right of $$c$$.

This result is known as the first derivative test.

First Derivative Test

Suppose that $$f$$ is a continuous function over an interval $$I$$ containing a critical point $$c$$. If $$f$$ is differentiable over $$I$$, except possibly at point $$c$$, then $$f(c)$$ satisfies one of the following descriptions:

1. If $$f′$$ changes sign from positive when $$x<c$$ to negative when $$x>c$$, then $$f(c)$$ is a local maximum of $$f$$.
2. If $$f′$$ changes sign from negative when $$x<c$$ to positive when $$x>c$$, then $$f(c)$$ is a local minimum of $$f$$.
3. If $$f'$$ has the same sign for $$x<c$$ and $$x>c$$, then $$f(c)$$ is neither a local maximum nor a local minimum of $$f$$

Now let’s look at how to use this strategy to locate all local extrema for particular functions.

Example $$\PageIndex{1}$$: Using the First Derivative Test to Find Local Extrema

Use the first derivative test to find the location of all local extrema for $$f(x)=x^3−3x^2−9x−1.$$ Use a graphing utility to confirm your results.

Solution

Step 1. The derivative is $$f′(x)=3x^2−6x−9.$$ To find the critical points, we need to find where $$f′(x)=0.$$ Factoring the polynomial, we conclude that the critical points must satisfy

$3(x^2−2x−3)=3(x−3)(x+1)=0. \nonumber$

Therefore, the critical points are x$$=3,−1.$$ Now divide the interval $$(−∞,∞)$$ into the smaller intervals $$(−∞,−1),(−1,3)$$ and $$(3,∞).$$

Step 2. Since $$f'$$ is a continuous function, to determine the sign of $$f′(x)$$ over each subinterval, it suffices to choose a point over each of the intervals $$(−∞,−1),(−1,3)$$ and $$(3,∞)$$ and determine the sign of $$f′$$ at each of these points. For example, let’s choose $$x=−2,x=0,$$ and $$x=4$$ as test points.

Interval Test Point Sign of $$f′(x)=3(x−3)(x+1)$$ at Test Point Conclusion
$$(−∞,−1)$$ $$x=−2$$ (+)(−)(−)=+ $$f$$ is increasing.
$$(−1,3)$$ $$x=0$$ (+)(−)(+)=+ $$f$$ is increasing.
$$(3,∞)$$ $$x=4$$ (+)(+)(+)=+ $$f$$ is increasing.

Step 3. Since $$f′$$ switches sign from positive to negative as $$x$$ increases through $$1,f$$ has a local maximum at $$x=−1$$. Since $$f′$$ switches sign from negative to positive as $$x$$ increases through $$3,f$$ has a local minimum at $$x=3$$. These analytical results agree with the following graph.

Exercise $$\PageIndex{1}$$

Use the first derivative test to locate all local extrema for $$f(x)=−x^3+\frac{3}{2}x^2+18x.$$

Hint

Find all critical points of $$f$$ and determine the signs of $$f′(x)$$ over particular intervals determined by the critical points.

$$f$$ has a local minimum at $$−2$$ and a local maximum at $$3$$.

Example $$\PageIndex{2}$$: Using the First Derivative Test

Use the first derivative test to find the location of all local extrema for $$f(x)=5x^{1/3}−x^{5/3}.$$ Use a graphing utility to confirm your results.

Solution

Step 1. The derivative is

$f′(x)=\frac{5}{3}x^{−2/3}−\frac{5}{3}x^{2/3}=\frac{5}{3x^{2/3}}−\frac{5x^{2/3}}{3}=\frac{5−5x^{4/3}}{3x^{2/3}}=\frac{5(1−x^{4/3})}{3x^{2/3}}.$

The derivative $$f′(x)=0$$ when $$1−x^{4/3}=0.$$ Therefore, $$f′(x)=0$$ at $$x=±1$$. The derivative $$f′(x)$$ is undefined at $$x=0.$$ Therefore, we have three critical points: $$x=0, x=1,$$ and $$x=−1$$. Consequently, divide the interval $$(−∞,∞)$$ into the smaller intervals $$(−∞,−1),(−1,0),(0,1),$$ and $$(1,∞)$$.

Step 2: Since $$f′$$ is continuous over each subinterval, it suffices to choose a test point $$x$$ in each of the intervals from step 1 and determine the sign of $$f′$$ at each of these points. The points $$x=−2,x=−\frac{1}{2},x=\frac{1}{2},and x=2$$ are test points for these intervals.

Interval Test Point Sign of $$f′(x)=\frac{5(1−x^{4/3})}{3x^{2/3}}$$ at Test Point Conclusion
$$(−∞,−1)$$ $$x=−2$$ $$\frac{(+)(−)}{+}=−$$ $$f$$ is decreasing.
$$(−1,0)$$ $$x=−\frac{1}{2}$$ $$\frac{(+)(+)}{+}=+$$ $$f$$ is increasing.
$$(0,1)$$ $$x=\frac{1}{2}$$ $$\frac{(+)(+)}{+}=+$$ $$f$$ is increasing.
$$(1,∞)$$ $$x=2$$ $$\frac{(+)(−)}{+}=−$$ $$f$$ is decreasing.

Step 3: Since $$f$$ is decreasing over the interval $$(−∞,−1)$$ and increasing over the interval $$(−1,0), f$$ has a local minimum at $$x=−1$$. Since $$f$$ is increasing over the interval $$(−1,0)$$ and the interval $$(0,1)$$, f does not have a local extremum at $$x=0$$. Since $$f$$ is increasing over the interval $$(0,1)$$ and decreasing over the interval $$(1,∞),f$$ has a local maximum at $$x=1$$. The analytical results agree with the following graph.

Exercise $$\PageIndex{2}$$

Use the first derivative test to find all local extrema for $$(x)=\frac{3}{x−1}$$.

Hint

The only critical point of $$f$$ is $$x=1.$$

$$f$$ has no local extrema because $$f′$$ does not change sign at $$x=1$$.

## Concavity and Points of Inflection

We now know how to determine where a function is increasing or decreasing. However, there is another issue to consider regarding the shape of the graph of a function. If the graph curves, does it curve upward or curve downward? This notion is called the concavity of the function.

Figure $$\PageIndex{4a}$$ shows a function $$f$$ with a graph that curves upward. As $$x$$ increases, the slope of the tangent line increases. Thus, since the derivative increases as $$x$$ increases, $$f′$$ is an increasing function. We say this function $$f$$ is concave up. Figure $$\PageIndex{4b}$$ shows a function $$f$$ that curves downward. As $$x$$ increases, the slope of the tangent line decreases. Since the derivative decreases as $$x$$ increases, $$f′$$ is a decreasing function. We say this function $$f$$ is concave down.

Definition: concavity test

Let $$f$$ be a function that is differentiable over an open interval $$I$$. If $$f′$$ is increasing over $$I$$, we say $$f$$ is concave up over $$I$$. If $$f′$$ is decreasing over $$I$$, we say $$f$$ is concave down over $$I$$.

In general, without having the graph of a function $$f,$$ how can we determine its concavity? By definition, a function $$f$$ is concave up if $$f′$$ is increasing. From Corollary $$3$$, we know that if $$f′$$ is a differentiable function, then $$f′$$ is increasing if its derivative $$f''(x)>0$$. Therefore, a function $$f$$ that is twice differentiable is concave up when $$f''(x)>0$$. Similarly, a function $$f$$ is concave down if $$f′$$ is decreasing. We know that a differentiable function $$f′$$ is decreasing if its derivative $$f''(x)<0$$. Therefore, a twice-differentiable function $$f$$ is concave down when $$f''(x)<0$$. Applying this logic is known as the concavity test.

Test for Concavity

Let $$f$$ be a function that is twice differentiable over an interval $$I$$.

1. If $$f''(x)>0$$ for all $$x∈I$$, then $$f$$ is concave up over $$I$$
2. If $$f''(x)<0$$ for all $$x∈I,$$ then $$f$$ is concave down over $$I$$.

We conclude that we can determine the concavity of a function $$f$$ by looking at the second derivative of $$f$$. In addition, we observe that a function $$f$$ can switch concavity (Figure $$\PageIndex{6}$$). However, a continuous function can switch concavity only at a point $$x$$ if $$f''(x)=0$$ or $$f''(x)$$ is undefined. Consequently, to determine the intervals where a function $$f$$ is concave up and concave down, we look for those values of $$x$$ where $$f''(x)=0$$ or $$f''(x)$$ is undefined. When we have determined these points, we divide the domain of $$f$$ into smaller intervals and determine the sign of $$f'$$' over each of these smaller intervals. If $$f''$$ changes sign as we pass through a point $$x$$, then $$f$$ changes concavity. It is important to remember that a function $$f$$ may not change concavity at a point $$x$$ even if $$f''(x)=0$$ or $$f''(x)$$ is undefined. If, however, $$f$$ does change concavity at a point a and $$f$$ is continuous at $$a$$, we say the point $$(a,f(a))$$ is an inflection point of $$f$$.

Definition: inflection point

If $$f$$ is continuous at $$a$$ and $$f$$ changes concavity at $$a$$, the point $$(a,f(a))$$ is an inflection point of $$f$$.

Example $$\PageIndex{3}$$: Testing for Concavity

For the function $$f(x)=x^3−6x^2+9x+30,$$ determine all intervals where $$f$$ is concave up and all intervals where $$f$$ is concave down. List all inflection points for $$f$$. Use a graphing utility to confirm your results.

Solution

To determine concavity, we need to find the second derivative $$f''(x).$$ The first derivative is $$f'(x)=3x^2−12x+9,$$ so the second derivative is $$f''(x)=6x−12.$$ If the function changes concavity, it occurs either when $$f''(x)=0$$ or $$f''(x)$$ is undefined. Since $$f''$$ is defined for all real numbers $$x$$, we need only find where $$f''(x)=0$$. Solving the equation $$6x−12=0$$, we see that $$x=2$$ is the only place where $$f$$ could change concavity. We now test points over the intervals $$(−∞,2)$$ and $$(2,∞)$$ to determine the concavity of $$f$$. The points $$x=0$$ and $$x=3$$ are test points for these intervals.

Interval Test Point Sign of $$f''(x)=6x−12$$ at Test Point Conclusion
$$(−∞,2)$$ $$x=0$$ $$f$$ is concave down
$$(2,∞)$$ $$x=3$$ + $$f$$ is concave up

We conclude that $$f$$ is concave down over the interval $$(−∞,2)$$ and concave up over the interval $$(2,∞)$$. Since $$f$$ changes concavity at $$x=2$$, the point $$(2,f(2))=(2,32)$$ is an inflection point. Figure $$\PageIndex{7}$$ confirms the analytical results.

Exercise $$\PageIndex{3}$$

For $$f(x)=−x^3+\frac{3}{2}x^2+18x$$, find all intervals where $$f$$ is concave up and all intervals where $$f$$ is concave down.

Hint

Find where $$f''(x)=0$$

$$f$$ is concave up over the interval $$(−∞,\frac{1}{2})$$ and concave down over the interval $$(\frac{1}{2},∞)$$

We now summarize, in Table $$\PageIndex{2}$$, the information that the first and second derivatives of a function $$f$$ provide about the graph of $$f$$, and illustrate this information in Figure $$\PageIndex{8}$$.

Table: $$\PageIndex{2}$$: What Derivatives Tell Us about Graphs
Sign of $$f'$$ Sign of $$f''$$ Is $$f$$ increasing or decreasing? Concavity
Positive Positive Increasing Concave up
Positive Negative Increasing Concave down
Negative Positive Decreasing Concave up
Negative Negative Decreasing Concave sown

## The Second Derivative Test

The first derivative test provides an analytical tool for finding local extrema, but the second derivative can also be used to locate extreme values. Using the second derivative can sometimes be a simpler method than using the first derivative.

We know that if a continuous function has a local extrema, it must occur at a critical point. However, a function need not have a local extrema at a critical point. Here we examine how the second derivative test can be used to determine whether a function has a local extremum at a critical point. Let $$f$$ be a twice-differentiable function such that $$f′(a)=0$$ and $$f''$$ is continuous over an open interval $$I$$ containing $$a$$. Suppose $$f''(a)<0$$. Since $$f''$$ is continuous over $$I, f''(x)<0$$ for all $$x∈I$$ (Figure $$\PageIndex{9}$$). Then, by Corollary $$3, f′$$ is a decreasing function over $$I$$. Since $$f′(a)=0$$, we conclude that for all $$x∈I,f′(x)>0$$ if $$x<a$$ and $$f′(x)<0$$ if $$x>a$$. Therefore, by the first derivative test, $$f$$ has a local maximum at $$x=a$$.

On the other hand, suppose there exists a point $$b$$ such that $$f′(b)=0$$ but $$f''(b)>0$$. Since $$f''$$ is continuous over an open interval $$I$$ containing $$b$$, then $$f''(x)>0$$ for all $$x∈I$$ (Figure $$\PageIndex{9}$$). Then, by Corollary $$3,f′$$ is an increasing function over $$I$$. Since $$f′(b)=0$$, we conclude that for all $$x∈I$$, $$f′(x)<0$$ if $$x<b$$ and $$f′(x)>0$$ if $$x>b$$. Therefore, by the first derivative test, $$f$$ has a local minimum at $$x=b.$$

Second Derivative Test

Suppose $$f′(c)=0,f''$$ is continuous over an interval containing $$c$$.

1. If $$f''(c)>0$$, then $$f$$ has a local minimum at $$c$$.
2. If $$f''(c)<0$$, then $$f$$ has a local maximum at $$c$$.
3. If $$f''(c)=0,$$ then the test is inconclusive.

Note that for case iii. when $$f''(c)=0$$, then $$f$$ may have a local maximum, local minimum, or neither at $$c$$. For example, the functions $$f(x)=x^3, f(x)=x^4,$$ and $$f(x)=−x^4$$ all have critical points at $$x=0$$. In each case, the second derivative is zero at $$x=0$$. However, the function $$f(x)=x^4$$ has a local minimum at $$x=0$$ whereas the function $$f(x)=−x^4$$ has a local maximum at $$x$$, and the function $$f(x)=x^3$$ does not have a local extremum at $$x=0$$.

Let’s now look at how to use the second derivative test to determine whether $$f$$ has a local maximum or local minimum at a critical point c where $$f′(c)=0.$$

Example $$\PageIndex{4}$$: Using the Second Derivative Test

Use the second derivative to find the location of all local extrema for $$f(x)=x^5−5x^3.$$

Solution

apply the second derivative test, we first need to find critical points $$c$$ where $$f′(c)=0$$. The derivative is $$f′(x)=5x^4−15x^2$$. Therefore, $$f′(x)=5x^4−15x^2=5x^2(x^2−3)=0$$ when $$x=0,±\sqrt{3}\$$.

To determine whether $$f$$ has a local extrema at any of these points, we need to evaluate the sign of $$f''$$ at these points. The second derivative is

$$f''(x)=20x^3−30x=10x(2x^2−3).$$

In the following table, we evaluate the second derivative at each of the critical points and use the second derivative test to determine whether $$f$$ has a local maximum or local minimum at any of these points.

 $$x$$ $$f''(x)$$ Conclusion $$−\sqrt{3}$$ $$−30\sqrt{3}$$ Local maximum $$0$$ $$0$$ Second derivative test is inconclusive $$\sqrt{3}$$ $$30\sqrt{3}$$ Local minimum

By the second derivative test, we conclude that $$f$$ has a local maximum at $$x=−\sqrt{3}$$ and $$f$$ has a local minimum at $$x=\sqrt{3}$$. The second derivative test is inconclusive at $$x=0$$. To determine whether $$f$$ has a local extrema at $$x=0,$$ we apply the first derivative test. To evaluate the sign of $$f′(x)=5x^2(x^2−3)$$ for $$x∈(−\sqrt{3},0)$$ and $$x∈(0,\sqrt{3})$$, let $$x=−1$$ and $$x=1$$ be the two test points. Since $$f′(−1)<0$$ and $$f′(1)<0$$, we conclude that $$f$$ is decreasing on both intervals and, therefore, $$f$$ does not have a local extrema at $$x=0$$ as shown in the following graph.

Exercise $$\PageIndex{4}$$

Consider the function $$f(x)=x^3−(\frac{3}{2})x^2−18x$$. The points $$c=3,−2$$ satisfy $$f′(c)=0$$. Use the second derivative test to determine whether $$f$$ has a local maximum or local minimum at those points.

Hint

$$f''(x)=6x−3$$

$$f$$ has a local maximum at $$−2$$ and a local minimum at $$3$$.

We have now developed the tools we need to determine where a function is increasing and decreasing, as well as acquired an understanding of the basic shape of the graph. In the next section we discuss what happens to a function as $$→±∞.$$ At that point, we have enough tools to provide accurate graphs of a large variety of functions.

## Key Concepts

• If $$c$$ is a critical point of $$f$$ and $$f′(x)>0$$ for $$x<c$$ and $$f′(x)<0$$ for $$x>c$$, then $$f$$ has a local maximum at $$c$$.
• If $$c$$ is a critical point of $$f$$ and $$f′(x)<0$$ for $$x<c$$ and $$f′(x)>0$$ for $$x>c,$$ then $$f$$ has a local minimum at $$c$$.
• If $$f''(x)>0$$ over an interval $$I$$, then $$f$$ is concave up over $$I$$.
• If $$f''(x)<0$$ over an interval $$I$$, then $$f$$ is concave down over $$I$$.
• If $$f′(c)=0$$ and $$f''(c)>0$$, then $$f$$ has a local minimum at $$c$$.
• If $$f′(c)=0$$ and $$f''(c)<0$$, then $$f$$ has a local maximum at $$c$$.
• If $$f′(c)=0$$ and $$f''(c)=0$$, then evaluate $$f′(x)$$ at a test point $$x$$ to the left of $$c$$ and a test point $$x$$ to the right of $$c$$, to determine whether $$f$$ has a local extremum at $$c$$.

## Glossary

concave down
if $$f$$ is differentiable over an interval $$I$$ and $$f′$$ is decreasing over $$I$$, then $$f$$ is concave down over $$I$$
concave up
if $$f$$ is differentiable over an interval $$I$$ and $$f′$$ is increasing over $$I$$, then $$f$$ is concave up over $$I$$
concavity
the upward or downward curve of the graph of a function
concavity test
suppose $$f$$ is twice differentiable over an interval $$I$$; if $$f''>0$$ over $$I$$, then $$f$$ is concave up over $$I$$; if $$f''<$$ over $$I$$, then $$f$$ is concave down over $$I$$
first derivative test
let $$f$$ be a continuous function over an interval $$I$$ containing a critical point $$c$$ such that $$f$$ is differentiable over $$I$$ except possibly at $$c$$; if $$f′$$ changes sign from positive to negative as $$x$$ increases through $$c$$, then $$f$$ has a local maximum at $$c$$; if $$f′$$ changes sign from negative to positive as $$x$$ increases through $$c$$, then $$f$$ has a local minimum at $$c$$; if $$f′$$ does not change sign as $$x$$ increases through $$c$$, then f does not have a local extremum at $$c$$
inflection point
if $$f$$ is continuous at $$c$$ and $$f$$ changes concavity at $$c$$, the point $$(c,f(c))$$ is an inflection point of $$f$$
second derivative test
suppose $$f′(c)=0$$ and $$f'$$' is continuous over an interval containing $$c$$; if $$f''(c)>0$$, then $$f$$ has a local minimum at $$c$$; if $$f''(c)<0$$, then $$f$$ has a local maximum at $$c$$; if $$f''(c)=0$$, then the test is inconclusive


text:
💬 👋 We’re always here. Join our Discord to connect with other students 24/7, any time, night or day.Join Here!

JB
Numerade Educator

# Use the given graph of $f(x) = \sqrt{x}$ to find a number $\delta$ such thatif $\left| x - 4 \right| < \delta$ then $\left| \sqrt{x} - 2 \right| < 0.4$

## $\delta=1.44$

Limits

Derivatives

### Discussion

You must be signed in to discuss.
EJ

Emanuel J.

February 5, 2021

Use the given graph of f(x)to find

Lectures

Join Bootcamp

### Video Transcript

Yeah. Hello. We have one of these obnoxious questions with epsilon delta is regarding the graph of a function. In this case F of X equals root acts. So we're told to use the graph, I don't have access to that right away. But we can sketch a quick graph. Got 1234567891. I have a couple of points where I can do square roots readily James. So let's plot a couple of points that we know we're going to be here at four. We know we're going to be two at nine. We know we're gonna be three and the graph is going to do kind of like that. So what we're interested in actually is this point right here at X equals four. Because we are asked given that Square Root of X -2. So we're giving the absolute value Less than .4. We want to find a delta. Don't listen very I'm gonna find a delta. Such that we have computer indentation here. We want to dealt us such that if I can write to uh huh, Absolute Value X -4. Less than delta. So looking at the graph what this means is this right here we rewrite that as saying we want F of x -F of four because 2 is the square root of four to be in this range. Right? That's what we're saying. And so now we need to find Something so that X -4 being inside of delta being inside of delta And negative delta. Whose forgot to write my negative science. Those are important. Negative 0.4 negative delta. So this is kind of an epsilon delta thing. We have specified an epsilon of 0.4 around the value that we're interested in. So we're saying we are within this range, we now want to find what range on X. We'll meet the lower and upper end. If you can see, I've got this band on the Y axis surrounding Y equals two and that gives us a band on the X axis surrounding X equals four right there. So because my graph is crudely drawn at best, I can't actually estimate that from the graph, but fortunately a little bit of algebra can give us an exact answer. So if you wanted to know how to do this algebraic lee, you're about to learn. We're looking for a condition on X. So let's start with the condition we want to meet, we want to meet the condition That square root X -2 is greater than negative .4, But less than positive .4. So let's start by adding to everywhere. Because this is like saying we have an inequality here and then we have another inequality here. We could work with them separately, but rather We can do it at the same time. You add to everywhere. The left side becomes 1.6 less than route X, less than 2.4 because we added to over here. So now we can square everything because nothing ugly is going to happen when we do that. We get 2.56 over here, less than X. Less than I want to say. It was 5.76 when I did that earlier. Yeah. 5.76. Okay, so those are conditions, if X is in that range then it will meet the original condition. But the problem is we can't develop a delta off of this because these are not equidistant. So this is like saying for minus 1.44. And this is like saying four plus 1.76. So we can't get any farther away from four Than 1.44 before squaring it causes us to fall outside of this range right here. We have to be in this range. But if we try to choose plus one, if we try to choose a delta of 1.76 then we end up below this endpoint right here. So our delta then must be given by 1.44. And if you want to you can check it, try to in four minus 1.44, squaring it, You'll get where you need to be. Try doing try taking the square root of that and you'll end up within this range. Do four plus 1.44. Well that's 5.44 which falls inside this range. And so we have found our delta. Thank you folks have a good day

Limits

Derivatives

Lectures

Join Bootcamp

format: plain


text:
# Difference between 'include' and 'extend' in Ruby

RubyServer Side ProgrammingProgramming

In Ruby, when we are using the include keyword, we are importing a module code, but we aren't allowed to access the methods of the imported modules with the class directly because it basically gets imported as a subclass for the superclass.

On the other hand, when we are using the extend keyword in Ruby, we are importing the module code but the methods are imported as class methods. If we try to access the methods that we imported with the instance of the class, the compiler will throw an error.

Now let's use these two keywords in a Ruby code to understand the difference.

## Example 1

Consider the code shown below.

# Creating a module that contains a method
module MyModule
def first_method
puts 'This is the First Method.'
end
end

class First_Class
include MyModule
end

class Second_Class
extend MyModule
end

# object access
First_Class.new.first_method

# class access
Second_Class.first_method

## Output

It will produce the following output.

This is the First Method.
This is the First Method.

## Example 2

Now let's consider a case where we would want to import instance methods on a class and its class methods as well. In such a case, we will use both include and extend keywords at the same time.

Consider the code shown below

# Creating a module that contains a method
module MyModule
def logs(x)
puts x
end

end
class First_Class
include MyModule
extend MyModule
end

First_Class.new.logs("It's a chilly overcast day.")
First_Class.logs("Keep an umbrella with you.")

## Output

It will produce the following output.

It's a chilly overcast day.
Keep an umbrella with you.
Updated on 12-Apr-2022 08:49:45


text:
## Vol 6, No 2 (2014)

 On rigid derivations in rings Article References O. D. Artemovych, M. P. Lukashenko 181-190
 Approximation of modulus, periods and values of Jacobi elliptic functions Article (Українська) References G. M. Barabash, Ya. M. Kholyavka 191-195
 Approximation of capacities on metric spaces with Lipschitz capacities Article (Українська) References I. D. Hlushak 196-202
 A Study on $\phi$-Symmetric $\tau$-curvature tensor in $N(k)$-contact metric manifold Article References G. Ingalahalli, C. S. Bagewadi 203-211
 On operators of stochastic differentiation on spaces of regular test and generalized functions of Levy white noise analysis Article References M. M. Dyriv, N. A. Kachanovsky 212-229
 On Inverse Topology Problem for Laplace Operators on Graphs Article References Yu. Yu. Ershova, I. I. Karpenko, A. V. Kiselev 230-236
 Asymptotic behavior of the logarithmic derivative for entire functions of order zero Article (Українська) References M. V. Zabolotskyj, M. R. Mostova 237-241
 Non-local boundary value problem for a system of partial differential equations with operator coefficients in a complex domain Article (Українська) References V. S. Il'kiv, N. I. Strap 242-255
 Functions with connected graphs and $B_1$-retracts Article (Українська) References O. Karlova 256-259
 Gorenstein Tiled Orders Article References V. Kiricenko, M. Khibina, L. Mashchenko, M. Plakhotnyk, V. Zhuravlev 260-281
 Problem for hyperbolic system of equations having constant coefficients with integral conditions with respect to the time variable Article References A. M. Kuz, B. Yo. Ptashnyk 282-299
 On the growth of a klasss of entire Dirichlet series Article (Українська) References L. V. Kulyavetc', O. M. Mulyava 300-309
 On some generalizations of Baer's theorem Article References L. A. Kurdachenko, O. O. Pypka 310-316
 On orders of two transformation semigroups of the boolean Article References I. V. Livinsky, T. G. Zhukovska 317-319
 The fundamental solution of Cauchy problem for a single equation of the diffusion equation with inertia Article References H. P. Malytska, I. V. Burtnyak 320-328
 On continuity of $KC$-functions with values in Ceder plane Article (Українська) References V. K. Maslyuchenko, O. D. Myronyk 329-336
 Around $P$-small subsets of groups Article References I. V. Protasov, K. D. Protasova 337-341
 The problem with inclined derivative for a parabolic equations with impulse conditions and degeneration Article (Українська) References I. D. Pukalskiy 342-350
 Problem with two-point conditions for parabolic equation of second order on time Article References M. M. Symotyuk, I. R. Tymkiv 351-359
 Finite homomorphic images of Bezout duo-domains Article References O. S. Sorokin 360-366
 Partition polynomials assigned by parafunctions of triangular matrices with arbitrary first two columns Article References S. D. Stefluk 367-371
 Note on Arens regularity of symmetric tensor products Article References O. G. Taras, A. V. Zagorodnyuk 372-376
 Stability of tripled fixed point iteration procedures for mixed monotone mappings Article References I. Timis 377-388
 On the primitive representations of finitely generated metabelian groups of finite rank over a field of non-zero characteristic Article References A. V. Tushev 389-393
 Homomorphisms of the algebra of symmetric analytic functions on $\ell_1$ Article References I. V. Chernega 394-398
 Rostislav Ivanovich Grigorchuk is laureate of the Leroy P. Steele Prize of 2015 year Article (Українська) 399-399
 Volodymyr Vasyliovych Sharko (obituary) Article (Українська) 400-401


text:
# Discrete-time queue (Geo/Geo/1)

Queueing theory is generally introduced in the continuous-time setting, with the fundamental ${M/M/1}$ queue for which many analytical results may be obtained with relatively straightforward computations, due largely to the memoryless property of the exponential distribution. In the next few posts I will analyze the discrete-time analog of this model; namely, a single-server queue with *geomentric* interarrival and service times.

Suppose customers arrive to a queue according to a Bernoulli process; that is, at each time ${n=1,2,\ldots}$, a customer arrives with probability ${p_\lambda}$, independent of past or future arrivals. The probability that a customer finishes service at time ${n+1}$, conditioned on that customer having been in service at time ${n}$, is ${p_\mu}$. Let ${\{A_m : m=1,2,\ldots\}}$ be the arrival process and ${\{D_m : m=1,2,\ldots\}}$ the departure process. The interarrival times are ${T_m:=A_m-A_{m-1}}$, with ${A_0\equiv 0}$. Conditioned on ${A_{m-1}=i}$, we have ${\mathbb P(A_m=i+j)=\mathbb P(T_m=j)=(1-p_\lambda)^{j-1}p_{\lambda}}$, and so by independence of arrivals, the ${T_m}$ are i.i.d. ${\mathsf{Geo}(p_\lambda)}$ random variables. A similar argument shows that the service times are i.i.d. ${\mathsf{Geo}(p_\mu)}$ random variables.

Let ${\{Z_n:n=0,1,2,\ldots\}}$ be the number of customers in the system at time ${n}$, after arrivals and before departures. It follows from the memoryless property of the geometric distribution that ${Z_n}$ is a Markov chain; that is, for any nonnegative integers ${n}$, ${i}$, and ${j}$ and any ${E\in\sigma\left(\bigcup_{k=0}^n Z_k\right)}$, we have

$\displaystyle \mathbb P(Z_{n+1} = j\mid Z_n=i, E) = \mathbb P(Z_{n+1}=j\mid Z_n=i).$

At each time ${n}$, at most one customer can arrive and at most one customer can depart. It follows that ${Z_n}$ is a birth-death chain, with transition probabilities given by

$\displaystyle p(i,j) = \begin{cases} 1-p_\lambda,& i=j=0\\ p_\lambda,& i=0, j=1\\ p_\mu(1-p_\lambda),& j=i-1\\ p_\lambda(1-p_\mu),& j=i+1, i>0\\ p_\lambda p_\mu + (1-p_\lambda)(1-p_\mu),& i=j>0. \end{cases}$

Suppose ${\nu}$ is an invariant measure for the transition matrix ${P}$, that is ${\nu = \nu P}$. Assume WLOG that ${\nu_0=1}$, then ${\nu_1 = \frac{p_\lambda}{p_\mu(1-p_\lambda)}}$ and

$\displaystyle \nu_n = \left(\frac{p_\lambda(1-p_\mu)}{p_\mu(1-p_\lambda)}\right)\nu_{n-1},\ n\geqslant2.$

By inspection, this recurrence has solution

$\displaystyle \nu_n=\left(\frac{p_\lambda(1-p_\mu)}{p_\mu(1-p_\lambda)}\right)^{n-1}\frac{p_\lambda}{p_\mu(1-p_\lambda)},\ n\geqslant1.$

Now, ${\{Z_n\}}$ is positive recurrent iff ${\sum_{n=0}^\infty \nu_n<\infty}$, which is true precisely when

$\displaystyle p_\lambda(1-p_\mu)

The offered load to the system is then

$\displaystyle \rho := \frac{p_\lambda(1-p_\mu)}{p_\mu(1-p_\lambda)}.$

Assuming ${\rho<1}$, let ${C=\sum_{n=0}^\infty \nu_n}$ and define ${\pi=C^{-1}\nu}$. By construction, ${\pi = \pi P}$ and ${\sum_{n=0}^\infty \pi_n=1}$, so that ${\pi}$ is the (unique) stationary distribution of ${\{Z_n\}}$. A straightforward computation yields

\displaystyle \begin{aligned} \pi_0 &= \frac{p_\mu-p_\lambda}{p_\mu}\\ \pi_n &= \rho^{n-1}\left(\frac{p_\lambda(1-\rho)}{p_\mu}\right),\ n\geqslant1. \end{aligned}

The limiting mean number of customers in the system ${L}$ is given by

\displaystyle \begin{aligned} L &= \sum_{n=1}^\infty n\pi_n\\ &= \left(\frac{p_\lambda(1-\rho)}{p_\mu}\right)\sum_{n=1}^\infty n\rho^{n-1}\\ &= \frac{p_\lambda}{p_\mu(1-\rho)}. \end{aligned}

Invoking Little’s Law, we compute the mean sojourn time of customers by

$\displaystyle W = \frac L{p_\lambda} = \frac1{p_\mu(1-\rho)}.$


text:
# Prove that for any $a$ and $n > 2$, the last two digits of $a^n$ can not be $30$

I'm confused on how to prove this. I know if I test it out with small numbers it doesn't end up with the last two digits to being 30. But how about larger numbers with larger exponents? Can someone show me how to prove this?

If the last two digits of $$a^n$$ were $$30$$, then $$a^n$$ would be divisible by $$10$$.
But then $$a$$ would be divisible by $$10$$.
But then $$a^n$$ for $$n\ge2$$ would be divisible by $$100$$, so the last two digits of $$a^n$$ would be $$00$$.
• prime factorization: $10=2\times5$ – J. W. Tanner Feb 20 '20 at 21:55
If you talk about $$a^n$$, it is indeed true. You have $$30 = 2 * 3 * 5$$. Let $$a = 2^\alpha q$$ where $$q$$ is relatively prime to $$2$$. Then $$a^n = 2^{n\alpha} q^n$$. So for all $$k\in \mathbb{Z}$$, $$a^n + 100k$$ will be prime to $$2$$ if $$\alpha = 0$$ and divisible by $$4$$ if $$\alpha > 0$$. So $$a^n + 100k$$ cannot equal $$30$$, and the two last digits of $$a^n$$ cannot be $$30$$. You only need $$n \geq 2$$.


text:
# Homework Help: Sigma Algebras

1. Sep 8, 2009

### azdang

Let f be a function mapping $$\Omega$$ to another space E with a sigma-algebra[/tex] E. Let A = {A C $$\Omega$$: there exists B $$\epsilon$$ E with A = $$f^{-1}(B)$$}. Show that A is a sigma-algebra on $$\Omega$$.

Okay, so I should start by showing that $$\Omega$$ is in A. I wasn't sure if this was as easy as saying that since A is made up of all subsets of $$\Omega$$, then clearly, $$\Omega$$ must be in A since it is a subset of itself.

Next, I would have to show it is closed under complement. Here is what I tried doing.

$$A = f^{-1}(B)$$

$$A^c = (f^{-1}(B))^c = f^{-1}(B^c).$$ Since E is a sigma-algebra, $$B^c$$ is in E, thus by the definition of A, $$f^{-1}(B^c)$$ is in A so it is closed under complement.

The last thing would be to show it is closed under countable union. I'm sort of unsure how to set this up, but here is what I tried doing.

$$A_i \epsilon$$A. Then, $$A_i = f^{-1}(B_i)$$ where $$B_i \epsilon$$ E. So, $$\bigcup_{i=1}^{\infty}A_i = \Bigcup_{i=1}^{\infty}f^{-1}(B_i)=f^{-1}(\bigcup_{i=1}^{\infty}B_i).$$ And the union of the $$B_i$$'s is in E since it is a sigma-algebra. Therefore, can I conclude that A is closed under countable union and thus, a sigma-algebra?

Last edited: Sep 8, 2009
2. Sep 9, 2009

### Billy Bob

This is invalid, because A is not necessarily made up of all subsets of $$\Omega$$. (If it were, then A would be the power set of $$\Omega$$.)

You simply need to display a set B such that $$\Omega$$ is the inverse image of B. There is really only one possible choice for B, isn't there?

Your complement and countable union steps are very good. (In your final write-up of the complement step, you ought to introduce A and B, similar to what you did in the first step of the countable union proof, to satisfy a picky grader.)

By the way, is it even necessary to prove $$\Omega$$ is in A? I mean, is that part of your definition? (Wouldn't it follow anyway from the other properties, perhaps with a "non-empty" hypothesis here or there?)


text:
# Initial Progress on Micro Cathodic Arc Thruster Plume Simulations

Posted on July 14th, 2013
Previous Article :: Next Article

Few weeks ago I started working on modeling the near plume of a micro cathodic arc thruster (µCAT) that is currently being investigated at the George Washington University. You can see images of the thruster below. The thruster consists of a ring-type Titanium cathode, an insulator, and a copper anode. An inductor-based power supply provides pulses that result in vacuum arc breakdown at the cathode/insulator interface. This breakdown results in formation of dense Titanium plasma from the cathode spot.

In the absence of additional forces, the ion velocity is expected to be primarily in the radial direction. In order to turn the ions into the axial direction to provide thrust, the thrust tube is surrounded by an electromagnet that produces magnetic field lines predominantly parallel with the thrust axis. The magnetic field is selected such that only the electrons are magnetized. The resulting ambipolar field then provides the acceleration that rotates the ions in the thrust direction. The magnetic field further allows the mission designer to tune the trust and Isp by adjusting the field strength. The magnetic field also assists with uniform erosion of the cathode.

## Simulation Setup

The miniature size and power requirements of the thruster make it an attractive choice for nanosatellite missions that historically had to manage without using propulsion. However, before the thruster can be flight qualified, it is necessary for us to obtain a better understanding of performance, plume properties, and any possible backflow contamination concerns. The small size makes it difficult to utilize standard tools such as Langmuir and Faraday probes. The experimental effort to data, which has been summarized in number of papers, has mainly consisted of using a segmented disc to measure current density, a gridded probe to study ion velocity, and microbalances to determine thrust and mass flow. Numerical simulations can help us fill in the gaps. Due to its small size, we should be able to perform a single end-to-end simulation encompassing the internal region and extending to the near plume. That is the objective of this study.

Figure 3 shows the planned simulation domain. It consists of three rectilinear meshes of varying node spacing. The cathode is shown in pink, the insulator is in white, and the anode is in blue. The black square is the magnet. The three meshes are shown by the red outlines. We perform the simulations with our Starfish code. Starfish supports both kinetic and fluid materials. In this case we opted for the fully-kinetic approach in which ions and electrons are simulated as macroparticles. This then requires a mesh fine enough to resolve the local Debye length. This however turned out to be a challenge. Starfish for now contains just a Gauss-Seidel based matrix solver, and as you surely know, the Gauss-Seidel schmee require a large number of iterations to converge. Given that some 250,000 time steps were used to generate the plots below, the convergence rate of the solver is a huge contributor to the simulation computational performance. Unfortunately, in the absence of resolving the Debye length, a virtual anode forms as shown in Figure 4. This is a common occurrence in kinetic plasma simulations and is due to the mesh not resolving local charge non-neutrality. The electric field induced by the numerical artifact forces the ions back towards the cathode spot and we do not obtain a discharge.

## Preliminary Results

We tried several approaches and finally settled and using an artificial permittivity multiplier. Since $latex nabla^2 phi = -rho/epsilon_0$, increasing vacuum permittivity is analogous to a decrease in the plasma density. And since Debye length scales inversely with the density, this then allows us to use a coarser grid. Below you will find videos from our preliminary results. These concentrate only on the near cathode region. The results still need to be analyzed in more detail, but they at least show the simulation capturing some of the basic physics.

### Ion and Electron Density without Magnetic Field

First, we can see that in the absence of the magnetic field, the ions and electrons indeed initially flow in the radial direction. Because our simulation is axisymmetric, we are actually modeling a uniform circumferential source. The resulting growth of density near the centerline results in formation of a repulsive electric field which acts to shed this ion concentration. The electrons can be seen to closely follow the ions in this case.

### Ion and Electron Density with Magnetic Field

The situation is quite different once the magnetic field is included. As we can see below in the electron animation, electrons are now confined to a thin tube corresponding to a magnetic field line. Collisions were ignored in this simulation and hence the electron motion is restricted to the tangential direction. The ions can be seen to initially flow radially just as in the case above, however, they can be seen to turn and roughly follow the electrons. We can see that only about 50% of the ions actually flow in the correct direction. The other half flows upstream due potential drop induced by the cathode. It is not yet clear whether this is the true behavior or a simulation artifact due to perhaps incorrect boundary conditions. However, what is reassuring is that, the experiments indicate that only about 50% of the ion current leaves the thruster with the second half depositing back in the device. We can also see that a periodic instability develops. The source of this instability is still under investigation.

Subscribe to the newsletter and follow us on Twitter. Send us an email if you have any questions.


text:
GMAT Question of the Day - Daily to your Mailbox; hard ones only

 It is currently 20 Jan 2019, 11:14

### GMAT Club Daily Prep

#### Thank you for using the timer - this advanced tool can estimate your performance and suggest more practice questions. We have subscribed you to Daily Prep Questions via email.

Customized
for You

we will pick new questions that match your level based on your Timer History

Track

every week, we’ll send you an estimated GMAT score based on your performance

Practice
Pays

we will pick new questions that match your level based on your Timer History

## Events & Promotions

###### Events & Promotions in January
PrevNext
SuMoTuWeThFrSa
303112345
6789101112
13141516171819
20212223242526
272829303112
Open Detailed Calendar
• ### FREE Quant Workshop by e-GMAT!

January 20, 2019

January 20, 2019

07:00 AM PST

07:00 AM PST

Get personalized insights on how to achieve your Target Quant Score.
• ### GMAT Club Tests are Free & Open for Martin Luther King Jr.'s Birthday!

January 21, 2019

January 21, 2019

10:00 PM PST

11:00 PM PST

Mark your calendars - All GMAT Club Tests are free and open January 21st for celebrate Martin Luther King Jr.'s Birthday.

# A merchant reduces the original price of a coat by 20 percent for a sp

Author Message
TAGS:

### Hide Tags

SVP
Status: Preparing GMAT
Joined: 02 Nov 2016
Posts: 2034
Location: Pakistan
GPA: 3.39
A merchant reduces the original price of a coat by 20 percent for a sp  [#permalink]

### Show Tags

16 Feb 2017, 05:38
00:00

Difficulty:

5% (low)

Question Stats:

94% (01:14) correct 6% (01:27) wrong based on 44 sessions

### HideShow timer Statistics

A merchant reduces the original price of a coat by 20 percent for a spring sale. Finding that the coat did not sell, the merchant reduces the spring price by a further 15 percent at the start of the summer. The coat’s summer price is what percent of its original price?

A. 35%
B. 64%
C. 65%
D. 68%
E. 80%

_________________

Final days of the GMAT Exam? => All GMAT Flashcards.
This Post Helps = Press +1 Kudos
Best of Luck on the GMAT!!

Senior Manager
Joined: 19 Apr 2016
Posts: 274
Location: India
GMAT 1: 570 Q48 V22
GMAT 2: 640 Q49 V28
GPA: 3.5
WE: Web Development (Computer Software)
Re: A merchant reduces the original price of a coat by 20 percent for a sp  [#permalink]

### Show Tags

16 Feb 2017, 07:12
A merchant reduces the original price of a coat by 20 percent for a spring sale. Finding that the coat did not sell, the merchant reduces the spring price by a further 15 percent at the start of the summer. The coat’s summer price is what percent of its original price?

A. 35%
B. 64%
C. 65%
D. 68%
E. 80%

Let x be the original price
after 20% decrease, new price = 0.8x
after 15% further decrease = 0.8x*.85=0.68x
coat’s summer price is what percent of its original price = 0.68x/x = 0.68 = 68%

Hence Option D is correct.
Hit Kudos if you liked it
Board of Directors
Status: QA & VA Forum Moderator
Joined: 11 Jun 2011
Posts: 4342
Location: India
GPA: 3.5
Re: A merchant reduces the original price of a coat by 20 percent for a sp  [#permalink]

### Show Tags

16 Feb 2017, 07:47
A merchant reduces the original price of a coat by 20 percent for a spring sale. Finding that the coat did not sell, the merchant reduces the spring price by a further 15 percent at the start of the summer. The coat’s summer price is what percent of its original price?

A. 35%
B. 64%
C. 65%
D. 68%
E. 80%

Let original price be 100

Reduced price of coat is 80

Final reduced price is $$\frac{80*(100-15)}{100} = 68$$

Thus, the final price of the coat is $$\frac{68}{100*100}$$ = 68% of the Original Price.

Hence, answer will be (D) 68%
_________________

Thanks and Regards

Abhishek....

PLEASE FOLLOW THE RULES FOR POSTING IN QA AND VA FORUM AND USE SEARCH FUNCTION BEFORE POSTING NEW QUESTIONS

How to use Search Function in GMAT Club | Rules for Posting in QA forum | Writing Mathematical Formulas |Rules for Posting in VA forum | Request Expert's Reply ( VA Forum Only )

Target Test Prep Representative
Affiliations: Target Test Prep
Joined: 04 Mar 2011
Posts: 2830
Re: A merchant reduces the original price of a coat by 20 percent for a sp  [#permalink]

### Show Tags

21 Feb 2017, 09:21
1
A merchant reduces the original price of a coat by 20 percent for a spring sale. Finding that the coat did not sell, the merchant reduces the spring price by a further 15 percent at the start of the summer. The coat’s summer price is what percent of its original price?

A. 35%
B. 64%
C. 65%
D. 68%
E. 80%

We can let the original price of the coat = x. After a 20% reduction, the price is 0.8x. After another 15% reduction, the price is 0.85(0.8x) = 0.68x.

Thus, coat’s summer price is (0.68x/x)100 = 68% of the original price.

_________________

Jeffery Miller

GMAT Quant Self-Study Course
500+ lessons 3000+ practice problems 800+ HD solutions

Re: A merchant reduces the original price of a coat by 20 percent for a sp &nbs [#permalink] 21 Feb 2017, 09:21
Display posts from previous: Sort by


text:
# Is my OS 32-bit or 64-bit?

It's not too important anymore, but occasionally somebody needs to know.

Here is a simple golf: Taking no user input, tell me if the computer on which the code is run is on a 64-bit operating system, or a 32-bit operating system!

If the code is run on a 32-bit operating system, print "32", if the code is run on a 64 bit operating system, output "64". Important: Print any other non-empty string of alphanumeric characters if it's neither 32 or 64 bit.

Please note that a 32 bit program running on a computer with a 64 bit operating system should output "64". You can assume that users will use 64 bit software whenever possible.

To be eligible for entry, your code must be able to run on Windows 4.10 or newer Microsoft supported Windows systems, and at least one flavor of Linux of your choosing (so long as that flavor is gratis). Compatibility mods can be installed, so long as the program still returns the right value.

The usual rules apply.

Note: If your answer is only meant to print out 32 or 64, but not the alt case, I'll accept it, but it is not a competing answer.

I'll try and post some results of running these codes on different OSes later!

• So "Please note that a 32 bit program running on a computer with a 64 bit operating system should output "64". You can assume that users will use 64 bit software whenever possible." means that if the interprettor/compiler etc is is available in both 32 bit and 64 bit, then a 32 bit OS, will always run the 32 bit version of the interpreter/etc, and the 64 bit OS will always run the 64 bit interpreter/etc. So worrying about the difference between the program being 32 or 64, and the OS being 32 or 64, is basically only a problem for languages with only 32 bit implementations. Right? – Lyndon White Jun 20 '17 at 4:33
• Many solutions here would print "32" on a 64-bit OS if a 32-bit compiler was used to compile program. Is this OK? – Martin Rosenau Jun 20 '17 at 8:54
• What in the world is "Windows 4.10"? Does that mean Windows 98? Or does it mean Windows NT 4? What do you consider to be "newer" than that? This seems an exceptionally poorly thought-out challenge. – Cody Gray Jun 20 '17 at 9:47
• There is no "official windows spec", and nobody refers to Windows 98 as being "Windows 4.10". You are literally the first. So maybe instead of trying to sound cool or official by using version numbers, you should just use the actual product name. By the way, Windows 9x was never available in a 64-bit build, so is it actually legitimate for me to submit an entry that runs only on Windows 98 and just returns "32"? Seems very unfair/unsporting/uninteresting, but would technically be allowed by your rules. – Cody Gray Jun 21 '17 at 2:25
• You still haven't answered the question about the Windows version. Does must be able to run on Windows 4.10 or newer mean on Windows 4.10 and all newer versions or on any single Windows version, 4.10 or newer? – Dennis Jun 21 '17 at 3:08

# x86 Assembly (polyglot), 13 bytes

Bytecode:

31 c0 b4 80 48 70 05 04 40 83 e0 60 c3

Defines a function which returns 32 if interpreted as 32-bit, 64 if 64-bit, and 32767 if 16-bit.

I wanted to make a polyglot which ran on Windows and Linux, but this is a lot harder than I thought. As it is I'm not sure there's even any way to print a value on non-16-bit Windows without linking.

## Explanation

This code uses two tells to determine the architecture it is running on. The first is the instruction 0x48—on 16 and 32 bits, this is dec %eax, but on 64 bits, it is an instruction-size prefix. The second tell is the same instruction, however, when we execute it on the value 0x8000, the most significant bit is flipped only if the register size is 16 bits, setting the overflow flag and letting us use jo.

In 16 bits, this code is interpreted as the following:

0:   31 c0                   xor    %ax,%ax    /* 0x0000 */
2:   b4 80                   mov    $0x80,%ah /* 0x8000 */ 4: 48 dec %ax /* 0x7fff */ 5: 70 05 jo c /* taken */ 7: 04 40 add$0x40,%al
9:   83 e0 60                and    $0x60,%ax c: c3 ret /* 0x7fff */ In 32 bits, this code is interpreted as the following: 0: 31 c0 xor %eax,%eax /* 0x00000000 */ 2: b4 80 mov$0x80,%ah   /* 0x00008000 */
4:   48                      dec    %eax        /* 0x00007fff */
5:   70 05                   jo c               /* not taken  */
7:   04 40                   add    $0x40,%al /* 0x00007f3f */ 9: 83 e0 60 and$0x60,%eax  /* 0x00000020 */
c:   c3                      ret

In 64 bits, this code is interpreted as the following:

0:   31 c0                   xor    %eax,%eax   /* 0x00000000 */
2:   b4 80                   mov    $0x80,%ah /* 0x00008000 */ 4: 48 70 05 rex.W jo c /* not taken */ 7: 04 40 add$0x40,%al   /* 0x00008040 */
9:   83 e0 60                and    $0x60,%eax /* 0x00000040 */ c: c3 ret • This is actually probably in the lead, very nice – tuskiomi Jun 21 '17 at 16:36 • A very neat idea, but as implemented, this will return the wrong value if assembled as a 32-bit binary and run on a 64-bit operating system. – Cody Gray Jun 21 '17 at 17:26 • @CodyGray from the rules: You can assume that users will use 64 bit software whenever possible. I suppose this also means that for functions we can assume that the caller code is 64 bit whenever possible. – Ruslan Jun 22 '17 at 19:30 • Ah, I suppose that's a fair interpretation, @Ruslan. And I see you have already posted the answer I had in mind, were it not for this issue. :-) You've got my upvote. – Cody Gray Jun 23 '17 at 6:22 • does the byte 48 represent dec %eax in 16-bit mode? – phuclv Jun 24 '17 at 13:50 # x86 machine code, 12 bytes 8c c8 83 f8 23 b0 20 75 02 00 c0 c3 Ungolfed: getKernelBitness: mov eax,cs cmp eax,0x23 ; 32 bit process on 64 bit kernel has this selector in CS mov al,32 jne kernelIs32Bit add al,al ; return value in eax kernelIs32Bit: ret This function works in Linux when used in ELF32, following i386 SysV ABI, as well as in Windows/Wine when used in PE32, following stdcall calling convention. • Actually one can reduce byte count even more if following another approach. – Ruslan Jun 22 '17 at 15:41 • what would this theoretically do in a non 32/64 bit environment? – tuskiomi Jun 26 '17 at 13:35 • @tuskiomi In any case, this code will still return either 32 or 64. The only difference of interpreting this byte sequence in 16-bit mode will be a change of mnemonics from eax to ax. So, if the selector in cs happens to be 0x23, the result will be 64, otherwise 32. – Ruslan Jun 26 '17 at 13:44 • this looks specific to two particular operating-systems, though. You could easily have a 32-bit system with cs=0x23. See instead my 8-byte answer that targets the CPU instead. – peter ferrie Nov 11 '17 at 23:51 • @peterferrie yeah, that's why I have another answer. But yours does outgolf it by 2 bytes. – Ruslan Nov 12 '17 at 6:47 # Mathematica, 17 bytes$SystemWordLength
• Of course there's a builtin! \s (+1) – tuskiomi Jun 19 '17 at 20:35
• Shouldn't you either add an & or specify that this is in the REPL? – LegionMammal978 Jun 19 '17 at 20:48
• @LegionMammal978 "If the code is ran on a 32-bit operating system, print "32", if the code is ran on a 64 bit operating system, output "64". Print any (other) non-empty string of alphanumeric characters if it's neither." Not "provide a function that, when run, does this"; just "do this". – Patrick Stevens Jun 19 '17 at 21:41
• @PatrickStevens: If the question doesn't specify what form a submission should take, it's a program or function, but not a snippet, by default. – user62131 Jun 19 '17 at 22:16
• @ais523 I would argue there is no distinction in Mathematica between programs, functions, and snippets. Everything is just an expression. – ngenisis Jun 21 '17 at 16:05

Did you know that GRUB and IPXE both have Turing complete programming languages accessible at run-time? The Syslinux family of boot loaders don't but they can do this.

## IPXE, 36 bytes

#!ipxe
cpuid --ext 29 && echo 64 || echo 32

the first line is needed if the script is run remotely, but not if typed directly at the command line.

## GRUB, 42 bytes

if cpuid -l ; then
echo 64
else
echo 32
fi

## Syslinux, 186 bytes

This takes three files the first is syslinux.cfg (or isolinux.cfg, etc.).

label a
kernel ifcpu64.c32
append s -- t

label s
append s.cfg

label t
append t.cfg

default a
prompt 0
timeout 0

and t.cfg

ans s.cfg

For this one the hard part is that syslinux does not have any simple text display capabilities, so the menu is abused.

• I'm not sure if you can tell the os resolution with a boot loader, but i like the idea – tuskiomi Jun 20 '17 at 22:13
• It checks the cpu and is used to select the right operating system. This is basically golfed code from my unboot project. – hildred Jun 20 '17 at 22:17
• So it changes the os based on the architecture. Thinking outside the box. I like. – tuskiomi Jun 20 '17 at 22:18
• What's the bytecount? – Restioson Jun 22 '17 at 15:45
• @hildred I believe it would be more readable if you used ## iPXE, 36 bytes instead of ### ipxe 36 – NieDzejkob Jun 22 '17 at 16:45

## Julia 14 13 bytes

n->8sizeof(1)

Explain:

• Anon function, taking anything (including nothing) returning an integer 32, or 64
• Integer literals are of type Int which depending if 32 bit or 64 bit, is either an Int32 or an Int64 (the 1 could be any digit)
• placing a number before a function call does a juxtaposition multiplication
• This is basically a minified version of the code for Sys.WORD_SIZE, used in rahnema1's answer

Other fun answer is ()->"$(Int)"[4:5], but I can't get the count down on that one. -1 thanks to @Roman Gräf # julia, 2017 16 bytes n->Sys.WORD_SIZE *Thanks to @LyndonWhite saved 3 bytes *Thanks to @RomanGräf saved a byte Previous answers: ()->Sys.WORD_SIZE print(Sys.WORD_SIZE) Try it online! ## JavaScript (Node.js), 24 bytes _=>process.arch.slice(1) This is a function and returns '32', '64', or if neither 'rm'. • +1, but I suppose a 64bit arch could be running a 32bit OS though – Octopus Jun 19 '17 at 22:35 • Gives me '32' on 32-bit Windows, so it does appear to work. – Ken Y-N Jun 20 '17 at 6:16 • You can shave off 7 bytes if you're using the REPL and os instead of process: os.arch().slice(1) – GilZ Jun 20 '17 at 10:21 • This returns the OS architecture reported to the process, not the actual OS architecture. So this does not work on Linux. (Punch "setarch" into your favorite search engine.) – David Schwartz Jun 21 '17 at 23:24 • @DavidSchwartz it works fine on my linux box unless I'm misunderstanding, but on PPCG we can assume an unmodified environment in terms of user changing the arch – Downgoat Jun 22 '17 at 0:06 # C, 333129 23 bytes f(){return sizeof&f*8;} Thanks to commenters @ceilingcat and @Dennis for golfing tips! • It also says that the usual code golf rules apply, and returning from a function is part of our defaults for I/O. – Dennis Jun 19 '17 at 21:42 • Isn't that going to depend on whether you compile as a 32 or 64 bit program? – Ken Y-N Jun 20 '17 at 4:35 • This doesn't comply with the requirements. "Please note that a 32 bit program running on a computer with a 64 bit operating system should output "64"." This tells you how the program was compiled, not what the OS is. – David Schwartz Jun 21 '17 at 23:24 • @DavidSchwartz "You can assume that users will use 64 bit software whenever possible." – Klas Lindbäck Jun 22 '17 at 12:16 • Sorry to say that but sizeof is evaluated at compile time. So if you compile a 32 bit exe and run it on a 64 bit machine, it will ouput 32 while it should output 64 (stackoverflow.com/questions/2615203/…). Nice idea though ! – Dinaiz Jun 23 '17 at 1:14 ## PowerShell, 16 bytes 8*[IntPtr]::Size Gets the pointer size in bytes, multiplies by 8 to get bits. • -1 because your code must be able to run on Windows 4.10 or newer – ub3rst4r Jun 20 '17 at 5:06 • @ub3rst4r or newer, not and newer. I'm willing to bet a good chunk of these answers are difficult, at best, to run on a long-unsupported version of Windows. It's also unreasonable to expect people to test on 98 of all OSes - it's not even easy to install in a VM these days (trust me, I've tried. Not gonna run on KVM, and it has interesting interactions with VBox display adapters). (Nor does it even have a concept of 64-bit... that's a truly ridiculous requirement.) – Bob Jun 20 '17 at 6:37 • @ub3rst4r I doubt that all of the interpreted programming languages here have an implementation working on Windows 4.10! – Martin Rosenau Jun 20 '17 at 8:51 • This looks like it fails if it's a 32-bit powershell on a 64-bit OS. – Chris J Jun 21 '17 at 9:28 • @ChrisJ At least on Win10 and Win2012 R2 it returns the proper result from x86 PowerShell. Haven't tested on Linux. – Booga Roo Jun 21 '17 at 18:29 ## Python 2, 52, 48, 42 41 bytes from struct import*;print calcsize("P")*8 Thanks to totallyhuman! • zoom! across the line in under a minute. – tuskiomi Jun 19 '17 at 20:16 • I'm going to hold off on testing this until i'm home, but i'm not sure this prints out "32" and "64", but other cases i'm confident. – tuskiomi Jun 19 '17 at 20:21 • @tuskiomi, this prints "32bit" or "64bit" – Daniel Jun 19 '17 at 20:21 • from struct import*;print calcsize("P")*8 is shorter. – totallyhuman Jun 19 '17 at 20:42 • If you run this on 32-bit Python in a 64-bit OS, I think this will lie to you. Most other answers also seem sensitive to that anyways... – Nick T Jun 19 '17 at 22:02 ## Java 8, 45 bytes ()->System.getProperty("sun.arch.data.model") • @Dopapp What (s)he means is that this is a snippet, not a program or function. In Java 8, this should work: n=>System.getProperty("os.arch") – NoOneIsHere Jun 19 '17 at 20:25 • @NoOneIsHere, oh thank you that went way over my head – Daniel Jun 19 '17 at 20:26 • "If the code is ran on a 32-bit operating system, print "32", if the code is ran on a 64 bit operating system, output "64". Print any (other) non-empty string of alphanumeric characters if it's neither.". This doesn't do that at all... – Olivier Grégoire Jun 19 '17 at 22:54 • Can you get Java 8 for Windows 98 (v4.10) ? – TessellatingHeckler Jun 20 '17 at 6:11 • @TessellatingHeckler Java 8 requires "i586" (whatever that means). The entry says: "your code must be able to run on Windows 4.10 or newer", not "your code must be able to run on Windows 4.10 and newer". It runs on a Windows newer. – Olivier Grégoire Jun 20 '17 at 7:44 # Perl 6, 17 bytes say$*KERNEL.bits

Try it

There is a related $?BITS which contains the number of bits that a native int has in the runtime. say$?BITS

Try it

# Windows CMD, 56 52 bytes (thanks Bob!)

if EXIST "%ProgramFiles(x86)%" (echo 64)else echo 32

Still surprisingly lengthy - longest so far!

• Actually, %windir%\SysWOW64 is even shorter, I think... – Bob Jun 20 '17 at 5:07
• "must be able to run on Windows 4.10 or newer, and at least one flavor of Linux of your choosing" - which flavour of Linux for this? – TessellatingHeckler Jun 20 '17 at 6:13
• @TessellatingHeckler if you install Wine...? – Ken Y-N Jun 20 '17 at 6:14
• What about using shorthand? if EXIST "c:\Progra~3" (echo 64)else echo 32 By default you have ProgramData and Program Files so if a third exists, we should be 64 – Marie Jun 20 '17 at 20:09
• What will this print for an 8-bit OS? – tuskiomi Jun 21 '17 at 13:43

# C, Win32 API, 103 183 bytes

#include <windows.h>

Actually there are more than 2 cases here. Let's examine them

• The easiest: IsWow64Process does not exist: We are on a 32 bit OS

For the next two cases we need to have the knowledge that our binary will be a 32 bit executable. And this description of what will be out into the out parameter of IsWow64Process

A pointer to a value that is set to TRUE if the process is running under WOW64. If the process is running under 32-bit Windows, the value is set to FALSE. If the process is a 64-bit application running under 64-bit Windows, the value is also set to FALSE.

That leaves us with two additional cases:

• IsWow64Process exists, and yields TRUE -> We are on a 64 bit machine
• IsWow64Process exists, and yields FALSE -> We are on a 32 bit machine

We don't wory about the part where a 64-bit application on a 64-bit Windows yields FALSE. As we know that our application is 32-bit

Oh and there is one additional case that is not covered by this challenge and should be rare anyways:

• IsWow64Process exists, but it fails: We default to 32-bit machine.

This should cover most Windows NT Operating Systems. Have only tested on Win10 64-Bit, Win 7 64-Bit, Win 8.1 32-Bit and WinXP SP1 32-Bit

#include<windows.h>

To be sure we need to distinguish only 2 cases

• IsWow64Process does not exist in kernel32.dll => We are on a 32 bit machine.

• IsWow64Process does exist => We are on a 64 bit machine.

The actual value provided by IsWow64Process is irrelevant for this challange, since we want the binary to be 32bit in any case.

Unlike most of the answers, this doesn't rely on the binary itself being compiled on the machine that it's executed on.

If I knew a shorter function that is present only on 64bit and not 32bit machines, I could shorten the answer.

• Drop the .dll from the module name string. Not only is this good for golfing, but it's actually a better practice in normal use, too. Also, for golfing purposes, you can drop the space after #include. – Cody Gray Jun 20 '17 at 15:00
• Thanks, I actually wanted to reduce the whole thing by just looking for a module that can be found on 64bit but not on 32bit. I'm still looking. Sadly (for this purpose) there is no module called WoW64. – MrPaulch Jun 20 '17 at 15:03
• There is actually a wow64.dll and Wow64Win.dll, but I have never tried to call GetModuleHandle with those. The problem, though, is that they would only be loaded for a 32-bit process running on a 64-bit machine, not for a 64-bit process running on a 64-bit machine. – Cody Gray Jun 20 '17 at 15:05
• I have. They return 0 even on a 64bit machine. Makes sense actually. They don't exist to be linked with directly. The system takes care of the redirection during runtime. – MrPaulch Jun 20 '17 at 15:07
• Ooh, problem though. From the SDK documentation: "Note that this technique is not a reliable way to detect whether the operating system is a 64-bit version of Windows because the Kernel32.dll in current versions of 32-bit Windows also contains this function." – Cody Gray Jun 20 '17 at 15:08

# C#, 60 50 bytes

_=>System.Environment.Is64BitOperatingSystem?64:32

Thanks @TheLethalCoder

• Welcome to the site! :) – James Jun 20 '17 at 6:22
• Save 4 bytes if you remove 'Line' – John Jun 20 '17 at 10:58
• can also remove 'Environment.' and 'console.' assuming use of using static System.Environment; and using static System.Console; – John Jun 20 '17 at 11:00
• also, change WriteLine to Write – Thomas Ayoub Jun 20 '17 at 13:20
• @John Last time I checked, imports must be included and so would add to the byte count – Ceshion Jun 20 '17 at 18:02

# Ruby, 22 bytes

p [?a].pack(?p).size*8

["any string"].pack("p") returns a string whose bytes correspond to the pointer that pointed towards "any string", and is 8 characters if the OS is 64-bit, or 4 characters if the OS is 32-bit.

• Since this is using the pointer size, this will print 32-bit when the Ruby interpreter is a 32-bit binary on a 64-bit OS. So misses a rule. – DarkDust Jun 20 '17 at 11:36
• @DarkDust You can assume that users will use 64 bit software whenever possible. So 64-bit users will be assumed to be running 64-bit Ruby. – Value Ink Jun 20 '17 at 17:12

## R, 16 bytes

.Machine[[18]]*8

Returns the pointer size.

• Like all pointer-size solutions, this will print the wrong result when the program is a 32-bit binary running on a 64-bit OS. – DarkDust Jun 20 '17 at 11:39
• @DarkDust R is interpreted, and we can assume the user uses 64-bit software where possible, so also a 64-bit interpreter. IMHO, the rule only applies to compiled languages – NieDzejkob Jun 22 '17 at 16:39
• @NieDzejkob That is the exact same logic I have used for my answer in PHP when someone else put the same type of comment in response to my answer, I wish others read the same from the question as we have on assuming users will use 64-bit software where possible with interpreted languages. – Bja Jun 24 '17 at 8:03

## Perl, 1815 18 bytes

say length pack p8
• I get 64␤ on my 32 bit computer, because perl was built with a 64bit IV. You'll find this is usually the case when running on 32bit version of Windows. – Brad Gilbert b2gills Jun 20 '17 at 18:39
• @BradGilbertb2gills I reverted the code to the previous version; this one should work even in this case. Let me know if it still doesn’t work, I’ll delete my answer. – Grimmy Jun 20 '17 at 18:54
• That works correctly. – Brad Gilbert b2gills Jun 20 '17 at 19:21
• Seems wrong on HP 9000/785. Gives 32. But I do not think there were any 32-bit HP/PA-RISC CPUs. – Ole Tange Jun 25 '17 at 12:55

# x86 machine code, 8 bytes

31 C0 B0 40 48 24 60 C3

Ungolfed:

31 c0    xor eax,eax
b0 40    mov al, 0x40
48       dec al — in 32-bit mode; "REX.W" in 64-bit mode (ignored)
24 60    and al, 0x60
c3       ret

If compiled as a 64-bit executable, it returns 64 in eax, and if compiled as 32-bit, then returns 32 — regardless of the OS.

This answer relies on the rules saying:

You can assume that users will use 64 bit software whenever possible.

• While this is an interesting approach, how can it be written into a program in such a way that it can actually be executed? Every method I can think of executing binary code other than writing your own loader function uses files that are specific to 64-bit or 32-bit code. Therefore, you'll need two copies of this code in order to actually run... – Jules Jun 24 '17 at 22:48
• @Jules You can put it as inline assembly into a high-level language program, like here. Then you just need to use your platform-native compiler with its default options, and you'll get the bitness. – Ruslan Jun 25 '17 at 5:52
• @l4m2 why do you yell at me? But you're right anyway, these two bytes seem to be some junk left from my experiments. Will remove. – Ruslan Dec 9 '17 at 12:23

# PHP, 18 Bytes

<?=PHP_INT_SIZE*8;

This correctly handles all of the cases of 32, 64 and other bit CPUs provided that PHP_INT_SIZE is correct, it will show the precise size of the CPU no matter what CPU PHP is running on!

If PHP is running on

32-bit OS PHP_INT_SIZE == 4,

64-bit OS PHP_INT_SIZE == 8,

16-bit OS PHP_INT_SIZE == 2 (theoretically)

8-bit OS PHP_INT_SIZE == 1 (again theoretically)

128-bit OS PHP_INT_SIZE == 16 (Not yet achieved but possible)

• that constant has the size of the OS where PHP was built, not run – Einacio Jun 22 '17 at 1:44
• @Einacio Yes, but in the initial challenge the poster wrote "You can assume that users will use 64 bit software whenever possible", Therefore if the OS is 64-bit then the version of PHP running on the OS would have to be assumed to be 64-bit! (Note: I don't see this as a loophole just pure logic based off of the initial challenge.) – Bja Jun 22 '17 at 7:26

C# (29 bytes)

Console.Write(IntPtr.Size*8);
• Like all pointer-size solutions, this will print the wrong result when the program is a 32-bit binary running on a 64-bit OS. – DarkDust Jun 20 '17 at 11:39
• Need to specify that this is compiled for "AnyCPU" with the "Prefer 32-bit" checkbox unchecked. – Cody Gray Jun 23 '17 at 17:00

# PowerShell, 17 52 bytes

try{32+32*((gci \*))-or(arch)[-1]-eq52)}catch{32}

Returns 64 if either of the following is true:

• You have a directory on your current drive with a filename ending in a close paren, the idea being to detect Program Files (x86).
• arch returns a string ending in 4 (ASCII 52), like x86_64, as opposed to e.g. i686.

The try-catch is intended to circumvent the error you get if gci returns nothing and you don't have an arch. I haven't found a shorter way to do it so far. gci is used over ls because on Linux, ls will produce a visible error.

This version should detect whether the OS is 64-bit rather than just PowerShell, and is tested to work on Windows and Linux. For Mac support, replace arch with uname -m.

Previous Windows-only version: -!(ls \*))*32+64

• what linux distro does this run on? – tuskiomi Jun 20 '17 at 18:51
• @tuskiomi Oh, my bad - I see what you mean. Didn't read the challenge properly. Should I delete the answer? – Andy C. Jun 20 '17 at 19:17
• If you know it'll work with WINE, you should keep it. – tuskiomi Jun 20 '17 at 19:20
• @tuskiomi At the very least Ubuntu 14.04, 16.04, RHEL7, CentOS7 and some version of SUSE: github.com/PowerShell/PowerShell/releases – Xudonax Jun 24 '17 at 17:16

# Swift 4 REPL/Playground, 12 bytes

Int.bitWidth

Int is word sized, acting like either Int32 or Int64 depending on the system.

• Isn't this a code-snip it, so it should print? Or does saying you are using the REPL get around that restriction? – Lyndon White Jun 21 '17 at 1:28
• That's up to the judges. The REPL usage isn't very common, but Swift Playgrounds are very popular (especially on iPad). Personally, I think it's fair game. People design custom programming languages for golfing that implicitly print values, and this is no different – Alexander - Reinstate Monica Jun 21 '17 at 5:25

# Ruby, 10 bytes

p 0.size*8

While Ruby can use integers of any length, internally it stores the values that fit in a machine word as Fixnum. The method Fixnum#size always return the length in bytes of a machine word.

The Fixnum class was removed in Ruby 2.4.0, its functionality was included in class Integer. The code stands.

# Shell, 26 bytes

uname -m|awk \\$0=/_/?64:32
• You can use arch instead of uname -m. – Dennis Jun 20 '17 at 6:29
• @Dennis Not necessarily. On macos: uname -m -> x86_64, but arch -> i386. Because macos :( Also, this is bash-specific - fails on zsh. – viraptor Jun 20 '17 at 9:28
• @StevenPenny zsh will try to interpret the ? as a glob / single character wildcard. – Doorknob Jun 20 '17 at 12:43
• Does this run on Windows? – Ajasja Jun 20 '17 at 15:03
• @Ajasja with Cygwin – Steven Penny Jun 20 '17 at 17:08

# Bash, 25 17 bytes

getconf LONG_BIT

Thanks to Dennis for golfing help.

# C, 22 bytes

f(){return(int**)0+8;}

This is a pointer-size based answer that assumes a native binary. The 0 is cast to int** (address 0x0). Then we add 8 to 0, which, in C advances, the pointer by sizeof(int*)*8. 4 bytes * 8 bits = 32, 8 bytes * 8 bits = 64. So we get (int**)0x20 and 0x40 which are then implicitly cast as integers by returning them from an implicitly int-returning function.

# C, stand-alone, 34 bytes

main(){printf("%d\n",(int**)0+8);}

# C, fun with Unicode, 30 code-points, 34 bytes(UTF-8)

main(){puts((int**)U" ㈳㐶"+1);}
• I've been trying to understand how this works, but I'm clueless. Can you add an explaination? – NieDzejkob Jun 22 '17 at 16:36
• @jbcreix clever... – NieDzejkob Jun 23 '17 at 18:03

# Java, 50 bytes

int b(){return com.sun.jna.Native.POINTER_SIZE*8;}

• Is that a library? If yes, you should mention it! I don't see that class available in the Oracle's JDK 8 though (I don't have my usual JDK 6 and 7 at my disposal, atm). – Olivier Grégoire Jun 19 '17 at 23:01
• This answer is invalid. It doesn't print. – Philipp Jun 20 '17 at 10:42
• Quoting Dennis: > It also says that the usual code golf rules apply, and returning from a function is part of our defaults for I/O. – Asu Jun 20 '17 at 13:02
• Change it into a lamba function for less bytes: ()->com.sun.jna.Native.POINTER_SIZE*8 – Ferrybig Jun 25 '17 at 12:02

# PHP, 29 bytes

<?=@php_uname(m)[-1]-4?32:64;

https://3v4l.org/Y6JXv

• Ooh. I like this one. How does it work? – tuskiomi Jun 20 '17 at 12:09
• php_uname('m') returns x86_64 on a 64 bit OS, otherwise something like i386. 4 being the 6th character (5th 0 indexed) of the string, '4' - 4 == 0 == false. And @ just suppresses warnings for unquoted strings, and uninitialised offsets. – Petah Jun 20 '17 at 12:27
• This detects the architecture of PHP, not of the OS. I'm running 32-bit PHP on a 64-bit Windows, php_uname('m') returns 'i586'. – Gras Double Jun 21 '17 at 3:58
• @GrasDouble well I guess ymmv, I works for me with Windows NT USER-PC 10.0 build 15063 (Windows 10) AMD64. – Petah Jun 21 '17 at 9:13
• @tuskiomi this will print 64 if there is an 8-bit operating system – Bja Jun 21 '17 at 16:33

# Python 3, 778471 59 bytes

-13 bytes, thanks to @JonathanAllan!
Down to 59 by @Clearer

from platform import*;print({'4':64,'6':32}[machine()[-1]])

Try it online!

My fist time code-golfing :)
Should output the correct version even when running 32Bit-Python on 64bit-OS.
Assuming platform.machine() gives i*86 or x86 for 32Bit-OS. I don't have one available to check this. Output is 0 when OS is not in 64/32Bit
Edit: Added print statement, so it got 7 bytes longer

• Not sure if it's acceptable because it is possible to run a 32 bit OS on a 64 bit machine (or to have some machine called a foo86 that is 64 bit :p), but if it is acceptable then you can save 9 (edit ...13!) bytes with print((a==64)*a+32*(a==86)). – Jonathan Allan Jun 20 '17 at 14:03
• from platform import*;print({'4':64,'6':32}[machine()[-1]]) would work too. – Clearer Jun 21 '17 at 10:40
• @Clearer This would miss following constraint: Important: Print any other non-empty string of alphanumeric characters if it's neither 32 or 64 bit.. – tOmAtE Jun 22 '17 at 7:41
• @tOmAtE if it's neither 32 nor 64 bit, it will throw an exception, which prints a non-empty string. – Clearer Jun 22 '17 at 8:04
• Try architecture(), saves the dict: from platform import*;print(architecture()[0][:2]) -> 50 bytes – bugmenot123 Jun 23 '17 at 13:19


text:
# zbMATH — the first resource for mathematics

##### Examples
 Geometry Search for the term Geometry in any field. Queries are case-independent. Funct* Wildcard queries are specified by * (e.g. functions, functorial, etc.). Otherwise the search is exact. "Topological group" Phrases (multi-words) should be set in "straight quotation marks". au: Bourbaki & ti: Algebra Search for author and title. The and-operator & is default and can be omitted. Chebyshev | Tschebyscheff The or-operator | allows to search for Chebyshev or Tschebyscheff. "Quasi* map*" py: 1989 The resulting documents have publication year 1989. so: Eur* J* Mat* Soc* cc: 14 Search for publications in a particular source with a Mathematics Subject Classification code (cc) in 14. "Partial diff* eq*" ! elliptic The not-operator ! eliminates all results containing the word elliptic. dt: b & au: Hilbert The document type is set to books; alternatively: j for journal articles, a for book articles. py: 2000-2015 cc: (94A | 11T) Number ranges are accepted. Terms can be grouped within (parentheses). la: chinese Find documents in a given language. ISO 639-1 language codes can also be used.

##### Operators
 a & b logic and a | b logic or !ab logic not abc* right wildcard "ab c" phrase (ab c) parentheses
##### Fields
 any anywhere an internal document identifier au author, editor ai internal author identifier ti title la language so source ab review, abstract py publication year rv reviewer cc MSC code ut uncontrolled term dt document type (j: journal article; b: book; a: book article)
Introduction to black hole physics. (English) Zbl 1234.83001
Oxford: Oxford University Press (ISBN 978-0-19-969229-3/hbk). xvi, 488 p. £ 55.00 (2011).
In general relativity, there are solutions of the field equations (like the Schwarzschild and the Kerr metrics) which represent strong field configurations having the feature that the curvature manifests itself in unusual global properties of space-time. Since the time when J. A. Wheeler and others gave them the name black holes’, more and more relativists considered them as astrophysical objects. Black holes were assumed to be possible end stages of the star development and thus became an object of astrophysical considerations. Wheeler and colleagues had still strong criteria to be imposed on possible physical matter, i.e., on its energy-momentum tensor. These limitations and the fact that the known black hole solutions are singular led them to conclude that there is no such solution of the classical (i.e., not quantized) gravitation field equations. In the hope to arrive at regular classical black hole (and cosmological) solutions, at that time many authors tried to modify Einstein’s gravitational field equations. Now, the situation has changed: mostly, without having developed a quantized general relativity (Quantum Gravity’), one relies on that a future Quantum Gravity will solve the singularity problem such that one can consider the black hole solutions to Einstein’s classical equations as space-times physically interpretable up to the Planck regime. This is also the standpoint of the authors of the present book. They are of the opinion that after 40 years of black hole discussion by relativists and astrophysical discoveries supporting the belief in the existence of black holes (the observation of pulsars is considered to be the beginning of such discoveries), “we cannot imagine our world without black holes”. This is the second comprehensive book by V. P. Frolov on black holes, now co-authored by A. Zelnikov, while its 1998 forerunner was written together with I. D. Novikov [{\it V.P. Frolov} and {\it I.D. Novikov}, Black hole physics. Basic concepts and new developments. Dordrecht: Kluwer Academic Publishers (1998; Zbl 0978.83001)]. The book is based on lectures that Frolov has given at different universities during 30 years. The main part (presented in Chapters 1-8) provides one with material sufficient for a one-term self-consistent course on black holes. After giving a survey over this fast developing area of research, general relativity is prepared by chapters on physics in accelerated reference frames in Minkowski space, Riemannian geometry, and particle motions in curved space-time. Chapter 5 introducing Einstein’s equations and discussing gravitational radiation and gravity in higher-dimensions is followed by three chapters devoted to spherically symmetric and rotating black holes. Besides very informative appendices, in Chapters 9 and 10, the book also contains additional material, e.g., concerning classical and quantum fields near black holes, black holes and higher dimensions, wormholes, and `time machines’. This book is a very good basis for teaching graduate courses on black holes. Moreover, in view of the diversity of considered topics reaching from mathematics over special and general relativity theory to astrophysics, this book deserves a great readership going beyond readers who are particularly interested in black hole physics.

##### MSC:
 83-01 Textbooks (relativity) 83C57 Black holes 83C15 Closed form solutions of equations in general relativity 83F05 Relativistic cosmology 83C35 Gravitational waves 83A05 Special relativity 83C10 Equations of motion 85A40 Cosmology (astronomy and astrophysics) 83C47 Methods of quantum field theory in general relativity 83C75 Space-time singularities, cosmic censorship, etc. 85A15 Galactic and stellar structure 83D05 Relativistic gravitational theories other than Einstein’s


text:
## Analytical questions

Question 1 Show that the univariate ols model $$y_i = \beta x_i + \epsilon_i$$ is identified when $$E(x\epsilon)=0$$ and $$var(x)>0$$.

Question 2 Derive the bias of the sample variance.

## Computer Question

require(kableExtra)
require(ggplot2)
require(texreg)
require(sandwich)
options(knitr.table.format = "html")

Here is some relevant material:

To install these packages

install.packages("lmtest")
install.packages("sandwich")

We are going to reproduce an exercise similar to the example for the computation of standard error. Start by downloading the CPS data from here. We first load the data into R.

# replace this with the path to your download folder
data = data.table(data)
data$age = as.numeric(data$age)

Next generate a fictuous policy that you randomly assigned at the state times gender level. Run the regression and report standard errors given by R for one draw of the poilcy.

set.seed(60356548) # I fix the seed to make sure the draws are reproducible
data <- data[,fp := runif(1)>0.5, statefip]
fit1 = lm(lnwage ~fp,data)
htmlreg(fit1,single.row=TRUE)
Statistical models
Model 1
(Intercept) 2.68 (0.00)***
fpTRUE -0.02 (0.00)**
R2 0.00
Num. obs. 65685
RMSE 0.63
p < 0.001, p < 0.01, p < 0.05

Note We do not control for state specific fixed effect as these would would be perfectly colinear with the policy.

Now this is surprising. We generated fp randomly across states and so we should have that when the number of states becomes very large $$E(\epsilon_i fp_i)=0$$. To gain understanding on what is happening we will generate our own data in a way where we control exactly what is happening.

### IID errors

Let’s start by reassuring ourselves. Let’s use an IID data generating process (DGP), run the regression and check the significance.

1. compute the variance of lnwage in the sample. This is an estimate of our homoskedastic error.
2. simulate a fictuous outcome y2 by adding to fp a normal error with the estimated variance, and truly independent across individuals. Use y2:=rnorm(.N)*var_est inside your data.table data.
3. regress this outcome y2 on fp, our fictuous policy and collect the coefficient, also save if the coefficient is significant at 5%.
4. run steps (2,3) 500 times.

Question 3 Follow the previous steps and report the rejection rate of the test on fp. You should find something close to 5% and you should feel better!

### Heteroskedastic errors

Now we want to compute heteroskedastic robust standard errors which requires us to use some co-variates. We then want to repeat the previous procedure, but we are going to use a different test for the significance. We then want to construct our variance co-variance matrix using the following formula:

$V =(X'X)^{-1} X' \Omega X' (X'X)^{-1}$ where $$\Omega = diag \{ \epsilon_i^2 \}$$. Using vcovHC with type type="const" and type="HC0" will do that for you!

We want to check this by simulating from a model with heteroskedesatic errors. To do so we are going to use linear model for the variance.

1. use the following regression lnwage ~ yrseduc + age + I(age^2) and regress the square of the residual on the same co-variates formula to get an estimate of the heteroskedastic variance.
2. predict the value of the square residual for each individual in the data and store this as new variable s.
3. predict the value of the level and store it in pred.
4. simulate data by drawing a normal, multiplying it by individual specific variancs s and adding the pred.
5. replicate (4) this 500 times, evaluate the significance of fp using vcovHC with type type="const" and type="HC0".

Question 4 Follow the steps and report the rejection rate for each of the variance evaluation.

### State clustered errors

We are again here going to try to simulate corrolated error within state. For this we pick a correlation parameter $$\rho$$. Then, to simulate we are going to draw the first individual in an iid way, then using an auto-regressive structure to compute the error of the following people. Given $$\rho$$ it can be done in the following way:

fit0  = lm(lnwage ~ yrseduc + age + I(age^2),data)
data <- data[,yhat := predict(fit0)]
rho = 0.8
data <- data[, res_hat := {
r = rep(0,.N)
r[1] = rnorm(1)
for (i in 2:.N) {
r[i] = rho*r[i-1] + rnorm(1)
}
r
},statefip]
data <- data[,y2:= yhat + res_hat]
data <- data[,fp := runif(1)>0.5, statefip]
fitn = lm(y2 ~ fp+yrseduc + age + I(age^2),data)
#summary(fitn)

htmlreg(fitn,single.row=TRUE,omit.coef="state")
Statistical models
Model 1
(Intercept) -0.50 (0.09)***
fpTRUE -0.03 (0.01)**
yrseduc 0.10 (0.00)***
age 0.07 (0.00)***
I(age^2) -0.00 (0.00)***
R2 0.04
Num. obs. 65685
RMSE 1.66
p < 0.001, p < 0.01, p < 0.05

Question 5 Explain the expression that starts with data[, res_hat := {...

Question 6 For $$\rho=0.7,0.8,0.9$$ run 500 replications and report the proportion at each value of replication for which the coefficient on our ficutous policy was significant at 5%.

### State level bootstrap

We have not covered this in class yet, but one could instead try to resample the data.

Use the following procedure:

1. Draw 51 states from the 51 states (at the state level) with replacement
2. Create a dataset from the actual data, appending the observations for each of the state
• when a state appears multiple times, attach the data of that state, but treat these states as different. In other words the names of the states in this synthetic data set should just be 1,2,3,4…51.
3. compute the regression on this synthetic data set
4. store the resulting regression coeffecient for each repetition, repeat 500 times.

Note do not redraw fp!

Question 7 Report the 0.05 and 0.095 quantiles for the regression coefficients. This is a test at 10%, does this interval include 0?

Fork me on GitHub


text:
# Can I use the parallax coefficients for observatories as a proxy for latitude using arctan2(sin, cos)?

In How are the three character IAU Minor Planet Center's Observatory Codes assigned? Why are some letters so popular? I looked at the distribution of the first alphanumeric character versus the value of the second two (36 x 100).

The table lists longitudes but no latitudes for these observatories, but using the cos and sin parallax coefficients in $$\arctan2(\sin, \cos)$$ and plotting as a function of tabular longitude produces a map that looks like it could be the distribution of telescopes on Earth.

Question: What exactly are the cos and sin parallax coefficients, and how closely can $$\arctan2(\sin, \cos)$$ be expected to serve as a proxy for latitude? Within a degree or so?

import numpy as np
import matplotlib.pyplot as plt
# blob is the unformatted lines from https://www.minorplanetcenter.net/iau/lists/ObsCodes.html
threes = [line[:3] for line in blob.splitlines()]
key = '0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ'
a = [[x] for x in key]
for t in threes:
a[key.find(t[0])].append(t)
b = np.zeros((36, 100))
for i, thing in enumerate(a):
c = [int(x[1:]) for x in thing[1:]]
for d in c:
b[i, d] = 1
plt.imshow(-b, interpolation='nearest', cmap='gray')
plt.gca().set_aspect(2)
plt.show()
pairs = []
todegs = 180/np.pi
for line in blob.splitlines():
try:
cos, sin = [float(x) for x in (line[13:21], line[21:30])]
lat = todegs * np.arctan2(sin, cos)
lon = float(line[4:13])
pairs.append([lon, lat])
except:
pass
print(len(pairs), len(blob.splitlines()), float(len(pairs))/len(blob.splitlines()) )
lon, lat = np.array(list(zip(*pairs)))
lon = np.mod(lon+180, 360) - 180
plt.figure()
plt.plot(lon, lat, 'ok', markersize=1)
plt.ylim(-90, 90)
plt.xlim(-180, 180)
plt.gca().set_aspect('equal')
plt.show()

• @StephenG -- Right here on this corner of the SE network, there's the question What is 𝜙′ in orbital mechanics? – David Hammen Mar 20 '20 at 10:07
• @DavidHammen I've posted an answer. I think I've got it right, and the answer is about +/- 0.2 degrees. How does it look? – uhoh Mar 22 '20 at 3:09

The title of the question reads:

Can I use the parallax coefficients for observatories as a proxy for latitude using arctan2(sin, cos)?

and the body expands:

Question: What exactly are the cos and sin parallax coefficients, and how closely can $$\arctan2(\sin, \cos)$$ be expected to serve as a proxy for latitude? Within a degree or so?

## First the "How closely can (they) serve as a proxy for latitude?" part

tl;dr: to within +/-0.2 degrees; the range in the differences between geocentric and geodetic latitude.

The table provides the sin and cos of the same angle $$\phi'$$ multiplied by $$r/R_E$$ and the 2nd half of the answer will explain that $$\phi'$$ is the angle that a radius drawn from the observatory to the Geocenter makes with respect to the Earth's equatorial plane. Everyday latitude or GPS latitude which is a kind of geodetic latitude (what I want to use for my map) is a little bit different because it's drawn on an ellipsoid.

How different?

Well it turns out that I wrote an answer about geodetic latitude about 18 months ago. (@DavidHammen wrote a nicer answer elsewhere as well) Here is an excerpt from my answer:

The 3D cartesian coordinates $$X, Y, Z$$ in Earth-centered, Earth-fixed coordinates assuming an ellipsoidal shape is given by:

$$X = \left(N(\phi) + h \right) \cos\phi \cos\lambda$$

$$Y = \left(N(\phi) + h \right) \cos\phi \sin\lambda$$

$$Z = \left(\frac{b^2}{a^2} N(\phi) + h \right) \sin\phi$$

where $$\phi, \lambda, h$$ are latitude, longitude, and altitude, and $$a, b$$ are the equatorial and polar radii of the ellipsoid used, and

$$N(\phi) = \frac{a^2}{\sqrt{a^2\cos^2\phi + b^2 \sin^2\phi}}.$$

Lat, lon, alt in "GPS coordinates} is based on WGS 84 with $$a, b$$ of 6378.1370 and 6356.7523 kilometers, respectively.

The parallax coefficients are $$\rho \cos(\phi')$$ and $$\rho \sin(\phi')$$ and $$\rho$$ is the distance from the observatory to the Geocenter divided by "the Earth radius". That makes them:

$$\rho \cos(\phi') = \frac{\sqrt{X^2+Y^2}}{R_E}$$

$$\rho \sin(\phi') = \frac{Z}{R_E}$$

So if we chose a geodetic latitude $$\phi$$, choose a longitude of zero so that $$Y=0$$ and calculate $$X, Z$$ and plug them into this:

$$\phi' = \arctan2\left(Z, X \right) = \arctan2\left(\frac{Z}{R_E}, \frac{X}{R_E} \right) = \arctan2\left( \rho \sin(\phi'), \rho \cos(\phi') \right)$$

we can get the geocentric latitude, and then calculate the error by subtracting the two.

It turns out to be about +/- 0.2 degrees with extrema at about +/- 45 degrees. It is of course zero at the equator and poles.

So to an error of 0.2 degrees, yes that can indeed be used as a proxy!

## Now the "What exactly are..." part

As pointed out in comments, the link explains how the cos and sin parallax coefficients are defined:

The following list gives the observatory code, longitude (in degrees east of Greenwich) and the parallax constants (rho cos phi' and rho sin phi', where phi' is the geocentric latitude and rho is the geocentric distance in earth radii) for each observatory. It is updated nightly.

What is geocentric latitude? It's the "easy one" to understand; it's just the angle measured at the Geocenter between the radius to the point and the closest point on Earth's equator. So while the definition *does not specify a specific Earth radius, it doesn't have to because the table only gives the unit-less parts cos phi' and sin phi'.

## But why both sin and cos? Can't you just use sin between -90 and +90 degrees?

To just define an angle (without the radius), mathematically you might think so. However sin is insensitive near the poles and in the world of real computing numerical errors can crop up. Near the poles sin will still provide the appropriate sign and cos will provide the sensitivity. This way you will have low numerical errors (for this particular step) everywhere.

But this is the latitude and distance together, so you have to have two numbers. They could be a latitude angle and a radius explicitly, but this also works. (revised per @DH's comment)

## But what are the parallax coefficients for exaclty? What are they really?

I don't know, but hopefully someone with a valid "astronomer's ID card" will come along and post an answer. I'm to scared to ask a new question on this topic given all the comments under the question! :-)

Script for the plot

import numpy as np
import matplotlib.pyplot as plt

halfpi, pi, twopi = [f*np.pi for f in (0.5, 1, 2)]
a, b = 6378.1370, 6356.7523 # only their ratio matters in this case
todegs = 180/pi

phi = np.linspace(-halfpi, halfpi, 101)
h = 0.
lam = 0.
N = a**2 / np.sqrt(a**2 * np.cos(phi)**2 + b**2 * np.sin(phi)**2)
X = (N + h) * np.cos(phi) * np.cos(lam)
Y = (N + h) * np.cos(phi) * np.sin(lam)
Z = ((b/a)**2 * N + h) * np.sin(phi)

phi_prime = np.arctan(Z/X) # two quandrants so no need for arctan2

plt.figure()
plt.plot(todegs*phi, todegs*(phi_prime-phi))
plt.xlabel('geodetic ("GPS") latitude (degs)', fontsize=12)
plt.ylabel('geocentric - geodetic latitude (degs)', fontsize=12)
plt.xlim(-90, 90)
plt.show()

• The parallax coefficients are typically used when applying the topocentric corrections (for a given site on the Earth's surface as opposed to the geocenter). They let you form a 3d vector which can be combined with precession/nutation/frame bias matrix which is what describes the orientation between the celestial coordinate system and the CIO and the terrestrial reference and the TIO. Code examples include find_orb (search for rho_cos_phi) and SOFA cookbook – astrosnapper Mar 20 '20 at 16:25
• @astrosnapper I've fixed this answer and will read those soon, thank you! – uhoh Mar 22 '20 at 3:08
• Re But why both sin and cos? That's the wrong question. The given values are $\rho\cos\phi'$ and $\rho\sin\phi'$, not $\cos\phi'$ and $\sin\phi'$ . The given values encode both radial distance and geocentric latitude. The right question is then why not radial distance and geocentric latitude? I don't know the answer to that question. An even better question is why not altitude and latitude? I don't know the answer to that question, either. (Note well: I used an unqualified "latitude" in my better question. Latitude without a qualifying prefix almost always means geodetic latitude.) – David Hammen Mar 22 '20 at 4:32
• @DavidHammen I see what you mean and have revised accordingly – uhoh Mar 23 '20 at 23:03