text:
There are times in the financial market when a certain asset is traded at a low price but it has huge potential for speculation. Back in 2013 you could buy bitcoins at \$13.50, and by the end of 2017 they were traded at nearly \$20k. When Tesla (TSLA) and Nio (NIO) took off in 2020, their stock prices rallied by 9x and 25x, respectively. In the recent WallStreetBets war with shorting institutions, Gamestop (GME) has had its price skyrocketed because of a short squeeze. The questions is, how can we seize these opportunities and make some profit?

The first trick is to capture the signal and get into the game early, when buying costs are still low. The next problem is when to sell them. No one knows what the peak will be. And to make things worse, when the bubble explodes, the price can drop even faster than it raise, and the asset may become near worthless. Another reason you might want to cash out prematurely is that you want to realize some profit, so that you can maximize expected utility or have something to brag about. A natural way to achieve this is to sell with a designed cadence: when the price rises to this number, sell this amount; when the price rises to that number, sell that amount; and so on.

Now, I will introduce an important pattern of thinking: exponential thinking. It may be tempting to set selling limits with a uniform interval: \$10, \$20, \$30, \$40, … But notice: it is easier to gain \$10 for a \$20 stock than for a \$10 stock; the first one needs only go up by 50%, whereas the latter needs 100%. If you set price limits as an arithmetic sequence like the aforementioned one, you may need to trade more and more frequently, and end up selling more at lower prices. The potential gain is proportional to the current value of the stock, and therefore, by basic calculus, we should think of prices against an exponential curve. That’s why we should set the price limits as a geometric sequence: e.g. \$10, \$20, \$40, \$80, … (More on exponential thinking: Benford’s Law) Like physicists, we setup the problem as an ideal model. For simplicity, assume that we bought 1 share of stock at price \$1. Trading fractional shares is allowed. The stock will keep rising until it hits \M$per share ($M$is unknown to us), after which it will become worthless. Our goal is to maximize the revenue. Here’s our strategy, in formal language. We choose parameters$p > 1, 0 < s < 1$. Whenever the price multiplies by$p$, we sell some shares. The number of shares sold each time is$s$times the number sold in the previous time. When the price rises to … Sell … shares$pa_0 sp^2a_0 s^2p^3a_0 s^3p^ka_0 s^k$Apparently we need to make the total number of shares sold add up to 1, which yields$a_0 = \frac{1 - s}{s}$. If the price peaks at$M \in [p^n, p^{n+1})$, our revenue will be $R = (1-s) p \frac{(s p)^n - 1}{s p - 1}$ Let’s look at some examples. Let$p = 2$and$s = 1/2$. At price \$2 we sell 1/2 shares and earn \$1. There we will break even. Then at price \$4 we sell 1/4 shares and earn another \$1. At price \$8 we sell 1/8 shares and earn another \$1. Note that our total revenue is unbounded, but only grows linearly as price rises exponentially. This time we keep$p = 2$and let$s = 1/3$. At price \$2 we sell 2/3 shares and earn \$4/3. At price \$4 we sell 2/9 shares and earn \$8/9. Note that we earned less in the second round. Then at price \$8 we sell 2/27 shares and earn \$16/27, which is even less. Our earnings per round is a decreasing geometric sequence, and our total revenue is capped at \$4. This is bad – we capped our gain at 4x, while the stock might rocket to 1000x!

Let’s still keep $p = 2$ and let $s = 2/3$. Things are totally different this time. At price \$2 we sell 1/3 shares and earn \$2/3. At price \$4 we sell 2/9 shares and earn \$8/9. Note that we earned more in the second round! Then at price \$8 we sell 4/27 shares and earn \$32/37, which is even more. Our earnings per round becomes an increasing geometric sequence, and our total revenue is unlimited! Yet the story does not end here – as price rises exponentially, our total revenue also grows exponentially (although still slower than price). Although we started out earning slower (in the first rounds), we unlocked unlimited potential!

To study the root cause of this behavior we go back to the revenue formula. It converges when $p s < 1$, and diverges when $p s > 1$. Our two last examples confirm this. So to make unbounded revenue, you just need to set $p s > 1$, have faith, and have a little bit of patience.

To further analyze the impact of selection of $p$ and $s$, let’s look at the revenues in the following scenarios: $(p = 2, s = 2/3)$, $(p = 4, s = 2/3)$, $(p = 4, s = 1/3)$

$M$ $R(p = 2, s = 2/3)$ $R(p = 4, s = 2/3)$ $R(p = 4, s = 1/3)$
[2, 4) 0.6667
[4, 8) 1.556 1.333 2.667
[8, 16) 2.741
[16, 32) 4.321 4.889 6.222
[32, 64) 6.428
[64, 128) 9.237 14.37 10.96
[128, 256) 12.98
[256, 512) 17.98 39.65 17.28
[512, 1024) 24.64

Comparing the first two columns tells us what happens when we vary $p$. A lower $p$ yields better revenue at the low multiplier range, while a higher $p$ yields better revenue at the high multiplier range. So if we predict a high $M$, we should use larger $p$. Comparing the last two columns tells us what happens when we vary $s$. A lower $s$ means we sell more aggresively at the beginning, and yields better revenue at the low multiplier range. In contrast, a higher $s$ saves more shares to the long run, and yields better revenue at the high multipler range. So if we predict a high $M$, we should use larger $s$.

If you are looking for a good parameter setting that gives you at least $\sqrt{M}$ revenue, use the golden ratio! Set $p = \phi^2 = 2.618, s = \bar{\phi} = 0.618$. The action table is

When the price rises to … Sell … shares Earn … Revenue
$\phi^2 = 2.618$ $\bar{\phi}^2 = 0.3820$ $\phi^0 = 1.0$ $\phi^2 - \phi = 1.0$
$\phi^4 = 6.854$ $\bar{\phi}^3 = 0.2361$ $\phi^1 = 1.618$ $\phi^3 - \phi = 2.618$
$\phi^6 = 17.94$ $\bar{\phi}^4 = 0.1459$ $\phi^2 = 2.618$ $\phi^4 - \phi = 5.236$
$\phi^8 = 46.98$ $\bar{\phi}^5 = 0.09017$ $\phi^3 = 4.236$ $\phi^5 - \phi = 9.472$
$\phi^{10} = 123.0$ $\bar{\phi}^6 = 0.05573$ $\phi^4 = 6.854$ $\phi^6 - \phi = 16.33$

$\phi^{2k}$ $\bar{\phi}^{k+1}$ $\phi^{k-1}$ $\phi^{k+1} - \phi$

## What is the optimal strategy?

You may wonder, what is the optimal value for $p$ and $s$? First, we need to define what “optimal” is, i.e. we need to set up a metric. For example, we can choose to optimize for expected revenue, that is, to maximize $\mathbb{E}[R]$.

Then we make a few assumptions. Recall that we denote the peak price as a random variable $M$. The exponential thinking principle means that no matter what the current price is, it is equally likely for it to go further up by a certain percentage. For simplicity we work in the logarithm space. Let $m = \ln{M}$, then the principle translates to $\forall m_0, P(m > k m_0) = c \cdot P(m > m_0)$. This is perfectly captured by the exponential distribution, so we assume that $m \sim \text{exp}(\lambda)$. Here $\lambda$ is a parameter based on the nature of the market.

Now we can compute the probability for each value of the revenue.

$n$ $M$ $m$ $P_n$ $R_n$
0 $[1, p)$ $[0, \ln{p})$ $1 - p^{-\lambda}$ 0
1 $[p, p^2)$ $[\ln{p}, 2 \ln{p})$ $p^{-\lambda} - p^{-2 \lambda}$ $(1-s) p$
2 $[p^2, p^3)$ $[2 \ln{p}, 3 \ln{p})$ $p^{-2 \lambda} - p^{-3 \lambda}$ $(1-s) p (1 + sp)$
3 $[p^3, p^4)$ $[3 \ln{p}, 4 \ln{p})$ $p^{-3 \lambda} - p^{-4 \lambda}$ $(1-s) p (1 + sp + (sp)^2)$

$n$ $[p^n, p^{n+1})$ $[n \ln{p}, (n+1) \ln{p})$ $p^{-n \lambda} - p^{-(n+1) \lambda}$ $(1-s) p \sum_{k=0}^{n-1}{(s p)^k}$

### Maximize revenue

Consider setting the metric as the expected revenue, as in the example above. The expected revenue is

$\mathbb{E}[R] = \sum_{n=1}^{\infty}{P_n R_n} = \sum_{n=1}^{\infty}{\Big[(p^{-n \lambda} - p^{-(n+1) \lambda}) \cdot (1-s) p \sum_{k=0}^{n-1}{(s p)^k}\Big]} \\ = (1-s) p \sum_{n=1}^{\infty}{p^{-n \lambda} (s p)^{n-1}} = \frac{(1-s) p^{-\lambda}}{1 - s p^{-\lambda}}$

when $s p^{-\lambda} < 1$. Otherwise, the sum will not converge, and your expected revenue is infinity! But beware that this is meaningless. As we have shown before, increasing $p$ or $s$ will pump unlikely revenue values, while leaving you a higher probability of winning small (or nothing).

On the other hand, if you stay on the converging side, the gradients

$\frac{\partial{\mathbb{E}[R]}}{\partial{p}} = -\frac{\lambda (1-s) p^{-(1-\lambda)}}{(p^\lambda - s)^2} < 0 \\ \frac{\partial{\mathbb{E}[R]}}{\partial{s}} = -\frac{p^{\lambda} - 1}{(p^\lambda - s)^2} < 0$

push $p$ and $s$ to the smallest values possible: $p = 1, s = 0$, which means you should sell all immediately after buying (a.k.a. you should not enter the game at all). This is obviously not a desired strategy, but it is the best we get when $s p^{-\lambda} < 1$. Below is a plot for $\mathbb{E}[R]$ under different $p$ and $s$ (with $\lambda = 2.0$):

### Maximize utility

The exploding expectation in the previous section implies something wrong with that metric. By the law of diminishing marginal utility, the utility we obtain is not proportional, but sub-linear, to the revenue. Instead of maximizing the expected revenue, we might want to maximize the expected utility. Let’s model the utility with $U = \ln{R}$, and out objective becomes maximizing $\mathbb{E}[\ln{R}]$.

Diminishing marginal utility. Source: Economics Help

The expected utility is

$\mathbb{E}[U] = \mathbb{E}[\ln{R}] = \sum_{n=1}^{\infty}{P_n \ln{R_n}} = \sum_{n=1}^{\infty}{(p^{-n \lambda} - p^{-(n+1) \lambda}) \cdot \Big[ \ln{(1-s)} + \ln{p} + \ln{\frac{(s p)^n - 1}{s p - 1}} \Big]} \\ = p^{-\lambda} \Big[ \ln{(1-s)} + \ln{p} \Big] + (1 - p^{-\lambda}) \sum_{n=1}^{\infty}{p^{-n \lambda} \ln{\frac{(s p)^n - 1}{s p - 1}}}$

This cannot be solved analytically, so we look at the plot: (with $\lambda = 0.5$)

This indicates a maxima along $s = 0$, so we plug this in, set $\frac{\partial{\mathbb{E}[\ln{R}]}}{\partial{p}} = 0$, and get $p = e^{1 / \lambda}$. This is a beautiful result: we sell off at $M = e^{1 / \lambda}$, i.e. $m = 1 / \lambda$, which is exactly the mean of the exponential distribution.

The shortcoming of this strategy is that you will only have a 37% chance of making any revenue. And that is based on the premise that your estimation of $\lambda$ is accurate. In the other 63% time you will lose everything.

### Maximize $\mathbb{E}[\frac{R}{M}]$

Another strategy is to maximize the expectation of $\frac{R}{M}$, that is, portion of growth that we realized. The expectation is computed as follows.

$P_n \mathbb{E}_n[\frac{1}{M}] = P_n \mathbb{E}_n[e^{-m}] = \int_{n \ln{p}}^{(n+1) \ln{p}}{e^{-m} \cdot \lambda e^{-\lambda m} dm} = \frac{\lambda}{1 + \lambda} p^{-(1 + \lambda) n} (1 - p^{-(1 + \lambda)}) \\ \mathbb{E}[\frac{R}{M}] = \sum_{n=1}^{\infty}{P_n \mathbb{E}_n[\frac{R}{M}]} = \sum_{n=1}^{\infty}{P_n R_n \mathbb{E}_n[\frac{1}{M}]} = \frac{\lambda}{1 + \lambda} (1 - p^{-(1 + \lambda)}) \frac{(1-s) p}{sp - 1} (\frac{s p^{-\lambda}}{1 - s p^{-\lambda}} - \frac{p^{-(1 + \lambda)}}{1 - p^{-(1 + \lambda)}}) \\ \frac{\partial}{\partial{p}} \mathbb{E}[\frac{R}{M}] \propto -\frac{\lambda (1-s) p^{\lambda - 1}}{(p^\lambda - s)^2} < 0 \\ \frac{\partial}{\partial{s}} \mathbb{E}[\frac{R}{M}] \propto -\frac{p^\lambda - 1}{(p^\lambda - s)^2} < 0$

Again, the gradients push $p$ and $s$ to the smallest values possible: $p = 1, s = 0$, and you shouldn’t have played at all!

### Penalize for variance

We love profit, but we also hate risk. We want to achieve more stable revenue, so we can add a penalty term to our metric that captures the variance. We denote the standard deviation of the revenue as $\sigma[R]$.

$\mathbb{E}[R^2] = \sum_{n=1}^{\infty}{P_n R_n^2} = \frac{(1-s)^2 p^{2 (1 - \lambda)} (p^\lambda + s p)}{(1 - s^2 p^{2 - \lambda}) (1 - s p^{1 - \lambda})} \\ \sigma[R] = \sqrt{\mathbb{E}[R^2] - \mathbb{E}[R]^2} = \frac{(1-s) p^{1 - \lambda}}{1 - s p^{1 - \lambda}} \sqrt{\frac{p^\lambda - 1}{1 - s^2 p^{2 - \lambda}}} = \mathbb{E}[R] \sqrt{\frac{p^\lambda - 1}{1 - s^2 p^{2 - \lambda}}}$

From there we can maximize for something like $(\mathbb{E}[R] - \sigma[R])$. Here’s the plot: (with $\lambda = 0.25$)

We see a maxima at $p = 2.5, s = 0.24$. However, this method is not very robust, as the maxima may degenerate with other choices of $\lambda$, and we will be forced to either sell all when it hits a certain price, or to sell a bit whenever the price makes the slightest move. $\lambda = 0.3$ shows the latter case:

### Mean-Variance Analysis

The idea of mean-variance analysis is to achieve the maximum return for a given level of risk (i.e. variance). Equivalently, we want to minimize the standard deviation for a given expected return. We plot $(\sigma[R] / \mathbb{E}[R])^2$: (with $\lambda = 0.5$)

The red line denotes the optimal $p$ for each value of $\mathbb{E}[R]$. We make the following observation:

• For a given expected return, there is always an optimal $p$ that minimizes risk at this return level. The optimal $p$ increases as return level increases.
• With better return level comes the higher risk, which is in line with common beliefs.

TODO


text:
# work for closed curve x²+y²=1 in the plane z=0

• Jul 5th 2013, 08:25 PM
n22
work for closed curve x²+y²=1 in the plane z=0
Hi I am not sure if i am doing this right.The question im having issues with is in green text.
The text in blue are the other parts of the question(I included it because it may be necessary...but was easy to calculate.)..
F is a force field . F=2xyzi+ (x²z+2y)j+(x²y-2z)k
Calculate ∇xF,and show its conservative.
find potential function Φ for F,
Hence find the work done by F.around the closed curve x²+y²=1 in the plane z=0, transversed in a counterclockwise direction ,starting and ending at the point (1,0,0)
(Clearly this is the base of a cylinder.)
Here is my method :

letting x=costi (α)
y=sintj
since x²+y²=1,y=√1-x² (β)
then subbing (α) into (B)
I got r=sin²ti+cos²tj=1 t ranges from 0 to 2π
then dr=(2sintcost)idt-(2costsint)jdt
• Jul 5th 2013, 08:30 PM
zzephod
Re: work for closed curve x²+y²=1 in the plane z=0
Quote:

Originally Posted by n22
Hi I am not sure if i am doing this right.The question im having issues with is in green text.
The text in blue are the other parts of the question(I included it because it may be necessary...but was easy to calculate.)..
F is a force field . F=2xyzi+ (x²z+2y)j+(x²y-2z)k
Calculate ∇xF,and show its conservative.
find potential function Φ for F,
Hence find the work done by F.around the closed curve x²+y²=1 in the plane z=0, transversed in a counterclockwise direction ,starting and ending at the point (1,0,0)
(Clearly this is the base of a cylinder.)
Here is my method :

letting x=costi (α)
y=sintj
since x²+y²=1,y=√1-x² (β)
then subbing (α) into (B)
I got r=sin²ti+cos²tj=1 t ranges from 0 to 2π
then dr=(2sintcost)idt-(2costsint)jdt

Isn't the work done 0 just because you have a closed curve and a conservative field?

.
• Jul 6th 2013, 11:47 PM
n22
Re: work for closed curve x²+y²=1 in the plane z=0
[QUOTE=zzephod;791883]Isn't the work done 0 just because you have a closed curve and a conservative field?

Hi, yes you are correct.... but what if it were not a closed curve...............then how would one approach this question?
• Jul 7th 2013, 08:24 AM
zzephod
Re: work for closed curve x²+y²=1 in the plane z=0
[QUOTE=n22;791951]
Quote:

Originally Posted by zzephod
Isn't the work done 0 just because you have a closed curve and a conservative field?

Hi, yes you are correct.... but what if it were not a closed curve...............then how would one approach this question?

You use $x=\cos(\theta)$, $y=\sin(\theta)$, $z=0$ and integrate $F(\cos(\theta).\sin(\theta),0)$ with respect to $\theta$ from $\theta=0$ to $2\pi$.

.

format: plain


text:
Integration rules

Let’s know today what is the Integration rules.

integration rules

Similarly, how do you find the integral of an equivalent?

What is integration of 3? Answer: The integral of the given constant expression 3 dx is equal to 3x + c . up to , where C is an arbitrary constant. Let us understand the solution in detail. Now, we know that the indefinite integral of a constant a is ax + C, where C is an arbitrary constant. So, similarly 3 dx = 3x + C.

What are the integration methods? Integration Methods

• Integration by replacement.
• Integration by parts.
• Integration using trigonometric identities.
• integration of a particular function.
• Integration by fractional fraction.

Secondly how do you integrate 2x? What is the formula for the integration of 2x? The formula for the integration of 2x is given, 2x dx = x 2 + c, with the case of the integration constant.

How do you solve integrals with u-substitution?

So why do we use U-replacement? -Substitution essentially reverses the chain rule for derivatives . In other words, it helps us to integrate the overall functions. When finding antiderivatives, we’re basically doing a “reverse differential”. Some cases are very straightforward.

What is the integral of E 2x?

e^2x is the integral of e^2x /2 + c .

What is the integration of the E ax? E . The integral part of x is itself. i.e., E x dx = E x + C. From ax dx = e ax /a+c using integration by substitution.

What is the integral of 2?

So the integral of 2 is 2x + c , where c is a constant. An “S” shaped symbol is used to mean the integral, and dx is written at the end of the words, meaning “with respect to x”. This is the same “dx” that appears in dy/dx.

What are the 4 types of integration? The main types of integration are:

• Backwards vertical integration.
• Collective integration.
• Further vertical integration.
• horizontal integration.

What is the integral of sin2x?

Answer: sin2x dx = −½ cos (2x)+c.

What is the derivative of 2x?

The (most) common antidifferentiation of 2x is x2+c .

How do you know when to use u-replace?

1. U-sub undoes the chain rule. The chain rule always leaves the derivative of the “inside” function multiplied at the end.
2. Use u-sub when you can factor/manipulate the integrand in the multiplication and you see an inner function that is the derivative.
3. Integration by parts is used to undo the product rule.

What is DU DX?

du/dx is the potential energy in the x-direction . Example 1, for a spring system. U = 12kx2. Fx=−dUdx=−kx. Obviously, fx is the restoring force of the spring when it is compressed or stretched, the direction of which is always opposite to the compression or extension.

What is Die DX? A function that represents the rate of change of another function can be said to be the derivative of that function. … we represent the derivative by dy/dx, that is, x . The change in y with respect to . If y(x) is a function, then the derivative is expressed as y'(x).

How do I know when to use u-replace?

1. U-sub undoes the chain rule. The chain rule always leaves the derivative of the “inside” function multiplied at the end.
2. Use u-sub when you can factor/manipulate the integrand in the multiplication and you see an inner function that is the derivative.
3. Integration by parts is used to undo the product rule.

How do you get DU from you?

1 What is the integral of U? The integral of 1u with respect to u is ln(|u|) . Simplify.


text:
Math Help - cyclic function proof..

1. cyclic function proof..

prove that function f(x)=sinx +sinax
is cyclic if and only if "a" is rational
??

2. Originally Posted by transgalactic
prove that function f(x)=sinx +sinax
is cyclic if and only if "a" is rational
??
what is your definition of "cyclic"?

3. cyclic is a function which goes in cycles
like sinx cosx etc..

4. Originally Posted by transgalactic
prove that function f(x)=sinx +sinax
is cyclic [the usual word is "periodic"] if and only if "a" is rational
??
If a is rational, a=m/n, then it's easy to see that f is periodic, with period 2nπ.

It's harder to prove the converse. Suppose that f(x) is periodic. Then $f''(x) = -\sin(x) -a^2\sin(ax)$ will also be periodic, with the same period. But when x=0, f(0)=f''(0)=0. If there is another point, say x=c, at which f(c)=f''(c)=0, and a≠±1, then you should be able to show that sin(c) = sin(ac) = 0. With c≠0, this is only possible if a is rational. But if there is no such point c then f cannot be periodic.

5. you said that if f(0)=f'(0)=f''(0)=0
but when there is another point which gives the same result
then its not periodic
but why should differ +1 and -1

how to use this definition a=m/n of a rational number in this proof
?

6. Originally Posted by Opalg
If a is rational, a=m/n, then it's easy to see that f is periodic, with period 2nπ.

It's harder to prove the converse. Suppose that f(x) is periodic. Then $f''(x) = -\sin(x) -a^2\sin(ax)$ will also be periodic, with the same period. But when x=0, f(0)=f''(0)=0. If there is another point, say x=c, at which f(c)=f''(c)=0, and a≠±1, then you should be able to show that sin(c) = sin(ac) = 0. With c≠0, this is only possible if a is rational. But if there is no such point c then f cannot be periodic.
Question? Maybe I am misremembering but doesnt the period of $\sin(ax)+\sin(bx)$ have something to do with $\text{gcf}(a,b)$ or $\text{gcd}(a,b)$ or something? If so wouldn't that suffice to show that because $a$ is irrational that this doesnt make sense?

7. i dont know how to prove this thing

8. Originally Posted by Opalg
If there is another point, say x=c, at which f(c)=f''(c)=0, and a≠±1, then you should be able to show that sin(c) = sin(ac) = 0. With c≠0, this is only possible if a is rational. But if there is no such point c then f cannot be periodic.
How do you know this?

9. i know that i need to use
the definition that if a number is rational
then it ca be represented by two whole numbers a/b

what to do here?

10. Originally Posted by transgalactic
i know that i need to use
the definition that if a number is rational
then it ca be represented by two whole numbers a/b

what to do here?
See my previous comment (#4 above). If $f(x)=\sin x +\sin ax$ is periodic, with period c, then $\sin c +\sin ac = f(c) = f(0) = 0$. The second derivative $f''(x)=-\sin x - a^2\sin ax$ will also be periodic with period c, and therefore $-\sin c - a^2\sin ac = 0$. Add those two equations together, and you see that $(1-a^2)\sin ac = 0$. Assuming that $1-a^2\ne0$, it follows that $\sin ac=0$. Since $\sin c +\sin ac = 0$, it also follows that $\sin c=0$.

But if $\sin x = 0$ then x must be a multiple of π. Therefore both c and ac are multiples of π, say c=nπ and ac=mπ. Then a=m/n, which is rational.


text:
CGAL 4.12 - Polygon Mesh Processing
Corefinement and Boolean Operations

Functions to corefine triangulated surface meshes and compute triangulated surface meshes of the union, difference and intersection of the bounded volumes.

## Functions

template<class TriangleMesh , class NamedParameters >
bool CGAL::Polygon_mesh_processing::does_bound_a_volume (const TriangleMesh &tm, const NamedParameters &np)
indicates if tm bounds a volume. More...

template<class TriangleMesh , class NamedParameters1 , class NamedParameters2 , class NamedParametersOut >
bool CGAL::Polygon_mesh_processing::corefine_and_compute_union (TriangleMesh &tm1, TriangleMesh &tm2, TriangleMesh &tm_out, const NamedParameters1 &np1, const NamedParameters2 &np2, const NamedParametersOut &np_out)
corefines tm1 and tm2 and puts in tm_out a triangulated surface mesh bounding the union of the volumes bounded by tm1 and tm2. More...

template<class TriangleMesh , class NamedParameters1 , class NamedParameters2 , class NamedParametersOut >
bool CGAL::Polygon_mesh_processing::corefine_and_compute_intersection (TriangleMesh &tm1, TriangleMesh &tm2, TriangleMesh &tm_out, const NamedParameters1 &np1, const NamedParameters2 &np2, const NamedParametersOut &np_out)
corefines tm1 and tm2 and puts in tm_out a triangulated surface mesh bounding the intersection of the volumes bounded by tm1 and tm2. More...

template<class TriangleMesh , class NamedParameters1 , class NamedParameters2 , class NamedParametersOut >
bool CGAL::Polygon_mesh_processing::corefine_and_compute_difference (TriangleMesh &tm1, TriangleMesh &tm2, TriangleMesh &tm_out, const NamedParameters1 &np1, const NamedParameters2 &np2, const NamedParametersOut &np_out)
corefines tm1 and tm2 and puts in tm_out a triangulated surface mesh bounding the volume bounded by tm1 minus the volume bounded by tm2. More...

template<class TriangleMesh , class NamedParameters1 , class NamedParameters2 >
void CGAL::Polygon_mesh_processing::corefine (TriangleMesh &tm1, TriangleMesh &tm2, const NamedParameters1 &np1, const NamedParameters2 &np2, const bool throw_on_self_intersection=false)
corefines tm1 and tm2. More...

template<class OutputIterator , class TriangleMesh , class NamedParameters1 , class NamedParameters2 >
OutputIterator CGAL::Polygon_mesh_processing::surface_intersection (const TriangleMesh &tm1, const TriangleMesh &tm2, OutputIterator polyline_output, const NamedParameters1 &np1, const NamedParameters2 &np2, const bool throw_on_self_intersection=false)
computes the intersection of triangles of tm1 and tm2. More...

## ◆ corefine()

template<class TriangleMesh , class NamedParameters1 , class NamedParameters2 >
 void CGAL::Polygon_mesh_processing::corefine ( TriangleMesh & tm1, TriangleMesh & tm2, const NamedParameters1 & np1, const NamedParameters2 & np2, const bool throw_on_self_intersection = false )

#include <CGAL/Polygon_mesh_processing/corefinement.h>

corefines tm1 and tm2.

For each input triangulated surface mesh, if a constrained edge is provided, intersection edges will be marked as constrained. If an edge that was marked as constrained is split, its sub-edges will be marked as constrained as well.

Precondition
!CGAL::Polygon_mesh_processing::does_self_intersect(tm1)
!CGAL::Polygon_mesh_processing::does_self_intersect(tm2)
Template Parameters
 TriangleMesh a model of MutableFaceGraph, HalfedgeListGraph and FaceListGraph NamedParameters1 a sequence of Named Parameters NamedParameters2 a sequence of Named Parameters
Parameters
tm1first input triangulated surface mesh
tm2second input triangulated surface mesh
np1optional sequence of Named Parameters among the ones listed below
np2optional sequence of Named Parameters among the ones listed below
throw_on_self_intersectionif true, for each input triangle mesh, the set of triangles closed to the intersection of tm1 and tm2 will be checked for self-intersection and CGAL::Corefinement::Self_intersection_exception will be thrown if at least one is found.
Named Parameters
 vertex_point_map the property map with the points associated to the vertices of tm1 (tm2). If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available in TriangleMesh edge_is_constrained_map a property map containing the constrained-or-not status of each edge of tm1 (tm2)

## ◆ corefine_and_compute_difference()

template<class TriangleMesh , class NamedParameters1 , class NamedParameters2 , class NamedParametersOut >
 bool CGAL::Polygon_mesh_processing::corefine_and_compute_difference ( TriangleMesh & tm1, TriangleMesh & tm2, TriangleMesh & tm_out, const NamedParameters1 & np1, const NamedParameters2 & np2, const NamedParametersOut & np_out )

#include <CGAL/Polygon_mesh_processing/corefinement.h>

corefines tm1 and tm2 and puts in tm_out a triangulated surface mesh bounding the volume bounded by tm1 minus the volume bounded by tm2.

If tm_out is one of the input surface meshes, it will be updated to contain the output (in-place operation), otherwise the result will be inserted into tm_out without clearing it first.

Precondition
!CGAL::Polygon_mesh_processing::does_self_intersect(tm1)
!CGAL::Polygon_mesh_processing::does_self_intersect(tm2)
CGAL::Polygon_mesh_processing::does_bound_a_volume(tm1)
CGAL::Polygon_mesh_processing::does_bound_a_volume(tm2)
Template Parameters
 TriangleMesh a model of MutableFaceGraph, HalfedgeListGraph and FaceListGraph. If TriangleMesh has an internal property map for CGAL::face_index_t, as a named parameter, then it must be initialized. NamedParameters1 a sequence of Named Parameters NamedParameters2 a sequence of Named Parameters NamedParametersOut a sequence of Named Parameters
Parameters
 tm1 first input triangulated surface mesh tm2 second input triangulated surface mesh tm_out output surface mesh np1 optional sequence of Named Parameters among the ones listed below np2 optional sequence of Named Parameters among the ones listed below
Named Parameters
 vertex_point_map the property map with the points associated to the vertices of tm1 (tm2). If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available in TriangleMesh edge_is_constrained_map a property map containing the constrained-or-not status of each edge of tm1 (tm2). face_index_map a property map containing the index of each face of tm1 (tm2). Note that if the property map is writable, the indices of the faces of tm1 and tm2 will be set after the corefinement is done.
Parameters
 np_out optional sequence of Named Parameters among the ones listed below
Named Parameters
 vertex_point_map the property map with the points associated to the vertices of tm_out. If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available in TriangleMesh edge_is_constrained_map a property map containing the constrained-or-not status of each edge of tm_out. An edge of tm_out is constrained if it is on the intersection of tm1 and tm2, or if the edge corresponds to a constrained edge in tm1 or tm2.
Returns
true if the output surface mesh is manifold and is put into tm_out. If false is returned and if tm_out is one of the input surface meshes, then tm_out is only corefined.
Examples:
Polygon_mesh_processing/corefinement_difference_remeshed.cpp.

## ◆ corefine_and_compute_intersection()

template<class TriangleMesh , class NamedParameters1 , class NamedParameters2 , class NamedParametersOut >
 bool CGAL::Polygon_mesh_processing::corefine_and_compute_intersection ( TriangleMesh & tm1, TriangleMesh & tm2, TriangleMesh & tm_out, const NamedParameters1 & np1, const NamedParameters2 & np2, const NamedParametersOut & np_out )

#include <CGAL/Polygon_mesh_processing/corefinement.h>

corefines tm1 and tm2 and puts in tm_out a triangulated surface mesh bounding the intersection of the volumes bounded by tm1 and tm2.

If tm_out is one of the input surface meshes, it will be updated to contain the output (in-place operation), otherwise the result will be inserted into tm_out without clearing it first.

Precondition
!CGAL::Polygon_mesh_processing::does_self_intersect(tm1)
!CGAL::Polygon_mesh_processing::does_self_intersect(tm2)
CGAL::Polygon_mesh_processing::does_bound_a_volume(tm1)
CGAL::Polygon_mesh_processing::does_bound_a_volume(tm2)
Template Parameters
 TriangleMesh a model of MutableFaceGraph, HalfedgeListGraph and FaceListGraph. If TriangleMesh has an internal property map for CGAL::face_index_t, as a named parameter, then it must be initialized. NamedParameters1 a sequence of Named Parameters NamedParameters2 a sequence of Named Parameters NamedParametersOut a sequence of Named Parameters
Parameters
 tm1 first input triangulated surface mesh tm2 second input triangulated surface mesh tm_out output surface mesh np1 optional sequence of Named Parameters among the ones listed below np2 optional sequence of Named Parameters among the ones listed below
Named Parameters
 vertex_point_map the property map with the points associated to the vertices of tm1 (tm2). If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available in TriangleMesh edge_is_constrained_map a property map containing the constrained-or-not status of each edge of tm1 (tm2). face_index_map a property map containing the index of each face of tm1 (tm2). Note that if the property map is writable, the indices of the faces of tm1 and tm2 will be set after the corefinement is done.
Parameters
 np_out optional sequence of Named Parameters among the ones listed below
Named Parameters
 vertex_point_map the property map with the points associated to the vertices of tm_out. If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available in TriangleMesh edge_is_constrained_map a property map containing the constrained-or-not status of each edge of tm_out. An edge of tm_out is constrained if it is on the intersection of tm1 and tm2, or if the edge corresponds to a constrained edge in tm1 or tm2.
Returns
true if the output surface mesh is manifold and is put into tm_out. If false is returned and if tm_out is one of the input surface meshes, then tm_out is only corefined.
Examples:
Polygon_mesh_processing/corefinement_consecutive_bool_op.cpp.

## ◆ corefine_and_compute_union()

template<class TriangleMesh , class NamedParameters1 , class NamedParameters2 , class NamedParametersOut >
 bool CGAL::Polygon_mesh_processing::corefine_and_compute_union ( TriangleMesh & tm1, TriangleMesh & tm2, TriangleMesh & tm_out, const NamedParameters1 & np1, const NamedParameters2 & np2, const NamedParametersOut & np_out )

#include <CGAL/Polygon_mesh_processing/corefinement.h>

corefines tm1 and tm2 and puts in tm_out a triangulated surface mesh bounding the union of the volumes bounded by tm1 and tm2.

If tm_out is one of the input surface meshes, it will be updated to contain the output (in-place operation), otherwise the result will be inserted into tm_out without clearing it first.

Precondition
!CGAL::Polygon_mesh_processing::does_self_intersect(tm1)
!CGAL::Polygon_mesh_processing::does_self_intersect(tm2)
CGAL::Polygon_mesh_processing::does_bound_a_volume(tm1)
CGAL::Polygon_mesh_processing::does_bound_a_volume(tm2)
Template Parameters
 TriangleMesh a model of MutableFaceGraph, HalfedgeListGraph and FaceListGraph. If TriangleMesh has an internal property map for CGAL::face_index_t, as a named parameter, then it must be initialized. NamedParameters1 a sequence of Named Parameters NamedParameters2 a sequence of Named Parameters NamedParametersOut a sequence of Named Parameters
Parameters
 tm1 first input triangulated surface mesh tm2 second input triangulated surface mesh tm_out output surface mesh np1 optional sequence of Named Parameters among the ones listed below np2 optional sequence of Named Parameters among the ones listed below
Named Parameters
 vertex_point_map the property map with the points associated to the vertices of tm1 (tm2). If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available in TriangleMesh edge_is_constrained_map a property map containing the constrained-or-not status of each edge of tm1 (tm2). face_index_map a property map containing the index of each face of tm1 (tm2). Note that if the property map is writable, the indices of the faces of tm1 and tm2 will be set after the corefinement is done.
Parameters
 np_out optional sequence of Named Parameters among the ones listed below
Named Parameters
 vertex_point_map the property map with the points associated to the vertices of tm_out. If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available in TriangleMesh edge_is_constrained_map a property map containing the constrained-or-not status of each edge of tm_out. An edge of tm_out is constrained if it is on the intersection of tm1 and tm2, or if the edge corresponds to a constrained edge in tm1 or tm2.
Returns
true if the output surface mesh is manifold and is put into tm_out. If false is returned and if tm_out is one of the input surface meshes, then tm_out is only corefined.
Examples:
Polygon_mesh_processing/corefinement_consecutive_bool_op.cpp, and Polygon_mesh_processing/corefinement_mesh_union.cpp.

## ◆ does_bound_a_volume()

template<class TriangleMesh , class NamedParameters >
 bool CGAL::Polygon_mesh_processing::does_bound_a_volume ( const TriangleMesh & tm, const NamedParameters & np )

#include <CGAL/Polygon_mesh_processing/corefinement.h>

indicates if tm bounds a volume.

See Definitions for details.

Template Parameters
 TriangleMesh a model of MutableFaceGraph, HalfedgeListGraph and FaceListGraph. If TriangleMesh has an internal property map for CGAL::face_index_t, as a named parameter, then it must be initialized. NamedParameters a sequence of Named Parameters
Parameters
 tm a closed triangulated surface mesh np optional sequence of Named Parameters among the ones listed below
Precondition
CGAL::is_closed(tm)
Named Parameters
 vertex_point_map the property map with the points associated to the vertices of tm. If this parameter is omitted, an internal property map for CGAL::vertex_point_t should be available in TriangleMesh face_index_map a property map containing the index of each face of tm.
CGAL::Polygon_mesh_processing::orient_to_bound_a_volume()

## ◆ surface_intersection()

template<class OutputIterator , class TriangleMesh , class NamedParameters1 , class NamedParameters2 >
 OutputIterator CGAL::Polygon_mesh_processing::surface_intersection ( const TriangleMesh & tm1, const TriangleMesh & tm2, OutputIterator polyline_output, const NamedParameters1 & np1, const NamedParameters2 & np2, const bool throw_on_self_intersection = false )

#include <CGAL/Polygon_mesh_processing/intersection.h>

computes the intersection of triangles of tm1 and tm2.

The output is a set of polylines with all vertices but endpoints being of degree 2.

Precondition
!CGAL::Polygon_mesh_processing::does_self_intersect(tm1)
!CGAL::Polygon_mesh_processing::does_self_intersect(tm2)
Template Parameters
 TriangleMesh a model of MutableFaceGraph, HalfedgeListGraph and FaceListGraph NamedParameters1 a sequence of Named Parameters NamedParameters2 a sequence of Named Parameters OutputIterator an output iterator in which std::vector of points can be put. The point type is the one from the vertex property map
Parameters
 tm1 first input triangulated surface mesh tm2 second input triangulated surface mesh polyline_output output iterator of polylines. Each polyline will be given as a vector of points throw_on_self_intersection if true, for each input triangle mesh, the set of triangles closed to the intersection of tm1 and tm2 will be checked for self-intersection and CGAL::Corefinement::Self_intersection_exception will be thrown if at least one is found. np1 optional sequence of Named Parameters among the ones listed below np2 optional sequence of Named Parameters among the ones listed below
Named Parameters
 vertex_point_map a property map with the points associated to the vertices of tm1 (tm2). The two property map types must be the same.


text:
# How PyXtal Works¶

PyXtal is a free, open source Python package intended to aid with crystal structure prediction and other purposes of crystal symmetry analysis. It is our aim to make our tools and theory freely available, in order to expand the knowledge and utilization of crystallographic symmetry. To this end, we outline the basic algorithms used by PyXtal. For more general information about crystallography, see the Background and Theory page.

## Overview¶

In order to generate random symmetrical crystals, PyXtal uses space groups and their Wyckoff positions as templates, then inserts atoms (or molecules) one Wyckoff position at a time, until the desired stoichiometry is reached. This ensures that the correct symmetry will be obtained, without the need to adjust atomic positions. Along the way, it checks that the atoms are sufficiently far apart. To generate a single random crystal, PyXtal performs roughly seven steps:

PyXtal Structure Generation Flowchart.

1. Get the input parameters from the user.
2. Check the compatibility of the stoichiometry with the space group.
1. Generate a random lattice consistent with the space group.
1. Begin placing atoms into Wyckoff positions, one atomic specie at a time.
1. Check that the atoms in the single Wyckoff position are not too close together. If the minimum distance is smaller than some tolerance (based on the atomic species), then we merge the Wyckoff position into a smaller special position.
1. Check the inter-atomic distance between the newly generated Wyckoff position and the previously generated positions. If the distances are too close, we choose a new generating point within the same original Wyckoff position. For molecular crystals, we also attempt to reorient the molecule, so as to reduce the distance between atoms.
2. Continue to place Wyckoff positions and species into the crystal, until the proper stoichiometry is reached. If any step between 3-6 fails, we repeat it, up to a pre-determined maximum number of attempts.

If the generation succeeds, the resulting crystal can be (energetically) optimized and compared with other possible structures. After many attempts, the lowest-energy structure will be the one most likely to exist at the specified conditions. This can be used, for example, to determine the phase diagram of a solid without the need to perform any experiments.

Next, we explain the steps listed above in greater detail.

## User Input¶

This includes the crystal’s stoichiometry, space group, and volume factor. Optionally, the desired lattice and allowed inter-atomic distances can also be defined (which is useful for testing at higher pressures). Otherwise, these parameters will be chosen automatically.

## Checking Compatibility¶

Before attempting to generate a structure, PyXtal must make sure it is possible to do so. The WP’s in different space groups have different multiplicities. As a result, not every number of atoms is compatible with every space group. For example, consider the space group Pn-3n (222).

\$ pyxtal_symmetry -s 222

-- Space group # 222 (Pn-3n)--
48i site symm: 1
...
...
...
6b site symm: 42 . 2
3/4, 1/4, 1/4
1/4, 3/4, 1/4
1/4, 1/4, 3/4
1/4, 3/4, 3/4
3/4, 1/4, 3/4
3/4, 3/4, 1/4
2a site symm: 4 3 2
1/4, 1/4, 1/4
3/4, 3/4, 3/4

The smallest Wyckoff position is 2a, with the next smallest being 6b. It is impossible to create a crystal with 4 atoms in the unit cell for this symmetry group, because no combination of Wyckoff positions adds up to 4. The position 2a cannot be repeated, because it falls on the exact coordinates (1/4, 1/4, 1/4) and (3/4, 3/4, 3/4). A second set of atoms in the 2a position would overlap the atoms in the first position, but this is not physically possible.

Thus, it is necessary to check the input stoichiometry against the Wyckoff positions of the desired space group. To accomplish this, PyXtal iterates through all possible Wyckoff position combinations within the confines of the stoichiometry. As soon as one valid combination is found, the check returns True. If no valid combination is found, the check returns False, and the generation attempt fails with a warning.

Some space groups allow valid combinations of WP’s, but may not give many degrees of freedom for generation. It may also be the case that the allowed combinations result in atoms which are too close together. In these cases, PyXtal will attempt generation as usual: until the maximum limit is reached, or until a successful generation occurs. If generation repeatedly fails for a given combination of space group and stoichiometry, the user should make note and avoid the combination going forward.

## Lattice Generation¶

The first step in PyXtal’s structure generation is the choice of unit cell. Depending on the symmetry group, a specific type of lattice must be generated. For all crystals, the conventional cell choice is used to avoid ambiguity. The most general case is the triclinic cell, from which other cell types can be obtained by applying various constraints.

To generate a triclinic cell, 3 real numbers are randomly chosen (using a Gaussian distribution centered at 0) as the off-diagonal values for a 3x3 shear matrix. Treating this matrix as a cell matrix, one obtains 3 lattice angles. For the lattice vector lengths, a random 3-vector between (0, 0, 0) and (1, 1, 1) is chosen (using a Gaussian distribution centered at (0.5, 0.5, 0.5)). The relative values of the x, y, and z coordinates are used for a, b, and c respectively, and scaled based on the required volume.

For other cell types, any free parameters are obtained using the same methods as for the triclinic case, along with any necessary constraints. In the tetragonal case, for example, all angles must be 90 degrees. Thus, only a random vector is needed to generate the lattice constants.

For molecular crystals, the issue of generating the lattice is also dependent on molecular orientation. Thus, the lattice must be checked for every molecule in the crystal. To do this, the atoms in the original molecule are checked against the atoms in periodically translated copies of the molecule. Here, standard atom-atom distance checking is used.

## Generation of Wyckoff Positions¶

The central building block for crystals in PyXtal is the Wyckoff position (WP). Once a space group and lattice are chosen, WP’s are inserted one at a time to add structure.

PyXtal starts with the largest available WP, which is the general position of the space group. If the number of atoms required is equal to or greater than the size of the general position, the algorithm proceeds. If fewer atoms are needed, the next largest WP (or set of WP’s) is chosen, in order of descending multiplicity. This is done to ensure that larger positions are preferred over smaller ones; this reflects the greater prevalence of larger multiplicities both statistically and in nature.

## Checking Inter-atomic Distances¶

To produce structures with realistic bonds and bond lengths, the generated atoms should not be too close together. In PyXtal this means that by default, two atoms should be no closer than the covalent bond length between them. However, for a given application the user may decide that shorter or longer cutoff distances are appropriate. For this reason, PyXtal has a custom tolerance matrix class which allows the user to define the distances allowed between any two types of atoms.

Because crystals have periodic symmetry, any point in a crystal actually corresponds to an infinite lattice of points. Likewise, any separation vector between two points actually corresponds to an infinite number of separation vectors. For the purposes of distance checking, only the shortest of these vectors are relevant. When a lattice is non-Euclidean, the problem of finding shortest distances with periodic boundary conditions is non-trivial, and the general solution can be computationally expensive cite{LatticeProblem}. So instead, an approximate solution is used based on assumptions about the lattice geometry:

For any two given points, PyXtal first considers only the separation vector which lies within the central unit cell spanning between (0, 0, 0) and (1, 1, 1). For example, if the original two (fractional) points are (-8.1, 5.2, -4.8) and (2.7, -7.4, 9.3), one can directly obtain the separation vector (-10.8, 12.6, -14.1). This is then translated to the vector (0.2, 0.6, 0.9), which lies within the central unit cell. PyXtal also considers those vectors lying within a 3x3x3 supercell centered on the first vector. These would include (1.2, 1.6, 1.9), (-0.8, -0.4, -0.1), (-0.8, 1.6, 0.9), etc. This gives a total of 27 separation vectors to consider. After converting to absolute coordinates, one can calculate the Euclidean length of each of these vectors and thus find the shortest distance.

Note that this does not work for certain vectors within some highly distorted lattices. Often the shortest Euclidean distance is accompanied by the shortest fractional distance, but whether this is the case or not depends on how distorted the lattice is. However, because all lattices are required to have no angles smaller than 30 degrees or larger than 150 degrees, this is not an issue.

Distorted Unit Cell. Due to the cell’s high level of distortion, the closest neighbors for a single point lie more than two unit cells away. In this case, the closest point to the central point is located two cells to the left and one cell diagonal-up. To find this point using PyXtal’s distance checking method, a 5x5x5 unit cell would be needed. For this reason, a limit is placed on the distortion of randomly generated lattices.

For two given sets of atoms (for example, when cross-checking two WP’s in the same crystal), one can calculate the shortest inter-atomic distances by applying the above procedure for each unique pair of atoms. This only works if it has already been established that both sets on their own satisfy the needed distance requirements.

Thanks to symmetry, it is not necessary to calculate every atomic pair between two Wyckoff positions. For two Wyckoff positions A and B, one need only calculate either the separations between one atom in A and all atoms in B, or one atom in B and all atoms in A. This is because the symmetry operations which duplicate a point in a Wyckoff position also duplicate the separation vectors associated with that point. This is also true for a single Wyckoff position; for example, in a Wyckoff position with 16 points, only 16 calculations are needed, as opposed to 256. This can significantly speed up the calculation for larger Wyckoff positions.

For a single WP, it is necessary to calculate the distances for each unique atom-atom pair, but also for the lattice vectors for each atom by itself. Since the lattice is the same for all atoms in the crystal, this check only needs to be performed on a single atom of each specie. For atomic crystals, this just means ensuring that the generated lattice is sufficiently large.

For molecules, the process is slightly more complicated. Depending on the molecule’s orientation within the lattice, the inter-atomic distances can change. Additionally, one must calculate the distances not just between molecular centers, but between every unique atom-atom pair. This increases the number of needed calculations, in rough proportion to the square of size of the molecules. As a result, this is typically the largest time cost for generation of molecular crystals.

## Merging and Checking Wyckoff Positions¶

Once a WP is chosen, a random 3-vector between (0, 0, 0) and (1, 1, 1) is created. This acts as the generating point. Projecting this vector into the WP, one obtains a set of coordinates in real space. Then, the distances between these coordinates are checked. If the atom-atom distances are all greater than a pre-defined limit, the WP is kept and the algorithm continues. If any of the distances are too small, it is an indication that the WP would not occur with that generating point. In this case, the coordinates are merged together into a smaller WP, if possible. This merging continues until the atoms are no longer too close together (see below).

Wyckoff Position Merging Example. Shown are possible mergings of the general position 8c of the 2D point group 4mm. Moving from 8c to 4b (along the solid arrows) requires a smaller translation than for 4a (along the dashed arrows). Thus, if the atoms in 8c were too close together, PyXtal would merge them into 4b instead of 4a. The atoms could be further merged into position 1o by following the arrows shown in the bottom right image.

To merge into a smaller position, the original generating point is projected into each of the remaining WP’s. The WP with the smallest translation between the original point and the transformed point is chosen, so long as the new WP is a subset of the original one, and so long as the new points are not too close together. If the atoms are still too close together, the WP is discarded and another attempt is made.

Once a satisfactory WP has been filled, the inter-atomic distances between the current WP and the already-added WP’s are checked. If all distances are acceptable, the algorithm continues. More WP’s are then added as needed until the desired number of atoms has been reached. At this point, either a satisfactory structure has been generated, or the generation has failed. If the generation fails, then either smaller distances tolerances or a larger volume factor might increase the chances of success. However, altering these quantities too drastically may result in less realistic crystals. Common sense and system-specific intuition should be applied when adjusting these parameters.

## Finding Valid Molecular Orientations¶

In crystallography, atoms are typically assumed to be point particles with no well-defined orientation. Since the object occupying a crystallographic Wyckoff position is usually an atom, it is further assumed that the object’s symmetry group contains the Wyckoff position’s site symmetry as a subgroup. If this is the case, the only remaining condition for occupation of a Wyckoff position is the location within the unit cell. However, if the object is instead a molecule, then the Wyckoff position compatibility is also determined by orientation and shape.

To handle the general case, one must ensure that the object 1) is sufficiently symmetric, and 2) is oriented such that its symmetry operations are aligned with the Wyckoff site symmetry. The result is that different point group symmetries are compatible with only certain Wyckoff positions. For a given molecule and Wyckoff position, one can find all valid orientations as follows:

1. Determine the molecule’s point group and point group operations. This is currently handled by Pymatgen’s build-in PointGroupAnalyzer class, which produces a list of symmetry operations for the molecule.
2. Associate an axis to every symmetry operation. For now, it can be assumed that the axis is centered at the origin. For a rotation or improper rotation, use the rotational axis. For a mirror plane, use an axis perpendicular to the plane. Note that inversional symmetry does not add any constraints, since the inversion center is always located at the molecule’s center of mass.
3. Find up to two non-collinear axes in the site symmetry and calculate the angle between them. Find all conjugate operations (with the same order and type) in the molecular point symmetry with the same angle between the axes, and store the rotation which maps the pairs of axes onto each other. For example, if the site symmetry were mmm, then choose two reflectional axes, say the x and y axes or the y and z axes. Then, look for two reflection operations in the molecular symmetry group. If the angle between these two operation axes is 90 degrees, store the rotation which maps the two molecular axes onto the Wyckoff axes for every pair of reflections with 90 degrees separating them.
4. For a given pair of axes, there are two rotations which can map one onto the other, with opposite directions of the molecular axis. Depending on the molecular symmetry, these two rotations may produce the same molecular orientation. Using the list of rotations calculated in step 3, remove redundant orientations which are equivalent to each other.
5. For each found orientation, check that the rotated molecule is symmetric under the Wyckoff site symmetry. To do this, simply check the site symmetry operations one at a time by transforming the molecule and checking for equivalence with the untransformed molecule.
6. For the remaining valid rotations, store the rotation matrix and the number of degrees of freedom. If two axes were used to constrain the molecule, then there are no degrees of freedom. If one axis is used, then there is one rotational degree of freedom, and store the axis about which the molecule may rotate. If no axes are used (because there are only point operations in the site symmetry), there are three (stored internally as two) degrees of freedom, meaning the molecule can be rotated freely in 3 dimensions.

PyXtal performs these steps for every Wyckoff position in the symmetry group and stores the nested list of valid orientations. When a molecule must be inserted into a Wyckoff position, an allowed orientation is randomly chosen from the list. This forces the overall symmetry group to be preserved, because symmetry-breaking positions are not allowed.

It is worth noting that the general position of any symmetry group always has site symmetry group 1. This means that any molecule can always be inserted into the general position with any orientation. However, many real crystals have molecules located in special positions, and thus this method alone is insufficient for generating realistic structures [1].

Another important consideration is whether a symmetry group will produce inverted copies of the constituent molecules. In many cases, a chiral molecule’s mirror image will possess different chemical or biological properties cite{chirality}. For pharmaceutical applications in particular, one may not want to consider crystals containing mirror molecules. By default, PyXtal does not generate crystals with mirror copies of chiral molecules. The user can choose to allow inversion if desired.

 [1] ller, “3.2.4. molecular symmetry,”International Tables for Crystallography, vol. A, p.72776, 2016.


text:
# Scipy Butterworth highpass filter results in distortion and bloated output

Trying to use Scipy Butterworth filter to filter frequencies below 54 Hz from audio files. Audio files are stored as WAVs. Sample rate is 44100.

When I try using this filter the result is distorted (very). Also, I assume with fixed time and sample rate that input and output files should be exactly the same size. Input file is 441 Kib, but output is 1.8 Mib. But the duration is unchanged.

Problem is with the filter or with application of the filter. I'm opening and saving WAV files with scipy.io.wavfile and have tested without applying the filter -- what I get out is what I put in, as expected.

Here's my code:

import scipy.io.wavfile
from scipy import signal

# Scipy reads audio data from WAV files
# rate is the sample rate, data is the data
# NOTE: Sample rate of my input is 44100
assert rate == 44100

cutoff = 54  # want this to be 54 Hz
nyquist = 0.5 * rate
normal_cutoff = cutoff / nyquist
order = 5

# https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.butter.html
# Create a filter and return coefficients
b, a = signal.butter(order, normal_cutoff, btype='highpass', analog=True)

# https://docs.scipy.org/doc/scipy/reference/generated/scipy.signal.filtfilt.html
# Apply filter to audio signal
filtered = signal.filtfilt(b, a, data)
scipy.io.wavfile.write('filtered.wav', rate, filtered)

Have also tried filtered = signal.lfilter(b, a, data) for application of filter, and have tried analog=False. Behavior is similar in both cases.

What am I doing wrong? Does this have to do with the sample rate? Bit depth? I'm stuck.

• So I added a note to filtfilt documentation that specifically says "The function sosfiltfilt should be preferred over filtfilt for most filtering tasks" Yet these questions keep being asked. Did you not see this note? docs.scipy.org/doc/scipy/reference/generated/… – endolith Nov 10 '20 at 20:50
• The main problem was that I needed to convert from int to float before filtering. After making that change everything improved. I did miss your note in the documentation however, so thanks for bringing that to my attention. – PartialOrder Nov 11 '20 at 0:00
• Ah, ok. Convert to float using data = data/(2**(bit_depth-1)) – endolith Nov 11 '20 at 0:49

b =
0.98763      -4.9381       9.8763      -9.8763       4.9381     -0.98763
a =
1      -4.9751       9.9007      -9.8515       4.9013     -0.97541

A 5th order highpass at such a low frequency has poles that are very close to the unit circle, so it's vulnerable to numberical problems, especially if you use fixed point data (which almost all wave files are).

Try

1. Convert your data to float or double
2. Run the filters: Design the filter as second order section and use sosfilt(). That's the most stable one.
3. Check your data for overflows & clip after filtering. Handle them gracefully (if you have any)
4. Convert back to fixed point and write output.

5th order at 54 Hz will give you a lot of time domain ringing. Using filtfilt extents that rining to negative time as well (i.e. you get pre-ringing) and makes the filter non causal. You may want to check whether this is a good trade off between time and frequency domain properties for your application.

• +1 , more secure to use needed count of 1st order HP filters rather than one high order HP. When the sample rate gets higher the situation with high order filters would be even worse... – Juha P Nov 10 '20 at 12:41
• int16 -> float64 -> Order 2 HP with SOS -> int16 works quite nicely! – PartialOrder Nov 10 '20 at 17:09

For digital filters, Wn are in the same units as fs. By default, fs is 2 half-cycles/sample, so these are normalized from 0 to 1, where 1 is the Nyquist frequency. (Wn is thus in half-cycles / sample.)

For analog filters, Wn is an angular frequency (e.g. rad/s).

As yours is an analog filter, your Wn parameter is 2π·54Hz

from scipy import constants
...
Wn = 2*constants.pi*54
b, a = signal.butter(order, Wn, btype='highpass', analog=True)


text:
Explore
Placement Prep

Edit

Edit

# TCS Coding Questions and Answers (Latest) | FACE Prep

Published on 07 Mar 2020

TCS coding questions are a must to prepare for the TCS exam. Here all the previously asked TCS coding questions were discussed with the detailed answers. TCS Coding questions are based on the number series and basic programs.

You can also check out these before you start preparing for the coding section

## TCS Coding Question

Numbers series Coding questions are one of the types of question that were asked in the recent TCS 2018 drive. Those coding questions will be of a mixture of two series where odd terms of one kind and the even terms of the other kind. For Example, consider the given series: 1, 2, 1, 3, 2, 5, 3, 7, 5, 11, 8, 13, 13, 17,

This series is a mixture of 2 series all the odd terms in this series form a Fibonacci series and all the even terms are the prime numbers in ascending order. Now write a program to find the Nth term in this series.

The above coding question was asked in the TCS drive 2018 which happened in the month of September 2018.

#include"stdio.h"
#define MAX 1000
voidfibonacci(int n)
{
int i, t1 = 0, t2 = 1, nextTerm;
for (i = 1; i<=n; i++)
{
nextTerm = t1 + t2;
t1 = t2;
t2 = nextTerm;
}
printf("%d", t1);
}
void prime(int n)
{
int i, j, flag, count =0;
for (i=2; i<=MAX; i++)
{
flag = 0;
for (j=2; j<i; j++)
{
if(i%j == 0)
{
flag = 1;
break;
}
}
if (flag == 0)
count++;
if(count == n)
{
printf("%d", i);
break;
}
}
}
int main( )
{
int n;
scanf("%d", &n);
if(n%2 == 1)
fibonacci (n/2 + 1);
else
prime(n/2);
return 0;
}

Input:14

Output:17

## TCS Coding questions Important instructions

### Instructions

1) Only One question, 20 minutes.

2) Choice of C / C++ / Java / Perl / Python 2.7.

3) Provided an IDE to debug.

4) For Java, the class name should be named Maze.

5)The input to the program either through STDIN / Command line arguments, as per the instructions.

6)The program should write the output to STDOUT.

7) Public and private test cases based evaluation.

### Points to note

1) While printing the output no leading or trailing spaces should be printed.

2) Other than the required output, no other text should be printed.

3) If the output is a number, no leading sign must be printed unless it is a negative number.

4) No scientific notation (3.9265E + 2).

5) All floating point numbers must contain that many decimal places as mentioned in the question.

## TCS Coding Questions with Solutions

### TCS Coding question - 1

Consider the following series: 1,1,2,3,4,9,8,27,16,81,32,243,64,729,128,2187

This series is a mixture of 2 series - all the odd terms in this series form a geometric series and all the even terms form yet another geometric series. Write a program to find the Nth term in the series.

The value N is a positive integer that should be read from STDIN. The Nth term that is calculated by the program should be written to STDOUT. Other than the value of the nth term, no other character/string or message should be written to STDOUT. For example, if N=16, the 16th term in the series is 2187, so only value 2187 should be printed to STDOUT. You can assume that N will not exceed 30.

#include"stdio.h"
#include"math.h"
int main()
{
//code
int n;
scanf("%d", &n);
if(n % 2 == 1)
{
int a = 1;
int r = 2;
int term_in_series = (n+1)/2;
int res = pow(2, term_in_series - 1);
printf("%d ", res);
}
else
{
int a = 1;
int r = 3;
int term_in_series = n/2;
int res = pow(3, term_in_series - 1);
printf("%d ", res);
}
return 0;
}

Input: 16

Output: 2187

### TCS Coding Questions - 2

Consider the following series: 0,0,2,1,4,2,6,3,8,4,10,5,12,6,14,7,16,8

This series is a mixture of 2 series all the odd terms in this series form even numbers in ascending order and every even term is derived from the previous term using the formula (x/2).

Write a program to find the nth term in this series.

The value n is a positive integer that should be read from STDIN the nth term that is calculated by the program should be written to STDOUT. Other than the value of the nth term no other characters /strings or message should be written to STDOUT.

For example, if n=10, the 10th term in the series is to be derived from the 9th term in the series. The 9th term is 8 so the 10th term is (8/2)=4. Only the value 4 should be printed to STDOUT. You can assume that the 'n' will not exceed 20,000.

#include "stdio.h"
#include "math.h"
int main()
{
//code
int n;
scanf(%d, &n);
if(n % 2 == 1)
{
int a = 1;
int r = 2;
int term_in_series = (n+1)/2;
int res = 2 * (term_in_series 1);
printf(%d , res);
}
else
{
int a = 1;
int r = 3;
int term_in_series = n/2;
int res = term_in_series 1;
printf(%d , res);
}
return 0;
}

Input: 10

Output: 4

### TCS Coding Questions - 3

Consider the given input and output:

Input: Get 3 strings in 3 lines as input

Hello

Hi

Good Morning

Output:

In the 1st string, replace the vowels with '$', in the 2nd string replace the consonants with '#' and for the 3rd string replace the upper case into lower and lower case into upper. And print these converted string in a single line as output. H$ll$#i gOOD mORNING Answer: #include "stdio.h" #include "string.h" int main() { char str1[20], str2[20], str3[20], ans3[20]; int i; scanf("%s", str1); scanf("%s", str2); scanf("%s", str3); for(i=0; i<=strlen(str1); i++) { if(check_vowel(str1[i]) == 1) str1[i] = '$';
}
printf("%s", str1);
for(i=0; str2[i]!=''; i++)
{
if((str2[i] =='a'||str2[i]=='e'||str2[i]=='i'||str2[i]=='o'||str2[i]=='u' || str2[i] == 'A' || str2[i] == 'E' || str2[i] == 'I' || str2[i] == 'O' || str2[i] == 'U') == 0)
{
str2[i] = '#';
}
}
printf("%s", str2);
for(i=0;i<=strlen(str3);i++)
{
if(str3[i]>='a' && str3[i]<='z')
{
ans3[i]=str3[i]-32;
}
if(str3[i]>='A' && str3[i]<='Z')
{
ans3[i]=str3[i]+32;
}
}
ans3[--i] = '';
printf("%s", ans3);
return 0;
}

Input: heyheygOOd

Output: h\$y#e#GooD

Practice more TCS Coding questions


text:
# [NTG-context] suggestion on [option=TEX]

Wolfgang Schuster schuster.wolfgang at gmail.com
Thu Feb 6 00:57:16 CET 2014

```Am 05.02.2014 um 19:50 schrieb Pablo Rodriguez <oinos at gmx.es>:

> Hi Hans,
>
> I have the following sample:
>
> \setuptyping[option=TEX]
> \starttext
> \starttyping
> \input zapf % knuth
> \stoptyping
> \stoptext
>
> The percent character is in bold font and gray color, but the rest of
> the commented text isn’t.
>
> My suggestion would be to apply the same color and font of the percent
> character to the rest of the comment. So it is easier to see that the
> text is a comment. And I think coloring the whole commented text (not
> only the percent character) is the normal practice in all text editors
> (if comments are colored at all).


text:
×
Get Full Access to Discrete Mathematics And Its Applications - 7 Edition - Chapter 2.4 - Problem 15e
Get Full Access to Discrete Mathematics And Its Applications - 7 Edition - Chapter 2.4 - Problem 15e

×

# Solved: Show that the sequence {an} is a solution of the

ISBN: 9780073383095 37

## Solution for problem 15E Chapter 2.4

Discrete Mathematics and Its Applications | 7th Edition

• Textbook Solutions
• 2901 Step-by-step solutions solved by professors and subject experts
• Get 24/7 help from StudySoup virtual teaching assistants

Discrete Mathematics and Its Applications | 7th Edition

4 5 1 309 Reviews
12
1
Problem 15E

Problem 15E

Show that the sequence {an} is a solution of the recurrence relation an = an-1 + 2an-2 + 2n – 9 if

Step-by-Step Solution:

Solution:

Step 1 :

In the problem we have to find the solution of the  recurrence relation.

Given the recurrence relation …….(1)

Step 2 of 5

Step 3 of 5

##### ISBN: 9780073383095

This textbook survival guide was created for the textbook: Discrete Mathematics and Its Applications, edition: 7. This full solution covers the following key subjects: recurrence, relation, sequence, show, solution. This expansive textbook survival guide covers 101 chapters, and 4221 solutions. The answer to “Show that the sequence {an} is a solution of the recurrence relation an = an-1 + 2an-2 + 2n – 9 if1. 2. 3. 4.” is broken down into a number of easy to follow steps, and 25 words. The full step-by-step solution to problem: 15E from chapter: 2.4 was answered by , our top Math solution expert on 06/21/17, 07:45AM. Since the solution to 15E from 2.4 chapter was answered, more than 443 students have viewed the full step-by-step answer. Discrete Mathematics and Its Applications was written by and is associated to the ISBN: 9780073383095.

## Discover and learn what students are asking

Calculus: Early Transcendental Functions : Integration Techniques, LHpitals Rule, and Improper Integrals
?Verify the reduction formula $$\int(\ln x)^{n} d x=x(\ln x)^{n}-n \int(\ln x)^{n-1} d x$$.

Calculus: Early Transcendental Functions : Inverse Trigonometric Functions: Integration
?In Exercises 1-20, find the indefinite integral. $$\int \frac{1}{4+(x-3)^{2}} d x$$

Statistics: Informed Decisions Using Data : The Normal Approximation to the Binomial Probability Distribution
?In a binomial experiment with n trials and probability of success p, if ________, the binomial random variable X is approximately normal with ?x= and

#### Related chapters

Unlock Textbook Solution

Enter your email below to unlock your verified solution to:

Solved: Show that the sequence {an} is a solution of the


text:
## 2. Big complexes

1. #### Problem 2.1.

[Katie Mann, Priyam Patel] What is the "right" combinatorial object to associate to a big mapping class group? Is there one complex that works for all surfaces, or is a patchwork approach more natural?
• #### Problem 2.2.

[Carolyn Abbott] For many big surfaces, we already have several complexes that are known to be hyperbolic. For these (and for others, as they’re added to the catalogue), what relationships exist between these graphs? For instance, for a given surface, are they quasi-isometric? Are there Lipschitz maps between them?
• #### Problem 2.3.

[Katie Mann] Classify big surfaces whose mapping class groups act by unbounded orbits on (hyperbolic) connected locally finite complexes.

Cite this as: AimPL: Surfaces of infinite type, available at http://aimpl.org/genusinfinity.


text:
## Is it possible to improve the Whitney embedding theorem?

Edited to fix the example, as per Zack's suggestion.

Edit 2: So it turns out that when I think 'manifold' I tend to assume the nicest possible object. As I believe is standard, I would like to assume that all manifolds are 2nd countable and Hausdorff. Furthermore, let's say that our manifolds are connected and closed.

The Whitney embedding theorem states that any smooth $n$-manifold may be smoothly embedded into $\mathbb{R}^{2n}$. If we consider embeddings into more general $k$-dimensional manifolds, is it possible find a '$n$-universal' manifold of dimension less than $2n$?

For example, a non-orientable 2-manifold cannot be embedded into $\mathbb{R}^3$, demonstrating the sharpness of the Whitney embedding theorem.

However, there are 3-manifolds into which we can embed any surface, such as $M = \mathbb{RP}^3 \sharp \mathbb{RP}^3$. Indeed, by the classification of surfaces we know that any surface may be decomposed as a connected sum of copies of $\mathbb{RP}^2$ and tori. In fact, by the monoid structure of closed surfaces under connected sums we may take this sum to have at most 2 copies of the projective plane. Now, embed 2 disjoint copies of the projective plane into $M$ and arbitrarily many copies of the torus. Taking the connected sum of these we see that any closed surface is embeddable into $M$.

Can we do something similar in higher dimensions?

-
A nitpick: the second map in the example isn't well defined. $\mathbb{RP}^3$ doesn't contain two $\mathbb{RP}^2$s (the complement of one of them is $\mathbb{R}^3$). $\mathbb{RP}^3\sharp\mathbb{RP}^3$ should work, though. – Zack Mar 6 2011 at 9:42
This is an extremely silly comment; sorry about that. Let $S$ be a set of $n$-manifolds containing one manifold out of each diffeomorphism class. Then $U=\coprod_{M \in S} M$ is an $n$-manifold and each $n$-manifold embeds into $U$. Of course, $U$ is not second countable. – Johannes Ebert Mar 6 2011 at 10:25
@Johannes $U$ is not a $n$-manifold as it's not second countable. Definitions of "manifold" that I've seen all require second countability. – Kelly Davis Mar 6 2011 at 10:40
1. You should probably just sprinkle the word "connected" all over this question to keep it interesting. 2. We already have the "upper bound" of $\mathbb{R}^{2n}$ for $n$-manifolds, so I think the answer to whether we can do this sort of has to be yes. 3. Certainly we can compare $n$-universal manifolds if their dimensions are different, but a priori there might be two $n$-universal $N$-manifolds and neither covers the other. Or perhaps it's provable that one must cover the other; that'd be a neat result. – Aaron Mazel-Gee Mar 6 2011 at 17:35
I think that, in addition to assuming the domain manifolds to be connected we should also assume "closed," that is, compact without boundary. – John Klein Mar 6 2011 at 19:35

Yes, the Whitney theorem can be improved in many cases. For example, C.T.C. Wall proved all 3-manifolds embed in $\mathbb R^5$.

Precisely what is the optimal minimal-dimensional Euclidean space that all $n$-manifolds embed in, I don't know what the answer to that is but Whitney's (strong) embedding theorem is only best-possible for countably-many $n$, not for all $n$. See Haefliger's work on embeddings -- I believe he noticed many cases where you can improve on Whitney.

The suggestion to improve Whitney's theorem that you're giving -- making the target not a Euclidean space but a manifold -- in a sense you're asking for something much weaker than Whitney's theorem. For example, given any $n$-manifold, you can take its Cartesian product with $S^1$. Take the connect sum of all manifolds obtained this way. It's a giant, non-compact $(n+1)$-manifold, and all $n$-manifolds embed in it. This isn't so interesting.

-
Dear Ryan, I vaguely remember a result about embedding in dimension 2n-b(n) where b(n) is the number of 1's in the binary expansion of n. But I dont remember if it was for the same problem. – Gil Kalai Mar 6 2011 at 21:42
@Ryan If I understand correctly, your answer is $(M_1 \times S^1) \# (M_2 \times S^1) \# \cdots$. This won't work. An infinite connected sum is not defined. For example, we know there exists an exotic $S^7$, notated as $S_+$ say, and it has an inverse $S_-$ such that $S^7 = S_- \# S_+$. If an infinite connected sum were defined, we would have $S_+ = S_+ \# (S_- \# S_+) \# (S_- \# S_+) \cdots$ $= (S_+ \# S_-) \# (S_+ \# S_-) \# \cdots$ $= S^7$ which is false as $S_+$ is exotic. – Kelly Davis Mar 6 2011 at 21:50
Kelly, I think there is a mis-communication over what is meant by "infinite connect-sum". Such arguments aren't a problem in the realm I'm working in because the manifolds are non-compact. If you want to make what I said more precise, the idea would be to take $\mathbb R^{n+1}$, and pick a countable discrete collection of disjoint points in $\mathbb R^{n+1}$, and use them as the "attaching points" for the connect sum operation. This doesn't cause any Mazur-swindle problems since the resulting manifold is non-compact. – Ryan Budney Mar 6 2011 at 21:54
@Gil : That's for immersions, not embeddings. It's the Immersion Conjecture, which was proven by Ralph Cohen. – Andy Putman Mar 6 2011 at 21:54
Hi Alessandro, there's many ways to argue this. One is that all smooth manifolds have triangulations, and there's only countably-many triangulations. Moreover, there's only finitely many smooth structures supported by a given triangulation. – Ryan Budney Mar 7 2011 at 15:38

I assume that all manifolds are closed and connected (embedding in $\mathbb R^n$ or in $S^n$ is the same), but not necessarily orientable.

Concerning dimension 3, a famous theorem of Wall states that every closed 3-manifold embeds in $S^5$.

It is not possible to improve this result. A theorem of Shiomi shows that there is no closed 4-manifold which contains every possible closed 3-manifold.

The question in dimension 4 seems more complicate. Since $4=2^2$, this is one of the dimensions where real projective plane $\mathbb R\mathbb P^4$ embeds in $S^8$ and not in $S^7$. Every orientable 4-manifold embeds topologically in $S^7$ by a theorem of Fang and Fuquan.

-
This answers the question in dimensions 3. But I do not see how it does answers it in other dimensions. – John Klein Mar 6 2011 at 23:36
I agree. This isn't an answer to the full question. – Kelly Davis Mar 6 2011 at 23:41
Ok, my apologies, I am new to Mathoverflow. May I ask what is the proper etiquette for accepting answers? I assumed I was supposed to pick one, which was hard because all three are very informative and interesting, even if they didn't entirely answer my question (ie embeddable closed connected manifolds for arbitrary dimension). In fact, I did not expect to get a full answer to the question. – Ben McMillan Mar 7 2011 at 8:59
@Ben Thanks. Things were just getting interesting, and I didn't want the fun to stop early. – Kelly Davis Mar 7 2011 at 8:59

If we restrict our interest to manifolds which are $k$-connected, then Wall proved that any $n$-manifold (closed) $M$ admits a locally flat PL embedding in $\Bbb R^{2n-k}$, thereby improving on Whitney by $k$ dimensions. If in addition we assume the metastable range condition $2k < n$, then we can even take the embedding to be smooth. The latter theorem was also known to Haefliger and Hirsch and is historically earlier.

One further thing worth mentioning: the Hirsch Conjecture says that a stably parallelizable $n$-manifold is supposed to embed in $\Bbb R^m$, where $m = \lceil (3/2)n\rceil$. The conjecture is still open. Partial results are known: for example it's true when the manifold is $[n/4]$-connected.

-


text:
# What is “entire finite complex plane"?

The question is from the following problem:

If $f(z)$ is an analytic function that maps the entire finite complex plane into the real axis, then the imaginary axis must be mapped onto
A. the entire real axis
B. a point
C. a ray
D. an open finite interval
E. the empty set

A search on Google didn't return any satisfying result of the concept "the entire finite complex plane". The word "entire" and "finite" seem to be a contradiction to me. Here are my questions:

1. What is "the entire finite complex plane"?
2. What properties does one need to use about analytic function to solve this problem?
-
Do you have a source for this problem? Offhand my guess is that this term denotes the extended complex plane a.k.a. the Riemann sphere (en.wikipedia.org/wiki/Riemann_sphere). –  Qiaochu Yuan Jun 29 '11 at 0:21
@Qiaochu When I read it, I thought the adjective "finite" meant the opposite as "extended"; i.e. I thought they were referring to the complex plane without the point at infinity. –  Quinn Culver Jun 29 '11 at 0:41
Agreed. "Finite" emphasizes that $\infty$ is not included. Nowadays when we say "complex plane" this is understood. –  GEdgar Jun 29 '11 at 0:59
Curious. To me "finite" suggests "compact," so that's where I guessed the meaning from. –  Qiaochu Yuan Jun 29 '11 at 1:34
@Qiaochu: Heine-Borel says that a sequence of bounded real numbers has a converging subsequence, a property that definitely doesn't hold for sequences of finite real numbers. (Not saying that your intuition is wrong, because often finiteness does suggest compactness, but one has to be careful in drawing that association.) –  Willie Wong Jun 29 '11 at 9:42
show 1 more comment

The "entire finite complex plane" is just the complex plane. This phrase isn't used very often, but can be used if you want to differentiate between the complex plane $\mathbb{C}$ and the Riemann sphere $\mathbb{C}\cup \{\infty\}$.

The easiest way to answer this is to use Little Picard, but there are certainly easier ways using less powerful machinery. For example, you could consider $\exp(if(z))$ and use Liouville.

Edit: Since you've added the tag reference-request, I will mention that the term "finite complex plane" is used in Silverman's translation of Markushevich's monumental "Theory of Functions of a Complex Variable" which is one of the standard references in complex analysis.

-
Another cheap way is to look at Cauchy-Riemann, and $f$ as a function $\mathbb{R}^2\to\mathbb{R}^2$. The dimensional restriction on the image means $df$ is not surjective anywhere, hence by Cauchy-Riemann $df = 0$ everywhere. (Since the Jacobian determinant of $df$ is a sum of squares.) –  Willie Wong Jun 29 '11 at 0:44
@Willie Wong: Maybe this is a stupid question: Are you talking about the "Cauchy-Riemann equation" when you say "Cauchy-Riemann"? –  Jack Jun 29 '11 at 1:39
@Corey: I am not able to catch up with you in your second paragraph. Could you elaborate it a little more? –  Jack Jun 29 '11 at 1:46
@Jack: The Little Picard theorem says that if the image of an entire function misses 2 points of $\mathbb{C}$, it is constant. The function $e^z$ misses 0, so an analytic function can miss 1 point. But the function in your question misses every point of $\mathbb{C}$ off the real line, so it is constant. As for the second explanation, Liouville's theorem says that a bounded entire function is constant. The function $\exp(if(z))$ is bounded so it is constant. Thus $f$ is constant. –  Corey Jun 29 '11 at 1:53
@Jack: yes. I mean the Cauchy-Riemann equations. For Little Picard, you can see Conway's Functions of one complex variable I, Markusevich's text which Corey mentioned in the edit (in which it is called Picard's first theorem), or, IIRC, Ahlfors's Complex analysis –  Willie Wong Jun 29 '11 at 9:37

Hint: A non-constant analytic function $f$ is an open mapping, i.e., if $U\subseteq \mathbb{C}$ is an open subset, then the image $f(U)$ is also an open subset of the complex plane.

Complete Solution (using the hint above; please avoid hovering your mouse cursor over the (silver) box below if you do not wish to view the solution):

Since no subset of the real line can be an open subset of the complex plane (except, of course, for the empty subset), $f$ must in fact be constant and the image of the imaginary axis (in particular) under $f$ is a single point. Therefore, $B$ is the correct choice.

Alternate Hint: The maximum modulus principle.

The following exercises are relevant to your question:

Exercise 1: If no non-empty subset of $A$ is open in the complex plane, prove that there is no non-constant entire function $f$ that maps the complex plane into $A$. Can you prove this result using only the Cauchy-Riemann equations?

Exercise 2: If $U$ is an open subset of the complex plane, does there exist a non-constant analytic function $f$ that maps the complex plane into $U$? Does the answer change if you restrict to the unbounded open subsets $U$ of the complex plane?

Exercise 3: Prove that there exists an analytic function $f$ that maps the imaginary axis in the complex plane bijectively onto the real axis.

Exercise 4: Find an invertible holomorphic mapping of the open unit disc (${z:\left|z\right|<1}$) onto the upper half plane (${z:\text{Im}(z)>0}$). Hence solve the Dirichlet problem in the upper half plane using the Poisson kernel on the open unit disk.

Challenging Exercise/Important Result (The Riemann Mapping Theorem): If $U$ and $V$ are proper, simply connected (and non-empty), open subsets of the complex plane, prove that there is an invertible holomorphic mapping of $U$ onto $V$. (If you cannot prove this, then you can look up the proof in most texts on complex analysis or online. However, the result is important and therefore you should at least understand the statement.)

Easy Exercise (based on the Riemann Mapping Theorem): Why is the assumption that both open sets be "proper" necessary in the Riemann mapping theorem? More precisely, why does not there exist an invertible holomorphic map from the complex plane onto the unit disk?

-
@Amitesh He didn't ask for a full solution. –  Quinn Culver Jun 29 '11 at 1:03
@Quinn I have edited my answer and hidden the complete solution. (I apologize for that lapse of concentration in my part; I usually avoid giving complete solutions but I forgot this time.) –  Amitesh Datta Jun 29 '11 at 1:08
@Amitesh Datta: Thanks for your answer. Due to my ignorance, I know nothing but the basic calculation with complex variables. Now I see that the "open mapping theorem" in complex analysis is needed. –  Jack Jun 29 '11 at 1:41
Dear Jack, you are welcome! Please do not hesitate to ask if you have further questions. (Note that the maximum modulus principle can be used to prove the open mapping theorem; are you familiar with the maximum modulus principle?) –  Amitesh Datta Jun 29 '11 at 1:56
Dear Theo, you are absolutely correct, of course (otherwise I would be claiming that a (proper) disconnected open subset of the plane is homeomorphic to a (proper) connected subset of the plane!) I have fixed the exercise; the assumption "simply connected (and non-empty)" should be added (in which case it becomes the Riemann mapping theorem). I apologize for this lapse in concentration on my part (again). –  Amitesh Datta Jun 29 '11 at 9:18


text:
# When tapping single phase power from a 3 phase service, how much power can safely be drawn?

I'm setting up a piece of lab equipment that needs 220v-260v to operate properly. The room it's located in has a a 480v 3-Phase service, in the form of a California Standard 50Amp twist-lock connector. It has a large outer ground terminal, and what I assume are 3 "hot" terminals.

The device in question had a 3-prong 240v plug, which I have removed. One Ground, one Hot, one Neutral.

Based on my reading, I believe I can connect the device by wiring Neutral and Ground on the device to the service Ground, and Hot to one of the 3-phase leads. Each lead should be about 440/sqrt(3) volts relative to ground, which is correct for the device.

I've been told that using only one phase of the 3-phase power is not something the transformer is designed for, and so the power factor will not be good, and the full 50amps will not be available. Needless to say, I need about 10 amps, so I assume this won't be a problem.

Is this feasible? Is there anything i'm missing?

And don't worry, I'll someone look at the cable after I set it up. I'm an EE student so I thought I would give it a try at least.

• You should really have a talk to the house electrician. This may be a corner-grounded delta arrangement. In that case, one of the "phase leads" is in fact the ground lead, and the other two have 480V against that one and against each other. – Janka Oct 13 '18 at 0:49
• Hmm so based on google, if that were the case I would need to identify which phase was tied to ground and use that as the neutral supply? Otherwise i would be shorting two phases together... – Tim Vrakas Oct 13 '18 at 1:51
• If that was the case, there would be no neutral equivalent wire. You would only have 480v available to you. Also, is "440/$\sqrt 3$" a typo? Where did you pull the 440 from? – K H Oct 13 '18 at 5:33

## 2 Answers

It sounds like you are intending to use ground as a replacement for neutral. That is not proper practice even if you verify that you have 480 volt wye service and neutral is connected to ground at the service entrance. In addition, you have not said that you have verified the supply voltage, A 480 volt service could be a bit higher at the service entrance and fully 480 volts at your location. That would mean 277 volts line to neutral, above the high end of your required range.

You should ask someone in charge of the facility what can be done to provide what you need.

What you suggest is not advisable.

If you are not offered a neutral then you cannot assume that you have access to a 'Y' service. As a 'delta' service you are able to use the phases for power. Your phase voltage is also outside your control but over 400V.

The correct solution is to arrange a enclosed tapped 400-480V to 230V isolated transformer with a suitable receptacle for your instrument. The ground will be passed through and connected to the transformer casing and to the secondary centre tap and neutral. You will need suitable circuit breaker and over current and residual fault current switches. This will eat into your budget a bit, if permanently mounted you will likely need facility electrician to fit and connect as well.

You can draw current to the maximum that your supply circuit protection devices will supply. If your loading is heavy and always on the same phase (pairs) you may overload the phase(s) before you have used the full supply available. Unevenly loading a 'delta' service causes one live to have less current, unevenly loading a 'Y' service causes one live line to have extra load and the neutral to carry undesirable but not a fault current. If you have 50A service at 400+V you could have over 85A at 230V after your 20kVA transformer (this is a good size).

Facility electrician can probably wire a 230V outlet for less money than supplying and fitting a step down transformer with ancillaries.

If you had a 'Y' outlet you could use the neutral and one phase (live) to get your 260+V single phase supply at 50A.


text:
# Revision history [back]

### Plotting a frequency chart form a set of values

Hello,

I have got a list of results from my function already. And now, I need to visualise this information and plot a chart of how many times each particular value is repeated in a list. I know how to do a histogram, but it shows intervals of values, but not specific values. I need to access all the values afterwards as well and be able to work with them.

I have found also that I can count values using a command "count" list.count() if it is necessary to do it like this in my problem. I'd like to ask what is the code for such frequency chart (or plot of points)? And how do I need to define my variables? Would be much appreciated if someone could help in any way. Thank you very much.

Xenia


text:
# Mechanics rope of mass problem

1. Oct 5, 2005

### asdf60

A uniform rope of mass 'i' per unit length is coiled on a table, one end s pulled straight up with constant speed Vo.

a. find the force exerted on the end of the rope as a function of distance of the top of the rope above table (y).
b. compare the power delivered to the rope with the rate of change of the ropes total mechanical energy.

Part a seems to be pretty simple... F-mg = dp/dt, so F(y) = i*V^2+i*y*g.

Now the problem is when i integrate F(y) with respect with y, I should get the total energy of the rope system. But i don't. The total energy = .5mv^2 + mgh = .5(i*y)(v^2) + .5(i*y)(y*g), which clearly isn't the integral of F. So what's going on???

2. Oct 5, 2005

### hotvette

Not sure I follow what you did, but you basically have mass that is a function of time.

3. Oct 5, 2005

### asdf60

Right.
That's why I set m(t) = y(t)*density*g.

4. Oct 5, 2005

### hotvette

Pls explain where $iV^2$ came from in part a.

Here's my line of thinking.

$$F = \dot p = ma$$

Since v is constant, that means a = 0, meaning the net force on the rope is zero. No?

Last edited: Oct 5, 2005
5. Oct 5, 2005

### asdf60

iv^2 is the change in momentum. This is because the change in mass is I*v, and velocity is a constant V, so dp/dt = Iv^2.

Last edited: Oct 6, 2005
6. Oct 6, 2005

### asdf60

Hehe simultaneous post.

In any case, no. The momentum is not constant. The mass of rope moving at velocity V is increasing. Which implies that F is not zero.

7. Oct 6, 2005

### Pyrrhus

Wait a minute asdf you mean

$$\frac{dp}{dt} = \frac{dm}{dt}v$$

where

$$\frac{dm}{dy} = \frac{M}{L}$$

so

$$\frac{dp}{dt} = \frac{M}{L}v^2$$

8. Oct 6, 2005

### asdf60

which is precisely what i posted by saying dp/dt = i*v^2, where i = M/L (if M = mass of entire rope, and L = length of entire rope), just as you have.

9. Oct 6, 2005

### asdf60

Let me just be a bit more clear. The question can be simplified.

Forget gravity, and just say the force is pulling on the string. Then as was proven above, F = dp/dt = M/L * v^2. This makes sense, we can integrate to show that the momentum at time t is the integral of the force up to t.

But now, if we consider the kinetic energy = .5 m v ^2, where m = y*M/L, it breaks down. The kinetic energy as a function of y should be the integral F dy from 0 to y, but this is clearly not the case, as the integral of F dy is M/L * v^2 * y, which is close to KE(y) = .5 y*M/L v^2, but the .5 term is missing.

Why is the .5 term missing? Am a making an incredibly stupid mistake, or is something really wrong?

Last edited: Oct 6, 2005
10. Oct 6, 2005

### hotvette

I see it now.

$$F = \dot p = ma$$ is only true when m is constant.


text:
Next Meeting: January 6: Social gathering Next Installfest: TBD Latest News: Nov. 18: Club officer elections Page last updated: 2004 Mar 04 15:25
Re: [vox-tech] latex sty

# Re: [vox-tech] latex sty

Thanks Pete and Micah for responding:

Peter Jay Salzman wrote:

On Tue 02 Mar 04,  6:44 PM, Jonathan Stickel <jjstickel@sbcglobal.net> said:

I'm submitting a latex document to a journal, and I'm not supposed to include any files other than my latex file and my eps figures.

have you written to them and said something like:

"is it OK to also send in a .sty file to conform to your bibliography
format?  and if i can't, please tell me how to conform to your format"

before giving up on that, you should definitely ask...

Well, like many nerdy engineers, I tend to use real human interaction as a last resort :-) But I did do so now and am waiting for a response.

<snip>
Is there any way to include that information in my latex file? I tried just pasting it in at the top of my document, but I get errors. Clearly, there is syntax for sty files that is not permitted in latex.

it's possible, but not that i know of.  my own pete_macros.sty is just a
bunch of macros i've written and placed in \$TEXINPUTS so \usepackage can
find it.

are you sure you pasted it after \documentclass but before
\begin{document}?

Most definitely, but my problem was with any \@[latex_command]. By Micah's suggestion to look around on comp.text.tex, I found my answer almost immediately in a tex-faq. You have to wrap sections that contain these commands with \makeatletter and \makeatother. For example:

\makeatletter
[pasted in from foo.sty]
\makeatother

This is actually discussed in the "Latex Companion" on pages 15-16, but I didn't realize it until now. So my problem is solved!

Jonathan
_______________________________________________
vox-tech mailing list
vox-tech@lists.lugod.org
http://lists.lugod.org/mailman/listinfo/vox-tech


text:
Primes: popular and lonely

Standard

ulam While doodling in class, I made a 10 x 10 grid and filled it with numbers from 1 to 100. The motivations behind 10 x 10 grid was human bias towards the number 10.

Then inspired by Ulam Spiral, I started creating paths (allowing diagonal, horizontal and vertical moves) starting from the smallest number. Following paths emerged:

• 2→ 3 →13 → 23
• 2 → 11
• 7 → 17
• 19 → 29
• 31 → 41
• 37 → 47
• 43 → 53
• 61 → 71
• 73 → 83
• 79 → 89

So, longest path is of length 4 and others are of length 2.

The number 2 is special one here, since it leads to two paths. I will call such primes, with more than one paths, popular primes.

Now, 5, 59, 67 and 97 don’t have any prime number neighbour. I will call such primes, with no neighbour, lonely primes.

I hope to create other $b \times b$ grids filled with 1 to $b^2$ natural numbers written in base $b$. Then will try to identify such lonely and popular primes.

8 responses

1. Pingback: Ulam Spiral | Gaurish4Math

• Thanks! This is very accessible exposition of Green-Tao Theorem.

Like

2. When you do b^2 it wont be prime, ever.

Like

• Yes, like 10^2 = 100. I just want to preserve this pattern. of 1 to 100 🙂

Liked by 1 person

• Oh sorry, I see now. I misunderstood!

Like