text:
# Help required to calculate the effective index of sub-wavelength gratings

#1

Hello there,

I am interested to calculate the effective mode index of the sub-wavelength gratings (SWG). Basically I calculated the effective index using the refractive index, i.e. the refractive index of the SWG on SOI platform on any particular wavelength is given as:

n = sqrt(n1^2*DC + (1-DC)*n2^2)

where, n1 - refractive index of silicon, n2 is the refractive index of cladding (mostly silica) and DC is the duty cycle of the SWG waveguide.

Now I am using the value of ‘n’ as the refractive index of new material and calculating the effective index. Now the effective index which I am getting by this way is basically I am assuming the true effective index of the SWG waveguide. But I am not sure about this method as this is a kind of approximation, any comments on it?

I will be very thankful if you please guide me the exact way to calculate the effective index of the SWG waveguide using Lumerical Mode/FDTD solution.

Many thanks,
Umair

#2

I am not an expert in the filed and not familiar with the equation.

Can you please elaborate on your inquiry? Once you select the refractive index of SWG, how you set the new material and duty cycles?

Thanks

#3

Hello @bkhanaliloo, sorry for the delay as I was working on the modelling of the subwavelength gratings (SWG) and I thought to do some research and now I really need your help . Basically, I am interested to calculate the effective index of the SWG waveguide at different temperatures (to calculate the dneff/dt). I have used the photonic crystal method which is available on this website:

https://kb.lumerical.com/en/diffractive_optics_pc_bandstructure.html

I have calculated the refractive index of silicon and silica which is used by Lumerical solution for Palik silicon and silica material from wavelength 1100 to 1800 nm. I have used the thermo-optic coefficient for the silicon and silica (1.87e-4 and 1e-5 respectively), hence created 4 new material using sampledata, named as:

1. Si_Temp_dep0K
2. Si_Temp_dep1K
3. SiO2_Temp_dep0K
4. SiO2_Temp_dep1K

Where, 0K represents the refractive index at room temperature (default value) and 1K represent the refractive index at 1 degree kelvin. The SWG is comprises of silicon and silica as main waveguide, cladding and box both are silica as well.

Now, by changing the refractive index of the both materials, silicon and silica, by varying the temperature and running the sweep, I found no difference in the effective indices for 0 and 1 degree for most of the ‘k’ points. There should be some change when you vary the temperature (increment as you increase the temperature) but here the difference is almost 0 for most of the ‘k’ points.

I am attaching you a FDTD .lsp and .lsf file, I will be very thankful if you please have a look in to it and kindly help me that where I am actually making the mistake. If you need any further information, please do let me know.
DataAnalysis.lsf (2.5 KB)
SWGwgExample_modified.fsp (391.3 KB)

Best regards,
Umair

#4

Thanks for elaborating on your inquiry and providing simulation files.

While you have defined two materials, it looks like they are both using same FDTD model:

Si_Temp_dep1k:

Si_Temp_dep0k:

It looks to me that the temperature change and shift in index are quite small and you will need to modify the material fitting to capture this. You could also use Index perturbed material to capture the shift. Please see the links below:
https://kb.lumerical.com/en/index.html?ref_sim_obj_temperature-to-index-conversio.html
Temperture to index pertubation
Does the "simulation temperature" setting in MODE do anything?

I think it will be a good practice to run single frequency simulations with fixed kx value and then move into sweeping over kx value for broadband simulations.

#5

Hello @bkhanaliloo, many thanks for the suggestions. I haven’t looked the links in detail which you shared: I will try it tomorrow. Just wanted to say that I opened the model and double checked the refractive index which FDTD is considering, i.e. change in the temperature. If you zoom up, there is a difference in the refractive index though it is very small because the thermo-optic coefficient is a change of 4 order lower.

This is the figure for silicon at room temperature and the refractive index at 1500 nm is 3.47995 used by FDTD model

And below is the figure for the refractive index of silicon with 1 degree more and the refractive index at 1500 nm is 3.48014:

And if you calculate the difference between both, i.e. 3.48014 - 3.47995 = 1.9e-4, and this is the thermo-optic coefficient of silicon. I will surely try the single frequency approach but I think the way I am introducing the new material is working too. I think there is something else which is missing in the simulation which is why the difference in the effective index at different temperature is zero.

Any other useful suggestion which you think I am missing in my simulations?

Best,
Umair

#6

Hi @bkhanaliloo, just to update you that I ran the simulation with your method (introducing the index perturbed material) and the results are somehow encouraging but not completely, but it really help me and thanks for it. I ran the script for 20 points and below are the values I am getting for dn/dt

1.0e-04 *

     0
0
0
0.3467
0.3438
0.3411
0.3385
0.3363
0.6681
0.3320
0.3300
0.3283
0.3266
0.3250
0.3235
0.6441
0.3207
0.3194
0.3182
0.6340

I am not sure that why there are three zeros in the beginning and three values with ‘0.6’. We cannot say that the temperature is not affecting the waveguide on certain frequency and on certain frequencies, it is affecting quite lot, something is missing in my simulation. Can you suggest some settings which can possibly help me to get the exact results?

Many thanks,
Umair

#7

You are right, and indeed there is a minor difference between them. I think the challenge would be to make sure that this difference can be captured in FDTD results.

I can think of a few modifications into your simulation file:

1. Make sure that mesh grids match the edge of the waveguide.

2. Plane wave source cannot be used with PML BCs. For bandstructure calculations, we use dipole source or maybe mode source (in specific cases where we are interested in a specific mode):
https://kb.lumerical.com/en/index.html?diffractive_optics_pc_simulation_methodology.html

Regarding your second inquiry, can you please share your simulation file and material model for a review?

Thanks

#9

Hello @bkhanaliloo, many thanks for the details.
About my second inquiry, here is the file:

SWGwgExample_Perturbed_material.fsp (330.5 KB)

The substrate is Silica and the waveguide in Silicon material. I have introduced the perturbed materials named as Temp_Silicon for the waveguides and Temp_Silica for the substrate and both are for broadband range. Initially I ran the simulation with simulation temperature as 300 and then I changed it to 310. I have used 100 points for the k vector ranges from 0.2 to 0.3.

Here is the MATLAB figure for the dn/dt. Please note that the dn/dt is calculated by using below formula:

dn/dT = (neff_10-neff_0)./(10-0);

Here you can see that the dn/dT is fluctuating in between 3e-5 and 7e-5.

Thanks,
Umair

#10

I think you need to run your files with the modifications mentioned above and perform your analysis with a proper simulation file. Also, can you please explain how you are extracting neff values for 0 and 10 degree perturbation?

Thanks

#11

Hi @bkhanaliloo,

Thanks for the message.

Can you please explain this statement in more detail? Like how my mesh grid should match the edge of the waveguide?

Initially, I set the simulation temperature of the FDTD to 300 degree (since 300 K is the reference temperature which means that the material refractive index will not get modified) and ran the dataAnalysis.lsf file,

Once I get the results of effective index at zero degree (reference temperature), I am changing the simulation temperature of the FDTD tab from 300 to 310 and re-run the simulation. Once the simulation is complete, I am again running DataAnalysis.lsf file to calculate the neff at 10 degree.

Thanks

#12


text:
# What makes an algorithm greedy?

I have a simple graph $$G = (V,E)$$ and each vertex has a range $$[a,b]$$. Every two vertices are connected only if $$[a_1, b_1]$$ and $$[a_2, b_2]$$ have a common subrange.

Each range of vertex is rV1 = [0,5] rV2 = [1,3] rV3 = [2,10] rV4 = [4,9] rV5 = [6,7] rV6 = [8,12] rV7 = [11,13]

Graph Created based on above ranges.

Based on the algorithm below i have to color the graph.

ranges = rV1,rV2,rV3,rV4,rV5,rV6,rV7...

COLOR_INTERVAL_GRAPH(rV1,rV2,rV3,rV4,rV5,rV6,rV7...){
if(number of rVi > 0){
C_m  = MAXIMAL_COLOR_CLASS(rV1,rV2,rV3,rV4,rV5,rV6,rV7...);
//paint C_m vertices with color m.
//new_ranges <- remove C_m from rV1,rV2,rV3,rV4,rV5,rV6,rV7...
return {C_m} U COLOR_INTERVAL_GRAPH(new_ranges)
else:
return []

MAXIMAL_COLOR_CLASS(new_range){
C = []
i = 1
while(i <= new_range.size()){
C = C U {Vi}
j = i+1
while(j <= new_range.size() AND rVi (not common subrange with rVj)){
j = j+1
i=j
return C

How i know if the above algorithm uses the greedy strategy?

My work so far:

The algorithm has the 'greedy choice property' since it paints the most each turn, by choosing the best solution to the current subproblem without caring about future problems or backtracking.(can this be improved and how)?

Graph Colored (Is the graph colored correctly?).

• Please ask only one question per post. If you have multiple questions, you can post them separately. We are a question-and-answer site, so we require you to articulate a specific question. A question usually ends with a "?".
– D.W.
Jan 11 at 18:04
• We discourage "please check whether my answer is correct" questions, as only "yes/no" answers are possible, which won't help you or future visitors. See here and here. Can you edit your post to ask about a specific conceptual issue you're uncertain about? As a rule of thumb, a good conceptual question should be useful even to someone who isn't looking at the problem you happen to be working on. If you just need someone to check your work, you might seek out a friend, classmate, or teacher.
– D.W.
Jan 11 at 18:05
• I am a newbie to this platform, thank you for correcting me. Now i think everything is better. Jan 11 at 18:21

"A greedy algorithm is any algorithm that follows the problem-solving heuristic of making the locally optimal choice at each stage." (from Wikipedia) In other words, it does not backtrack. It builds up the solution incrementally, and when it adds something to the solution-so-far, it never later removes it (or, when it makes a decision, it never later undoes that decision).

Does that describe the algorithm you are looking at?

If you want to justify that it satisfies the greedy choice property, it might help to precisely state what is the "subproblem" that is solved at each step.

• So my answer is correct, the algorithm does not backtrack and also makes the optimal choice at each stage since the criterion is to choose all non overlapping vertices (the ones that don't share an edge) with one another. Jan 11 at 19:08

Many problems can be written in the form "You start with an initial state. You make a choice what your first action should be and perform the action, getting into a new state. You make another choice for your second action and perform that action, and so on. After a limited number of actions, you will arrive at the final state. You never undo any action that you have taken, and the effort determining the next action is limited". That's a greedy algorithm.

For example, the travelling salesman problem can be handled with a greedy algorithm. You just pick the first, second, third etc. place to visit, and your last action is to return to the starting point. The "limited effort" requirement is there so you don't solve the whole problem, take the first step, and call it a "greedy algorithm".

If you're lucky, you can prove that a greedy algorithm will find the optimal solution. Or you can prove that a greedy algorithm that isn't much worse than the optimal solution. You can vary the effort to determine the next step, and that may make your greedy algorithm slower but with better results.

A "Greedy" algorithm is often not optimal when making one choice that seems a good choice now makes it impossible to make a good choice later.

format: plain


text:
# LinearReLU¶

class torch.nn.intrinsic.LinearReLU(linear, relu)[source]

This is a sequential container which calls the Linear and ReLU modules. During quantization this will be replaced with the corresponding fused module.


text:
## electrochika 4 years ago At time t equals or > 0, the acceleration of a particle moving on the x axis is a(t)=t+sint.?

1. electrochika

at t=0 the velocity of the particle is -2. for what value t will the velocity of the particle be zero?

2. anonymous

To find a velocity equation from an acceleration equation, you need to differentiate the acceleration equation with respect to t: $a'(t)=\cos(t)$Now find the values for which this equation is equal to 0. $0=\cos(t)$$t=\pi/2, 3\pi/2$

3. TuringTest

$v(t)=\int a(t)dt=\frac1 2t^2-\cos t+C$$v(0)=-1-2=C=-3$$v(t)=\frac1 2t^2-\cos t-3=0$solve for t

4. anonymous

think this might be backwards you are given acceleration and you want velocity

5. TuringTest

Xishem has it backwards, yes

6. anonymous

what turing test said.

7. anonymous

Yep.

8. electrochika

So t = - 2.917 and 2.917?

9. TuringTest

yes, and I would imagine we want the positive answer here

10. electrochika

yeah we do

11. TuringTest

oh yeah, positive only it says so in the problem


text:
# Problem: Draw the structural formulas for the products of the reaction shown below.

###### Problem Details

Draw the structural formulas for the products of the reaction shown below.


text:
# Math Help - Help understanding two Group questions

1. ## Help understanding two Group questions

Problem 1: Suppose G is a group with the property that agb=cgd always implies that ab=cd. Prove that G is abelian.

What does this question mean? Is g a special element of G, or any old element? Suppose g is the identity (in which case ab=cd anyway). How does one prove this?

Problem 2: Suppose G is a finite abelian group in which no non-identity is equal to its own inverse. Determine the product of all the elements of G.

How can I do the entire table? It could have thousands (literally!) of entries (or more). How do I know what a time b equals? I don't get it.

2. ## Re: Help understanding two Group questions

1) it's "any old element". the trick is to pick the right choices for a,b,c and d, so that we wind up with two products agb and agd we KNOW are equal. there are different ways to do this, here is one:

choose a = x, b = y, c = y, d = x, and g = x-1

then agb = x(x-1)y = (xx-1)y = y, and:

cgd = y(x-1)x = y(xx-1) = y, so we have agb = cgd. because in G agd = cgd implies ab = cd, we have: xy = yx, so G is abelian.

2) hint: if no element except the identity is its own inverse, multiply all the elements of G together like so:

(e)(g1g1-1)(g2g2-1)....... = ?

(of course this means that |G| must be odd. why is this not a problem?)

3. ## Re: Help understanding two Group questions

Originally Posted by Deveno
...choose a = x, b = y, c = y, d = x, and g = x-1

then agb = x(x-1)y = (xx-1)y = y, and:

cgd = y(x-1)x = y(xx-1) = y, so we have agb = cgd. because in G agd = cgd implies ab = cd, we have: xy = yx, so G is abelian.
Good clear answer. But how is a student supposed to come up with that? I mean, now that I see it, it's easy to understand. But how does one recognize this?
Is there anyone out there who, as a student, figured out this answer without asking for help, or at least very little help? What was the process by which you got there?

I now need to prove or disprove if the converse is true, so I'm going to try that on my own.

Originally Posted by Deveno
...(e)(g1g1-1)(g2g2-1)....... = ?
OK. I misunderstood the question to mean write the multiplication table of all the elements (duh!). Answer is the identity (which still took me some time to recognize <smh at myself>).

Originally Posted by Deveno
(of course this means that |G| must be odd. why is this not a problem?)
From the property that non-identities cannot equal their inverse (and your writing it out) it's pretty clear that the elements of G occur in pairs, g and g-1. Thus, there are an even number of non-identity elements. If there is only one identity (and identities are unique, I'm nearly certain), making an odd number of elements to G.

That's not a problem because I have no issues with a finite group having an odd number of elements. Clearly such groups exist, e.g. $(\mathbb{Z}_5,+)$.

4. ## Re: Help understanding two Group questions

well, Z4 has an even number of elements (0,1,2, and 3). the point is, the condition that x = x-1 is equivalent to saying x is of order 1 or 2. if x ≠ e, then x is of order 2. it turns out that |G| is even iff G has an element of order 2 (one direction is lagrange's theorem, the other is cauchy's theorem for p = 2). if G has elements of order 2, then this (elementary) argument fails.

to answer your question: how would somebody get the first question, if they didn't know the answer?

often, it's by working backwards. you'd like to prove that:

xy = yx

from xgy = ygx, so you need to pick g so that xgy = ygx will always be true. well if xg...(something) = yg...(something else) some sort of cancellation has to be going on, that is: g ought to start with either x-1 or y-1.

5. ## Re: Help understanding two Group questions

Originally Posted by Deveno
well, Z4 has an even number of elements (0,1,2, and 3)...
I meant Z5 (and edited my post to make me look less dumb).

6. ## Re: Help understanding two Group questions

Originally Posted by Deveno
...often, it's by working backwards. you'd like to prove that:

xy = yx

from xgy = ygx, so you need to pick g so that xgy = ygx will always be true. well if xg...(something) = yg...(something else) some sort of cancellation has to be going on, that is: g ought to start with either x-1 or y-1.
What I missed is fitting the xy=yx into ab=cd. Possibly if I'd realized that a=d and b=c I'd get the answer, I could have worked backwards. I need to work on fitting the needed conclusion (xy=yx) into some part of the given info.


text:
# The output of a circular convolution performed on two signals x1(n) = {2, 1, 2, 1} and x2(n) = {1, 2, 3, 4} is:

1. {16, 14, 16, 14}
2. {14, 16, 14, 16}
3. {12, 14, 12, 14}
4. {14, 12, 14, 12}

## Answer (Detailed Solution Below)

Option 2 : {14, 16, 14, 16}

## Detailed Solution

Concept:

Convolution in the time domain results in multiplication in the frequency domain.

To find circular convolution of two signals we can follow the following steps:

• First, make the length of the signals equal to N by adding extra zeros if needed.
• Form two matrices, 1st matrix using the cyclic rotation of one of the signals and 2nd matrix with another signal.
• Multiply the two matrices.

Calculation:

Given:

$$\\{x_1}\left( n \right)=\left\{ {\begin{array}{*{20}{c}} 2\\ \uparrow \end{array}\;\begin{array}{*{20}{c}} 1\\ {} \end{array}\;\begin{array}{*{20}{c}} 2\\ {} \end{array}\;\begin{array}{*{20}{c}} 1\\ {} \end{array}} \right\};\\{x_2}\left( n \right)=\left\{ {\begin{array}{*{20}{c}} 1\\ \uparrow \end{array}\;\begin{array}{*{20}{c}} 2\\ {} \end{array}\;\begin{array}{*{20}{c}} 3\\ {} \end{array}\;\begin{array}{*{20}{c}} 4\\ {} \end{array}} \right\}$$

$$y\left( n \right) = {x_1}\left( n \right)\;⊛{x_2}\;\left( n \right)$$

$$= \left\{ {\begin{array}{*{20}{c}} 2\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} 1\\ {} \end{array}\;,\begin{array}{*{20}{c}} 2\\ {} \end{array}\;,\begin{array}{*{20}{c}} 1\\ {} \end{array}\;} \right\} ⊛\;\;\left\{ {\begin{array}{*{20}{c}} 1\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} 2\\ {} \end{array},\begin{array}{*{20}{c}} 3\\ {} \end{array},\begin{array}{*{20}{c}} 4\\ {} \end{array}\;} \right\}$$

$$y\left( n \right) = \left[ {2\;1\;2\;1} \right]\left[ {\begin{array}{*{20}{c}} 1&2&3&4\\ 4&1&2&3\\ 3&4&1&2\\ 2&3&4&1 \end{array}} \right]$$

$$y\left( n \right) = \left\{ {\;\begin{array}{*{20}{c}} {14}\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} {16}\\ {} \end{array},\begin{array}{*{20}{c}} 14\\ {} \end{array},\begin{array}{*{20}{c}} {16}\\ {} \end{array}} \right\}$$

# The output of a circular convolution performed on two signals x1(n) = {2, 1, 2, 1} and x2(n) = {1, 2, 3, 4} is:

1. {16, 14, 16, 14}
2. {14, 16, 14, 16}
3. {12, 14, 12, 14}
4. {14, 12, 14, 12}

## Answer (Detailed Solution Below)

Option 2 : {14, 16, 14, 16}

## Detailed Solution

Concept:

Convolution in the time domain results in multiplication in the frequency domain.

To find circular convolution of two signals we can follow the following steps:

• First, make the length of the signals equal to N by adding extra zeros if needed.
• Form two matrices, 1st matrix using the cyclic rotation of one of the signals and 2nd matrix with another signal.
• Multiply the two matrices.

Calculation:

Given:

$$\\{x_1}\left( n \right)=\left\{ {\begin{array}{*{20}{c}} 2\\ \uparrow \end{array}\;\begin{array}{*{20}{c}} 1\\ {} \end{array}\;\begin{array}{*{20}{c}} 2\\ {} \end{array}\;\begin{array}{*{20}{c}} 1\\ {} \end{array}} \right\};\\{x_2}\left( n \right)=\left\{ {\begin{array}{*{20}{c}} 1\\ \uparrow \end{array}\;\begin{array}{*{20}{c}} 2\\ {} \end{array}\;\begin{array}{*{20}{c}} 3\\ {} \end{array}\;\begin{array}{*{20}{c}} 4\\ {} \end{array}} \right\}$$

$$y\left( n \right) = {x_1}\left( n \right)\;⊛{x_2}\;\left( n \right)$$

$$= \left\{ {\begin{array}{*{20}{c}} 2\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} 1\\ {} \end{array}\;,\begin{array}{*{20}{c}} 2\\ {} \end{array}\;,\begin{array}{*{20}{c}} 1\\ {} \end{array}\;} \right\} ⊛\;\;\left\{ {\begin{array}{*{20}{c}} 1\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} 2\\ {} \end{array},\begin{array}{*{20}{c}} 3\\ {} \end{array},\begin{array}{*{20}{c}} 4\\ {} \end{array}\;} \right\}$$

$$y\left( n \right) = \left[ {2\;1\;2\;1} \right]\left[ {\begin{array}{*{20}{c}} 1&2&3&4\\ 4&1&2&3\\ 3&4&1&2\\ 2&3&4&1 \end{array}} \right]$$

$$y\left( n \right) = \left\{ {\;\begin{array}{*{20}{c}} {14}\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} {16}\\ {} \end{array},\begin{array}{*{20}{c}} 14\\ {} \end{array},\begin{array}{*{20}{c}} {16}\\ {} \end{array}} \right\}$$

# Consider the following sequences:$${x_1}\left( n \right) = \left\{ {\;\begin{array}{*{20}{c}} 1\\ \uparrow \end{array}\;\begin{array}{*{20}{c}} 2\\ {} \end{array}\;\begin{array}{*{20}{c}} 3\\ {} \end{array}} \right\}$$$${x_2}\left( n \right)=\left\{ {\begin{array}{*{20}{c}} 1\\ \uparrow \end{array}\;\begin{array}{*{20}{c}} 2\\ {} \end{array}\;\begin{array}{*{20}{c}} 3\\ {} \end{array}\;\begin{array}{*{20}{c}} 4\\ {} \end{array}} \right\}$$ The resultant of the 4-point circular convolution of the above two sequences is

1. $$\left\{ {\begin{array}{*{20}{c}} {14}\\ \uparrow \end{array},\begin{array}{*{20}{c}} {15}\\ {} \end{array},\begin{array}{*{20}{c}} {12}\\ {} \end{array},\begin{array}{*{20}{c}} 9\\ {} \end{array}} \right\}$$
2. $$\left\{ {\begin{array}{*{20}{c}} 18\\ \uparrow \end{array},\begin{array}{*{20}{c}} {16}\\ {} \end{array},\begin{array}{*{20}{c}} {10}\\ {} \end{array},\begin{array}{*{20}{c}} {16}\\ {} \end{array}} \right\}$$
3. $$\left\{ {\begin{array}{*{20}{c}} {18}\\ \uparrow \end{array},\begin{array}{*{20}{c}} 9\\ {} \end{array},\begin{array}{*{20}{c}} {14}\\ {} \end{array},\begin{array}{*{20}{c}} {15}\\ {} \end{array}} \right\}$$
4. $$\left\{ {\begin{array}{*{20}{c}} {15}\\ \uparrow \end{array},\begin{array}{*{20}{c}} {12}\\ {} \end{array},\begin{array}{*{20}{c}} 9\\ {} \end{array},\begin{array}{*{20}{c}} {14}\\ {} \end{array}} \right\}$$

## Answer (Detailed Solution Below)

Option 2 : $$\left\{ {\begin{array}{*{20}{c}} 18\\ \uparrow \end{array},\begin{array}{*{20}{c}} {16}\\ {} \end{array},\begin{array}{*{20}{c}} {10}\\ {} \end{array},\begin{array}{*{20}{c}} {16}\\ {} \end{array}} \right\}$$

## Detailed Solution

Concept:

Convolution in the time domain results in multiplication in the frequency domain.

To find circular convolution of two signals we can follow the following steps:

• First, make the length of the signals equal to N by adding extra zeros if needed.
• Form two matrices, 1st matrix using the cyclic rotation of one of the signals and 2nd matrix with another signal.
• Multiply the two matrices.

Calculation:

Given:

$${x_1}\left( n \right) = \left\{ {\;\begin{array}{*{20}{c}} 1\\ \uparrow \end{array}\;\begin{array}{*{20}{c}} 2\\ {} \end{array}\;\begin{array}{*{20}{c}} 3\\ {} \end{array}} \right\};\\{x_2}\left( n \right)=\left\{ {\begin{array}{*{20}{c}} 1\\ \uparrow \end{array}\;\begin{array}{*{20}{c}} 2\\ {} \end{array}\;\begin{array}{*{20}{c}} 3\\ {} \end{array}\;\begin{array}{*{20}{c}} 4\\ {} \end{array}} \right\}$$

$$y\left( n \right) = {x_1}\left( n \right)\;⊛{x_2}\;\left( n \right)$$

$$= \left\{ {\begin{array}{*{20}{c}} 1\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} 2\\ {} \end{array}\;,\begin{array}{*{20}{c}} 3\\ {} \end{array}\;,\begin{array}{*{20}{c}} 0\\ {} \end{array}\;} \right\} ⊛\;\;\left\{ {\begin{array}{*{20}{c}} 1\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} 2\\ {} \end{array},\begin{array}{*{20}{c}} 3\\ {} \end{array},\begin{array}{*{20}{c}} 4\\ {} \end{array}\;} \right\}$$

$$y\left( n \right) = \left[ {1\;2\;3\;0} \right]\left[ {\begin{array}{*{20}{c}} 1&2&3&4\\ 4&1&2&3\\ 3&4&1&2\\ 2&3&4&1 \end{array}} \right]$$

$$y\left( n \right) = \left\{ {\;\begin{array}{*{20}{c}} {18}\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} {16}\\ {} \end{array},\begin{array}{*{20}{c}} 10\\ {} \end{array},\begin{array}{*{20}{c}} {16}\\ {} \end{array}} \right\}$$

# Let x (n) = h (n) = {3, 4, 2, 1}. The convolution of x (n - 1) & h (n + 4) is y (n). The value of y (n) at n = 0 is ________.

## Detailed Solution

Whenever in a discrete signal, the value of origin is not mentioned, the value of the signal is assumed to be origin value.

$$\therefore x\left( n \right) = h\left( n \right) = \left\{ {\begin{array}{*{20}{c}} 3\\ \uparrow \end{array},4,2,1} \right\}$$

$$x\left( {n - 1} \right) = \left\{ {\begin{array}{*{20}{c}} 0\\ \uparrow \end{array},3,4,2,1} \right\}$$

$$h\left( {n + 4} \right) = \left\{ {3,4,2,1,\begin{array}{*{20}{c}} 0\\ \uparrow \end{array}} \right\}$$

Using tabular method of convolution:

y(n) = x(n - 1) * h(n + 4)

$$y\left( n \right) = \left\{ {0,9,24,28,\begin{array}{*{20}{c}} {22}\\ \uparrow \end{array},12,4,1,0} \right\}$$

y(0) = 22

# The output of a circular convolution performed on two signalsx1(n) = {2, 1, 2, 1} and x2(n) = {1, 2, 3, 4} is

1. {16, 14, 16, 14}
2. {14, 16, 14, 16}
3. {12, 14, 12, 14}
4. {14, 12, 14, 12}
5. None of these

## Answer (Detailed Solution Below)

Option 2 : {14, 16, 14, 16}

## Detailed Solution

Concept:

Convolution in the time domain results in multiplication in the frequency domain.

To find circular convolution of two signals we can follow the following steps:

• First, make the length of the signals equal to N by adding extra zeros if needed.
• Form two matrices, 1st matrix using the cyclic rotation of one of the signals and 2nd matrix with another signal.
• Multiply the two matrices.

Calculation:

Given:

$$\\{x_1}\left( n \right)=\left\{ {\begin{array}{*{20}{c}} 2\\ \uparrow \end{array}\;\begin{array}{*{20}{c}} 1\\ {} \end{array}\;\begin{array}{*{20}{c}} 2\\ {} \end{array}\;\begin{array}{*{20}{c}} 1\\ {} \end{array}} \right\};\\{x_2}\left( n \right)=\left\{ {\begin{array}{*{20}{c}} 1\\ \uparrow \end{array}\;\begin{array}{*{20}{c}} 2\\ {} \end{array}\;\begin{array}{*{20}{c}} 3\\ {} \end{array}\;\begin{array}{*{20}{c}} 4\\ {} \end{array}} \right\}$$

$$y\left( n \right) = {x_1}\left( n \right)\;⊛{x_2}\;\left( n \right)$$

$$= \left\{ {\begin{array}{*{20}{c}} 2\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} 1\\ {} \end{array}\;,\begin{array}{*{20}{c}} 2\\ {} \end{array}\;,\begin{array}{*{20}{c}} 1\\ {} \end{array}\;} \right\} ⊛\;\;\left\{ {\begin{array}{*{20}{c}} 1\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} 2\\ {} \end{array},\begin{array}{*{20}{c}} 3\\ {} \end{array},\begin{array}{*{20}{c}} 4\\ {} \end{array}\;} \right\}$$

$$y\left( n \right) = \left[ {2\;1\;2\;1} \right]\left[ {\begin{array}{*{20}{c}} 1&2&3&4\\ 4&1&2&3\\ 3&4&1&2\\ 2&3&4&1 \end{array}} \right]$$

$$y\left( n \right) = \left\{ {\;\begin{array}{*{20}{c}} {14}\\ \uparrow \end{array},\;\begin{array}{*{20}{c}} {16}\\ {} \end{array},\begin{array}{*{20}{c}} 14\\ {} \end{array},\begin{array}{*{20}{c}} {16}\\ {} \end{array}} \right\}$$

# Two discrete time signals $$x\left[ n \right] = \left\{ {1,2, - \mathop 3\limits_ \uparrow ,4} \right\}$$ and $$h\left[ n \right] = \left\{ {2,\mathop 5\limits_ \uparrow } \right\}$$ are convolvedusing a 4 – point circular convolution method, find the value of the convolved signal at  n = 3.

## Detailed Solution

given signals are-

\eqalign{ & x\left[ n \right] = \left\{ {1,2, - \mathop 3\limits_ \uparrow ,4} \right\} \cr & h\left[ n \right] = \left\{ {2,\mathop 5\limits_ \uparrow } \right\} \cr}

and let the output convolved signal is -

$$y\left[ n \right] = x\left[ n \right] \otimes h\left[ n \right]$$

To find 4 – point circular convolution make length of the input signals equal to 4

i.e

\eqalign{ & x\left[ n \right] = \left\{ {\matrix{ 1 & 2 & { - 3} & 4 \cr {} & {} & \uparrow & {} \cr } } \right\}{\rm{or}}\ x\left[ n \right] = \left\{ {\matrix{ { - 3} & 4 & 1 & 2 \cr \uparrow & {} & {} & {} \cr } } \right\} \cr & h\left[ n \right] = \left\{ {\matrix{ 2 & 5 & 0 & 0 \cr {} & \uparrow & {} & {} \cr } } \right\}{\rm{or}}\ h\left[ n \right] = \left\{ {\matrix{ 5 & 0 & 0 & 2 \cr \uparrow & {} & {} & {} \cr } } \right\} \cr & y\left[ n \right] = \left[ {\matrix{ { - 3} & 2 & 1 & 4 \cr 4 & { - 3} & 2 & 1 \cr 1 & 4 & { - 3} & 2 \cr 2 & 1 & 4 & { - 3} \cr } } \right]\left[ {\matrix{ 5 \cr 0 \cr 0 \cr 2 \cr } } \right] \cr & = \left[ {\matrix{ { - 3 \times 5} & + & {4 \times 2} \cr {4 \times 5} & + & {1 \times 2} \cr {1 \times 5} & + & {2 \times 2} \cr {2 \times 5} & + & { - 3 \times 2} \cr } } \right] = \left[ {\matrix{ { - 7} \cr {22} \cr 9 \cr 4 \cr } } \right] \cr & \Rightarrow y\left[ n \right] = \left\{ {\matrix{ { - 7} & {22} & 9 & 4 \cr \uparrow & {} & {} & {} \cr } } \right\} \cr & \Rightarrow y\left[ 3 \right] = 4 \cr}


text:
eBird Status and Trends divides space and time into variably sized "stixels" within which individual base models are fit. The process of stixelization is performed many times and the prediction at any given point is the median of the predictions from all the stixels that that point falls in. For a given spatiotemporal extent, this function identifies the set of stixels whose centroids fall within that extent and calculates the spatial footprint of these stixels, i.e. a surface indicating the proportion of the selected stixels that contribute information to model estimates at each location. This footprint gives an estimate of where the information for the model predictions, predictor importances (PIs), and partial dependencies (PDs) come from.

stixel_footprint(path, ext)

# S3 method for stixel_footprint
plot(x, ...)

## Arguments

path character; full path to directory containing the eBird Status and Trends products for a single species. ebirdst_extent object; the spatiotemporal extent to filter the data to. stixel_footprint object to map. ignored.

## Value

A stixel_footprint object consisting of a list with three elements:

• footprint: a RasterStack giving the percentage of the selected stixels that are contributing to each grid cell.

• centroids: an sf object containing the stixel centroids points.

• extent: an ebirdst_extent object specifying the chosen spatiotemporal extent.

The stixel footprint can be mapped by calling plot() on the returned stixel_footprint object.

## Examples

if (FALSE) {
# download example data
path <- ebirdst_download("example_data")
# or get the path if you already have the data downloaded
path <- get_species_path("example_data")

# define a spatiotemporal extent
bb_vec <- c(xmin = -86, xmax = -83, ymin = 42, ymax = 45)
e <- ebirdst_extent(bb_vec, t = c("05-01", "05-31"))

# calculate effective extent map
footprint <- stixel_footprint(path, ext = e)
plot(footprint)
}


text:
# Equivalence of Definitions of Separated Sets/Definition 2 implies Definition 1

## Theorem

Let $T = \struct{S, \tau}$ be a topological space.

Let $A, B \subseteq S$.

Let $U,V \in \tau$ satisfy:

$A \subset U$ and $U \cap B = \empty$
$B \subset V$ and $V \cap A = \empty$

where $\empty$ denotes the empty set.

Then

$A^- \cap B = A \cap B^- = \empty$

where $A^-$ denotes the closure of $A$ in $T$.

## Proof

From Empty Intersection iff Subset of Relative Complement, $B \subseteq S \setminus U$.

By the definition of a closed set, the relative complement of $S \setminus U$ is closed in $T$.

From Set Closure is Smallest Closed Set, $B^- \subseteq S \setminus U$.

From Empty Intersection iff Subset of Relative Complement, $B^- \cap U = \empty$.

Then

 $\displaystyle B^- \cap A$ $=$ $\displaystyle B^- \cap \paren {U \cap A}$ Intersection with Subset is Subset $\displaystyle$ $=$ $\displaystyle \paren {B^- \cap U} \cap A$ Intersection is Associative $\displaystyle$ $=$ $\displaystyle \empty \cap A$ As $B^- \cap U = \empty$ $\displaystyle$ $=$ $\displaystyle \empty$ Intersection with Empty Set

Similarly, $A^- \cap B = \empty$.

$\blacksquare$


text:
## Multivariate Normal Conditional Distribution

Previously I made a post about diagonalizing a positive definite symmetric matrix . One of the applications of this within statistics is to diagonalize the variance matrix of a multivariate normal in order to derive conditional distributions. Let

$Y\sim N_{p}(m,V)$
Consider multiplying Y by the following matrix
$\begin{pmatrix} 1 & -V_{12}V_{22}^{-1}\\ 0 & 1\\ \end{pmatrix}Y \sim N_{p}\left( \begin{pmatrix} m_{1} - V_{12}V_{22}^{-1}m_{2} \\ m_{2}\\ \end{pmatrix},\begin{pmatrix} V_{11}-V_{12}V_{22}^{-1}V_{21} & 0 \\ 0 & V_{22}\\ \end{pmatrix}\right)$
i.e.
$\begin{pmatrix} Y_{1}-V_{12}V_{22}^{-1}Y_{2} \\ Y_{2}\\ \end{pmatrix}\sim N\left( \begin{pmatrix} m_{1} - V_{12}V_{22}^{-1}m_{2} \\ m_{2}\\ \end{pmatrix},\begin{pmatrix} V_{11}-V_{12}V_{22}^{-1}V_{21} & 0 \\ 0 & V_{22}\end{pmatrix} \right)\\$
The covariance matrix has now been diagonalized. This is useful because zero covariance implies independence for normally distributed random variables and so it follows that

$Y_{1}-V_{12}V_{22}^{-1}Y_{2} \sim N( m_{1} - V_{12}V_{22}^{-1}m_{2} ,V_{11}-V_{12}V_{22}^{-1}V_{21})$
Conditiong on Y2 it follows that the conditional distribution is
$Y_{1}|Y_{2} \sim N( m_{1} + V_{12}V_{22}^{-1}(Y_{2}-m_{2} ),V_{11}-V_{12}V_{22}^{-1}V_{21})$
Notice how the variance of the conditional normal distribution is the marginal variance of Y1 minus something. That is to say the variance of Y1 is reduced given the knowledge of Y2. The variance can be recognized as the Schur complement of the covariance matrix with respect to V22. A similar treatment yields
$Y_{2}|Y_{1} \sim N( m_{2} + V_{21}V_{11}^{-1}(Y_{1}-m_{1} ),V_{22}-V_{21}V_{11}^{-1}V_{12})$


text:
#### Vol. 10, No. 8, 2017

 Recent Issues
 The Journal About the Journal Editorial Board Editors’ Interests Subscriptions Submission Guidelines Submission Form Policies for Authors Ethics Statement ISSN: 1948-206X (e-only) ISSN: 2157-5045 (print) Author Index To Appear Other MSP Journals
Incompressible immiscible multiphase flows in porous media: a variational approach

### Clément Cancès, Thomas O. Gallouët and Léonard Monsaingeon

Vol. 10 (2017), No. 8, 1845–1876
##### Abstract

We describe the competitive motion of $N+1$ incompressible immiscible phases within a porous medium as the gradient flow of a singular energy in the space of nonnegative measures with prescribed masses, endowed with some tensorial Wasserstein distance. We show the convergence of the approximation obtained by a minimization scheme á la R. Jordan, D. Kinderlehrer and F. Otto (SIAM J. Math. Anal. 29:1 (1998) 1–17). This allows us to obtain a new existence result for a physically well-established system of PDEs consisting of the Darcy–Muskat law for each phase, $N$ capillary pressure relations, and a constraint on the volume occupied by the fluid. Our study does not require the introduction of any global or complementary pressure.

However, your active subscription may be available on Project Euclid at
https://projecteuclid.org/apde

We have not been able to recognize your IP address 34.239.150.57 as that of a subscriber to this journal.
Online access to the content of recent issues is by subscription, or purchase of single articles.

or by using our contact form.


text:
Friday
March 14, 2014

# Homework Help: chemistry

Posted by Andrea on Sunday, January 23, 2011 at 11:06am.

A 0.50 {\rm g} sample of vegetable oil is placed in a calorimeter. When the sample is burned, 18.9 {\rm kJ} are given off.

Related Questions

chemistry - a .50 sample if vegetable oil is placed in a calorimeter. When the ...
Chemistry - In the following experiment, a coffee-cup calorimeter containing 100...
chemistry - Calculate the specific heat (\rm{J/g \; ^\circ C}) for a 18.5-\rm g ...
chemistry - How many grams of water can be cooled from 35^\circ {\rm C} to 16^\...
Chem104 - Calculate the specific heat $$(\rm{J/g \; ^\circ C})$$ for a 18.5-\(\...
chem - Calculate the specific heat (\rm{J/g \; ^\circ C}) for a 18.5-\rm g ...
chemistry - A 337-\rm mL sample of unknown \rm HCl solution reacts completely ...
chemistry - nitroglycerin (used medically as a vasodilator to treat heart ...
Chemistry - Maleic acid is a carbon-hydrogen-oxygen compound used in dyeing and ...
chemistry 106 - A 0.1589 g sample of solid magnesium is burned in a bomb ...

Search
Members


text:
# Idea

Under certain conditions on a given homotopy theory on a category $C$ (namely if $C$ satisfies the axioms of a category of fibrant objects), the morphisms in the homotopy category $Ho(C)$ are represented already by spans

$\array{ \hat X &\to& A \\ \downarrow^\simeq \\ X }$

(ana-morphisms) instead of longer sequences of zig-zags.

In such a case it makes sense to address such a span as a nonabelian cocycle on $X$ with coefficients in $A$ and to regard

$H(X,A) := Ho(C)(X,A)$

as the cohomology of $X$ with coefficients in $A$. From the point of view of generalized sheaf cohomology this can be understood by recognizing the replacement object $\hat X$ appearing here as a codescent object.

# Literature

The fundamental ideas and facts are given in

This develops the theory of localization in categories of fibrant objects and then applies it to cohomology with coefficients in sheaves with values in combinatorial spectra.

Homotopical cohomology theory in the context of the homotopy theory of simplicial presheaves (presheaves with values in simplicial sets) has been much developed by Jardine. For instance

• J. Jardine, Cocycle categories (arXiv)

Last revised on June 30, 2009 at 10:20:54. See the history of this page for a list of all contributions to it.


text:
# Thunder Ketchup Territory

Electricity and Magnetism Level 1

An ion has a charge of approximately 4.8*10^-19 coulombs. Which of the following is necessarily true?

×


text:
# A Gem of Geometry and Analysis

Discussion in 'Physics & Math' started by rpenner, Feb 28, 2017.

1. ### rpennerFully WiredStaff Member

Messages:
4,827
Three special curves, symmetric about the x-axis, go vertically through the point (x=1,y=0). $r = \sqrt{x^2 + y^2}$

The vertical line: $x = 1$
The unit hyperbola: $x^2 - y^2 = 1$
The unit circle. $x^2 + y^2 = 1$

If we ignore parts left of the y-axis for now, we can describe each of these curve's x-values as functions of y.

The vertical line: $X_{0}(y) = \sqrt{1}$
The unit hyperbola: $X_{-1}(y) = \sqrt{1 + y^2}$
The unit circle. $X_{1}(y) = \sqrt{1 - y^2} ; \quad -1 \leq y \leq 1$

Note: $X_{\alpha}(y) = X_{\alpha}(-y)$ means these curves are symmetric about the x-axis.

Now, if for a certain value $y_t$ we want to know the area (A) in the "triangle" or "wedge" between the origin, the points $\left( X_{\alpha}(y_t), \pm y_t \right)$* and the curve we have:

The vertical line:
$A_{0}(y_t) = 2 \int_0^{y_t} X_0(y) - \frac{X_{0}(y_t)}{y_t} y \, dy \\ = 2 \int_0^{y_t} 1 dy - \frac{1}{y_t} \int_0^{y_t} 2 y dy \\ = 2 y_t - \frac{1}{y_t} y_t^2 = y_t$
The unit hyperbola:
$A_{-1}(y_t) = 2 \int_0^{y_t} X_{-1}(y) - \frac{X_{-1}(y_t)}{y_t} y \, dy \\ = 2 \int_0^{y_t} \sqrt{1 + y^2} dy - \frac{\sqrt{1 + y_t^2}}{y_t} \int_0^{y_t} 2 y dy \\ = y_t \sqrt{1 + y_t^2} + \ln \left( \sqrt{1 + y_t^2} + y_t \right) - y_t \sqrt{1 + y_t^2} \\ = \ln \left( X_{-1}(y_t) + y_t \right)$
The unit circle.
$A_{1}(y_t) = 2 \int_0^{y_t} X_{1}(y) - \frac{X_{1}(y_t)}{y_t} y \, dy \\ = 2 \int_0^{y_t} \sqrt{1 - y^2} dy - \frac{\sqrt{1 - y_t^2}}{y_t} \int_0^{y_t} 2 y dy \\ = y_t \sqrt{1 - y_t^2} - i \ln \left( \sqrt{1 - y_t^2} + i y_t \right) - y_t \sqrt{1 - y_t^2} \\ = -i \ln \left( X_{1}(y_t) + i y_t \right)$

Now if we parameterize the original curves in terms of the areas swept out, we have:

The vertical line: $t = A_{0}(y) = y \Rightarrow x(t) = 1, y(t) = t$
The unit hyperbola: $\rho = A_{-1}(y) = \ln( X(y) + y ) = \ln ( x + y ) \\ \Rightarrow x(\rho) = \frac{1}{2} \left(e^{\rho} + e^{-\rho} \right), y(\rho) = \frac{1}{2} \left(e^{\rho} - e^{-\rho} \right)$
The unit circle: $\theta = A_{1}(y) = -i \ln( X(y) + i y ) = \frac{1}{i} \ln ( x + i y ) \\ \Rightarrow x(\theta) = \frac{1}{2} \left(e^{i \theta} + e^{-i \theta} \right), y(\theta) = \frac{1}{2 i} \left(e^{i \theta} - e^{-i \theta} \right)$

So that's the motivation behind:
$\cosh \rho = \frac{1}{2} \left(e^{\rho} + e^{-\rho} \right) \\ \sinh \rho = \frac{1}{2} \left(e^{\rho} - e^{-\rho} \right) \\ \sinh^{-1} y = \ln \left( y + \sqrt{1 + y^2} \right) \\ e^{\rho} = \cosh \rho + \sinh \rho \\ \cos \theta = \frac{1}{2} \left(e^{i \theta} + e^{-i \theta} \right) \\ \sin \theta = \frac{1}{2 i} \left(e^{i \theta} - e^{-i \theta} \right) \\ \sin^{-1} y = -i \ln \left( iy + \sqrt{1 - y^2} \right) \\ e^{i \theta} = \cos \theta + i \sin \theta$

Which follows from the geometry of the curves and $\ln x = \int_1^{x} \frac{1}{t} dt$ being the inverse function of $e^x$.

* // Edit this has been fixed.

Last edited: Feb 28, 2017
iceaura, The God and Confused2 like this.
2. ### Google AdSenseGuest Advertisement

to hide all adverts.
3. ### The GodValued Senior Member

Messages:
3,093
This new thread again begs the question, what is required to justify the name of site as sciforums.

News articles from inferno stopped, cause poor response; alternative theories..generally no discussion, only the pusher is abused by this forum piranhas.

So such tutorials? I doubt as majority here lack intellect even to decipher the basics of what rpenner is talking about.

This forum is more or less gripped by Trump Mania and US politics. It appears to me that one of the Mods (Kittamaru) has forgotten her brief and making this as antitrumpforum rather than science forum.

4. ### Google AdSenseGuest Advertisement

to hide all adverts.
5. ### Confused2Registered Senior Member

Messages:
369
A student at the back of the remedial class has started to make progress after swapping all x's and y's.

6. ### Google AdSenseGuest Advertisement

to hide all adverts.
7. ### arfa branecall me arfValued Senior Member

Messages:
5,104
I might comment that the OP is a nice refresher, me having done something similar long ago, but I think it was with the asymptotes of the hyperbola.

Please Register or Log in to view the hidden image!

What rpenner said, without the circle which would intersect the hyperbola at {-1,1}.

Last edited: Mar 1, 2017
8. ### arfa branecall me arfValued Senior Member

Messages:
5,104
Animation of rpenner's "areas swept out". The parameter t is the position of the intersections of the red and blue lines, with the vertical line at x = 1.

Please Register or Log in to view the hidden image!

Last edited: Mar 1, 2017
Confused2 likes this.
9. ### rpennerFully WiredStaff Member

Messages:
4,827
Imagine my disappointment to learn these are not arfa brane's original works. https://en.wikipedia.org/wiki/Hyperbolic_angle#Comparison_with_circular_angle

The differential equation $y' + a y = 0$ has general solution
$y(x) = \left\{ { \begin{array}{lll} k_0 e^{-a x} & \quad & ; \; a \neq 0 \\ k_1 & & ; \; a = 0 \end{array} } \right.$
, while the differential equation $y'' + b y' + c y = 0$ has general solution:
$y(x) = \left\{ \begin{array}{lll} k_2 e^{ \frac{-b + \sqrt{b^2 - 4c}}{2} \, x} + k_3 e^{ \frac{-b - \sqrt{b^2 - 4c}}{2} \, x} ; b^2 \neq 2c & \quad & ; \; b^2 \neq 4c \\ k_4 e^{-\frac{b}{2} x} + k_5 \, x \, e^{-\frac{b}{2} x} & & ; \; b \neq 0, \, b^2 = 4c \\ k_6 + k_7 x & & ; \; b = c = 0 \end{array} \right.$

This first solution can also be written as:
$y(x) = e^{- \frac{b}{2} x} \left( k_2 e^{\sqrt{ \left(\frac{b}{2}\right)^2 - c} \, x} + k_3 e^{-\sqrt{ \left(\frac{b}{2}\right)^2 - c} \, x} \right) \\ = e^{- \frac{b}{2} x} \left( (k_2 + k_3 ) \cosh \left( \sqrt{ \left(\frac{b}{2}\right)^2 - c} \, x \right) + (k_2 - k_3) \sinh \left( \sqrt{ \left(\frac{b}{2}\right)^2 - c} \, x \right) \right) \\ = e^{- \frac{b}{2} x} \left( (k_2 + k_3 ) \cos \left( \sqrt{ c - \left(\frac{b}{2}\right)^2 } \, x \right) + i (k_2 - k_3) \sin \left( -i \sqrt{ \left(\frac{b}{2}\right)^2 - c} \, x \right) \right)$
and if $b^2 - 4c$ is real,
$y(x) = e^{- \frac{b}{2} x} \left( (k_2 + k_3 ) \cos \left( \sqrt{ c - \left(\frac{b}{2}\right)^2 } \, x \right) + i (k_2 - k_3) \sin \left( \sqrt{ c - \left( \frac{b}{2}\right)^2 } \, x \right) \right)$

Although these differential equations seem rather abstract, they arise naturally in modeling simple physical systems, including analog electric circuits and partially account for the ubiquitousness of sinusoidal signals showing up on equipment for a certain class of science fiction. Thank you, ITV.

Last edited: Mar 9, 2017

Messages:
3,093
11. ### sweetpeaRegistered Senior Member

Messages:
551
Rpenner, I don't get that last remark about ITV. Were you thinking of Doctor Who? That's BBC.

12. ### rpennerFully WiredStaff Member

Messages:
4,827
My mistake, it's ITC, not ITV. IMDB says it aired on ITV in the UK, but I wasn't there and can't actually name from memory the network or local channel which brought it to us in the US.

http://www.imdb.com/title/tt0072564/

See http://catacombs.space1999.net/main/cguide/umndabow.html "Close up of dome 3 screen."

Ben Carson might be wrong about the way human memory works, but we do let a fascinating amount of trivia pile up over the years.

Last edited: Mar 9, 2017


text:
# Math Help - precal help

1. ## precal help

simplify: (x-(1/x^2))/(x-(1/x^3))

simplify: 4+___d___
4+_4_
4+d

2. I'm not quite sure what the second question says, but for the first question you'll be needing common denominators. Working on the numerator first, we have $x - \frac{1}{x^2}$. To get a common denominator, multiply $x \cdot \frac{x^2}{x^2}$ so that you get $\frac{x^3}{x^2} - \frac{1}{x^2}$. Subtracting yields $\frac{x^3 - 1}{x^2}$. Can you simplify the denominator?

3. the bottom one, with many parantheses, says 4+(d/(4+(4/(4+d))))
i simplified the bottom part, but what do i do next?

4. For the first question, you should have gotten $\frac{x^4 - 1}{x^3}$ as the denominator, which leaves you with $\frac{\frac{x^3 - 1}{x^2}}{\frac{x^4 - 1}{x^3}}$. Now, you can rearrange this (using the reciprocal rule) to $\frac{x^3(x^3 - 1)}{x^2(x^4 - 1)}$. You can cancel out x^2 in the top and bottom to yield $\frac{x(x^3 - 1)}{x^4 - 1}$ and then remove a factor of x-1 from both top and bottom to yield $\frac{x(x^2 + x + 1)}{x^3 + x^2 + x + 1}$ and that's as simplified as it gets.

For the second question, using the parentheses, work from the inside out, using common denominators to combine fractions.


text:
# Summary statistics

## Basis statistics for a single variable

### N

The is the size of the sample.

### Sample range

#### Minimum

This is the smallest value in the sample.

#### Maximum

This is the largest value in the sample.

#### Range

This is the difference between the maximum and minimum.

#### Median

This is the value whereby 50% of the sample can be found below the value.

#### Percentiles

The $$x$$th percentile is the value by which $$x\%$$ of the values can be found below it.

#### Interquartile range

This is the differnence between the $$25$$th percentile and the $$75$$th percentile.

### Sample mode

The is the most common value in the sample.

## Sample moments

### Sample mean

We previously defined the population mean is defined as $$\mu=E[X]$$.

The sample mean is defined as $$\bar x = \dfrac{1}{n}\sum_i x_i$$.

#### Centred mean

We can subtract the mean from each entry in the sample. This will leave a new mean of $$0$$. This is convenient for many calculations.

### Sample variance

We previously defined the population variance as $$\sigma^2=E[(X-\mu)^2]$$.

We define the sample variance as $$\sigma^2=\dfrac{1}{n}\sum_i(x_i-\bar x)^2$$.

We can calculate this using matrices:

$$M=X-\bar x$$

$$\sigma^2=\dfrac{1}{n}M^TM$$.

#### Centred variance

If $$\bar x =0$$ then:

$$\sigma^2=\dfrac{1}{n}X^TX$$.

## Statistics for two variables

### Sample covariance

#### Calculating

We previously defined the population covariance as $$\sigma_{XY}=E[(X-\mu_X)^T(Y-\mu_Y)]$$.

We define the sample covariance as $$\sigma_{XY}=\dfrac{1}{n}\sum_i(x_i-\bar x)(y_i-\bar y)$$.

We can calculate this using matrices:

$$M=X-\bar x$$

$$N=Y-\bar y$$

$$\sigma_{XY}=\dfrac{1}{n}M^TN$$.

#### Sample correlation

$$\rho_{XY}=\dfrac{\sigma_{XY}}{\sigma_X \sigma_Y}$$

#### Covariance matrix

If we have $$n$$ variables we can have a $$n\times n$$ matrix $$\Sigma$$ where:

$$\Sigma_{ij} = \sigma_{ij}=\dfrac{1}{n}(X_i-\bar x_i)^T(X_j-\bar x_j)$$

#### Centred covariance

If $$\bar x = \bar y = 0$$ then:

$$\sigma_{XY}=\dfrac{1}{n}X^TY$$

#### Correlation matrix

Here each entry is the correlation rather than the covariance.

### Pearson correlation coefficient

The Pearson correlation coefficient is definited as the covariance normalised by the individual variances.

It is between $$-1$$ (total negative linear correlation), $$0$$ (no linear correlation) and $$1$$ (total negative linear correlation).

$$p_{X,Y}=\dfrac{cov (X,Y)}{\sigma_X\sigma_Y}$$

### Spearman rank correlation

#### Ranking variables

For each of $$2$$ variables we create a ranking of them.

From $$X$$ and $$Y$$ we then have $$R_X$$ and $$R_Y$$.

#### Calculating the Spearman rank correlation

We then calculate the Pearson correlation coefficient between the rankings.

$$r_S=\dfrac{cov(R_X, R_Y)}{\sigma_{R_X}\sigma_{R_Y}}$$

## Updating statistics

### Updating the mean, variance and covariance

#### Mean

$$\bar x_{n+1} = \dfrac{n\bar x_n+x_{n+1}}{n+1}$$

#### Variance

If it is centred:

$$\sigma_n^2=\dfrac{1}{n}X_n^TX_n$$

So:

$$\sigma_{n+1}^2=\dfrac{n\sigma_n^2 +x_{n+1}^tx_{n+1}}{n+1}$$

#### Covariance

If it is centred:

$$\sigma_{XY}^n=\dfrac{1}{n}X_n^TY_n$$

So:

$$\sigma_{XY}^{n+1}=\dfrac{n\sigma^n_{XY}+x_{n+1}^ty_{n+1}}{n+1}$$

## Splitting data into classes

### Splitting data into classes

We have $$X$$, and we want to split this into $$m$$ different matrices.

We can do this by creating an index for each group, $$v$$, where it is $$1$$ if in the group and $$0$$ otherwise.

We then select $$X[v]$$.

Alternatively we can do $$v^TX$$, however we must then trim the extra variables.


text:
# Chain of prime ideals of maximal length

Consider the domain $R=\mathbb{C}[x,y]/(y^2-x^3)$.

What would be an example of a chain of prime ideals of $R$ of maximal length?

-

The hardest part here seems to be proving that $y^2 - x^3$ is irreducible, which I'll attempt to show below. In general, an irreducible hypersurface in $\mathbf A^n$ has dimension $n - 1$. This is proved in most texts on algebraic geometry — see, for example, Proposition 2.25 of Milne's notes. [Prof Emerton notes in the comments that here $R$ is visibly finite over $\mathbf C[x]$, and hence these two rings have the same dimension.] So take the zero ideal of $R$ and a maximal ideal (corresponding to a point on the curve) of $R$.

To conclude, suppose we have $y^2 - x^3 = f(x, y)g(x, y)$, where $y$ occurs in $f(x, y)$. Suppose that $\deg_yf = 1$. Then $\deg_y g = 1$ and we can write $$f(x, y) = a(x)y + b(x) \qquad \text{and} \qquad g(x, y) = c(x)y + d(x).$$ Then $a(x)c(x) = 1$, so after shuffling around constant factors we can have $a = c = 1$. Multiplying things out, we get $$y^2 - x^3 = y^2 + y(b(x) + d(x)) + b(x)d(x).$$ So we must have $d = -b$ and hence $\deg b = \deg d$. But then the degree of the left side with respect to $x$ is even, which is absurd. The case of $\deg_yf = 2$ can be treated using the same ideas and is slightly easier to boot.

I would be very interested in a more geometric or at least conceptual way of looking at this. My dimension-fu is a little rusty.

-
Please write about why $y^2-x^3$ is irreducible. Thanks! –  Dave Sep 11 '11 at 19:13
Sure. I've been building furniture and trying to think of a less ad hoc way of doing this, but I'll just write up the first thing that came to mind and we'll see if it's right :) –  Dylan Moreland Sep 11 '11 at 22:07
Dear Dylan, You don't need the hauptidealsatz. If you observe that $\mathbb C[x,y]/(y^2 - x^3)$ is finite over $\mathbb C[x]$, it follows that it has dimension $1$. Best wishes, –  Matt E Sep 12 '11 at 5:10
@Matt That's a very good point. It is sad to see all of the German words leave this post, but so it goes. –  Dylan Moreland Sep 12 '11 at 5:23
What is meant by $R$ is finite over $\mathbb{C}[x]$? –  Dave Sep 12 '11 at 20:29


text:
# Question #9a436

There are 3 C-H bonds, 1 C-O bond and 1 O-H bond in methanol, $C {H}_{3} O H$. Because the electronegativity (EN) difference between C and H is very small, the C-H bond is considered non-polar. The EN of O is very large, resulting in both the C-O and the O-H bonds being polar.


text:
# Implement a Truth-Machine

A truth-machine (credits goes to this guy for coming up with it) is a very simple program designed to demonstrate the I/O and control flow of a language. Here's what a truth-machine does:

• Gets a number (either 0 or 1) from STDIN.

• If that number is 0, print out 0 and terminate.

• If that number is 1, print out 1 forever.

# Challenge

Write a truth-machine as described above in your language of choice. The truth-machine must be a full program that follows these rules:

• take input from STDIN or an acceptable alternative
• If your language cannot take input from STDIN, it may take input from a hardcoded variable or suitable equivalent in the program
• must output to STDOUT or an acceptable alternative
• If your language is incapable of outputting the characters 0 or 1, byte or unary I/O is acceptable.
• when the input is 1, it must continually print 1s and only stop if the program is killed or runs out of memory
• the output must only be either a 0 followed by either one or no newline or space, or infinite 1s with each 1 followed by either one or no newline or space. No other output can be generated, except constant output of your language's interpreter that cannot be suppressed (such as a greeting, ANSI color codes or indentation). Your usage of newlines or spaces must be consistent: for example, if you choose to output 1 with a newline after it all 1s must have a newline after them.

• if and only if your language cannot possibly terminate on an input of 0 it is acceptable for the code to enter an infinite loop in which nothing is outputted.

Since this is a catalog, languages created after this challenge are allowed to compete. Note that there must be an interpreter so the submission can be tested. It is allowed (and even encouraged) to write this interpreter yourself for a previously unimplemented language. Other than that, all the standard rules of must be obeyed. Submissions in most languages will be scored in bytes in an appropriate preexisting encoding (usually UTF-8).

# Catalog

The Stack Snippet at the bottom of this post generates the catalog from the answers a) as a list of shortest solution per language and b) as an overall leaderboard.

## Language Name, N bytes

where N is the size of your submission. If you improve your score, you can keep old scores in the headline, by striking them through. For instance:

## Ruby, <s>104</s> <s>101</s> 96 bytes

If there you want to include multiple numbers in your header (e.g. because your score is the sum of two files or you want to list interpreter flag penalties separately), make sure that the actual score is the last number in the header:

## Perl, 43 + 2 (-p flag) = 45 bytes

You can also make the language name a link which will then show up in the snippet:

## [><>](http://esolangs.org/wiki/Fish), 121 bytes

 <link rel="stylesheet" type="text/css" href="//cdn.sstatic.net/codegolf/all.css?v=83c949450c8b">

Shortest Solution by Language

Language	User	Score

Leaderboard

	Author	Language	Size

{{PLACE}}	{{NAME}}	{{LANGUAGE}}	{{SIZE}}	Link

{{LANGUAGE}}	{{NAME}}	{{SIZE}}	Link

• Can we assume that the program halts when the processor finishes executing the written code, for a machine code entry? – lirtosiast Nov 3 '15 at 16:58
• Assuming any behaviour is fine for all invalid inputs? – Cruncher Nov 3 '15 at 17:33
• @Cruncher Yes, the only inputs you should expect to get are 0 and 1. – a spaghetto Nov 3 '15 at 17:38
• Catalog is borked. – Addison Crump Nov 6 '15 at 15:18
• Catalog appears to consider Bf and bf to be different languages. – Mooing Duck Nov 10 '15 at 1:13

## Gol><>, 5 bytes

IZh1n

Thanks to JoKing for helping golf this down further!!!

Try it online!

# Tamsin, 19 bytes

main="0"|{print 1}.

## Explanation

The main production first tries to read a 0. If it succeeds, it is returned, and, because this is the main production, printed.

Otherwise, it ignores the input and tries the alternative, which is {print 1}. The { } brackets denote a loop that continues running as long as its content succeeds, and a print statement always succeeds, so this loops forever.

# Python 3, 41 bytes

a=input()
while(a=='1'):print(1)
print(0)

Try it online!

# INTERCAL, 89 bytes

DOWRITEIN.1PLEASE.3<-#1$.1DOCOMEFROM(2)DOREADOUT.1(2)PLEASE(1)NEXT(1)DO(1022)NEXTDOGIVEUP  Try it online! Looking at some answers to this challenge, I noticed that the current INTERCAL answer was barely golfed at all, with 141 bytes 30 of which are whitespace. Not hard to outdo! Uses native INTERCAL-72 integer I/O, that is, the input is ZERO or ONE (or some translation thereof) with a trailing newline, and the output is in "butchered Roman numerals". Explanation: DO WRITE IN .1 Inputs a number to the 16-bit variable .1. PLEASE .3 <- #1$ .1

Sets .3's value to 1 mingled with .1's value. Since .1 holds either 0 or 1, .3 is set to either 2 or 3.

DO COME FROM (2)

If execution would move on normally from statement (2), it goes here instead.

DO READ OUT .1

Prints the value in .1.

(2) PLEASE (1) NEXT

This is statement (2). It places itself on the NEXT stack and moves execution to statement (1). It does not trigger the COME FROM unless RESUMEd to.

(1) DO (1022) NEXT

This is statement (1). It NEXTS to statement (1022) in syslib, which then itself NEXTS to statement (1023) in syslib, which reads PLEASE RESUME .3. This pops a non-zero number of entries equal to .3 off the NEXT stack and resumes execution at the last one popped. Since there are at this point three entries on the NEXT stack, corresponding to (2), (1), and (1022) (RESUME works just fine without labels, it just so happens that all of the NEXTs here have them), and .3 is 2 or 3 depending on whether .1 is 0 or 1, this goes to and moves on from either (1) if .1 is 0, or (2) if .1 is 1. If this RESUMEs to (2), the COME FROM takes effect and begins an infinite loop (and since this outcome leaves the NEXT stack empty, the program does not disappear into the black lagoon after 80 loops).

DO GIVE UP

If (1) was RESUMEd to, execution moves here, and this terminates the program without an error.

(I'll edit in a version with Turing Tape string I/O some time later.)

# NuStack, 82 bytes

putchar(c:char):int;f(i:int):int{if(i>0)putchar('1');else while(1>0)putchar('0');}

Been working on this compiler for a month and a half. Still very much a WIP, but finally at a point where I can do some PPCG with it :D

Unlike all of my other languages, this isn't some toy, esoteric, interpreted language.
It's a serious language that compiles directly to assembly (nasm syntax).

I'll probably opt to get NuStack on TIO once it's notably more feature-complete than it currently is.

## Explanation:

Ungolfed version:

putchar(c: char): int;

f(i: int): int {
if(i > 0)
putchar('1');
else
while(1 > 0)
putchar('0');
}

The first line is a function prototype that allows you to call a function defined elsewhere (think C header files)

putchar in particular is currently the only function in libns, the language's standard library. It takes a single char, and outputs it to stdout. libns is currently available for 64bit linux, so it just makes a syscall using sys_write(), and 32bit "raw", ie not running on a kernel or operating system, where putchar will use the int 0x10 interrupt to print the character in TTY mode

NuStack uses post-fix types, similar to TypeScript, and there is no type inference, so types must always be explicitly declared.

NuStack also doesn't have type casts yet, or do..while loops, so this is, as far as I know, the golfiest way to do it.

# GolfScript, 13 bytes

~{.}{.p}while

### Explanation

~       # convert STDIN to an integer

{.}     # while loop condition: remains the same--the input
{.p}    # while loop body: print the input
while

This is one of my first golfs!

# Ruby + -np, 16 12 bytes

p 1while~/1/

Try it online!

~/1/ matches the last line of input to the regular expression /1/

Edit: replaced ;p 0 with the -p flag making the answer -np complete, thanks to @ValueInk

• you don't have to count flags any longer; just note in the body which one you've used (as you already have done) – Giuseppe Mar 5 '18 at 23:14
• @Giuseppe thanks, is this the consensus opinion now? – Asone Tuhid Mar 5 '18 at 23:16
• Yeah, see here. – Giuseppe Mar 5 '18 at 23:18
• @Giuseppe so should I call it Ruby + -n? – Asone Tuhid Mar 5 '18 at 23:28
• Use the -p flag instead to implicit print the zero ;p – Value Ink Jun 5 at 2:10

## Enterprise, 128 bytes

/©©//NDANDA/final disruptive class fdcBit{final immutable void main(){var Money i=read();;;write(i);;;while(i==1){write(i);;;}}}

It's really annoying how the specification isn't very clear, so I had to guess a lot of things.

## Keg, 1287 5 bytes

:[{:.

This duplicates an inputted string(the empty-: input mechanism was made to implement the Truth-machine). If the character is 1, output the character forever; otherwise output the character once. This indeed works. Try it online!

• This can now be 8 bytes due to implicit input – EdgyNerd Aug 10 at 9:30

# Rust compiler (nightly), 86 bytes

#![feature(log_syntax)]macro_rules!t{(0)=>{log_syntax!{0}};(1)=>{log_syntax!{1}t!{1}}}

(playground)

#![feature(log_syntax)]

macro_rules! truth_machine {
(0) => {
log_syntax!(0);
};
(1) => {
log_syntax!(1);
truth_machine!(1);
};
}

truth_machine!(0);
truth_machine!(1);

## Explanation

As the only way to iterate over anything other than the inputs of a macro is recursion, an infinite loop will always end in a stack overflow. I'm considering this error message "constant output of your language's interpreter that cannot be suppressed," as there's no other way to "infinitely" loop. The time for this to occur is dependent on the stack size, and thus most real-world macros will attempt to perform multiple operations per iteration to avoid this. Since this takes more space, I didn't do this. The only ways for a macro to give output are:

• compile_error!, a builtin which will immediately terminate compilation with a message, and is thus not valid for this challenge
• log_syntax!, an unstable builtin which will print its input to the compiler's stdout, with a newline appended
• Returning a value from the macro directly, which directly conflicts with the concept of an infinite loop

I chose to use log_syntax!, as I decided it was the only option that would follow the rules of the challenge. However, it requires a nightly compiler, and 23 additional characters in the source to enable. The syntax of macros is pretty fixed, but one trick I found is that macros called with macro!{} instead of macro!(); do not require a semicolon after, and are thus one character shorter.

?1/
#?
&#|

Try it online!

My first submission with my new language Cascade! Cascade is a tree-like esolang, similar to Pyramid Scheme, but a bit terser and with wrapping boundaries. Ungolfed, this looks more like:

 @ |
? /
#|
&|
^
# |
1 |

First, the ? checks if the printed (#) input (&) is positive. If not, it goes left and terminates since it finds no more instructions. If so, it goes right to the ^, which first executes the left (#1, print 1), then goes to the right, which wraps around back to the ^ for an infinite loop. In the golfed code we use another ? which does a similar thing except with the center and the right, since we know the return value of # is always positive.

# MathGolf, 5 4 3 2 bytes

-1 for dropping block marker

q▲

## Explanation

Implicit input
Starts a block
q  Output TOS without a newline.
▲ Execute the code block while the TOS is true. Executes at least once.
Implicit output

Try it online!

• I think you can drop the Ä since there's nothing before it now. – Unrelated String Oct 13 at 3:16

# Lua For windows, 70 bytes

Use lua for windows for this

I=io.read() If I=="1" then while 1 do print"1" end elseif print"0" end

This program works because it takes a 0 or 1 from stdin then if it's a one it makes a while loop that prints one if it's a 0 it prints 0 then the program ends

• Does this rely on functionality specific to Windows? Why couldn't this be run with Lua on other systems? – Alex A. Nov 4 '15 at 3:16
• This could be shorter if you just called If io.read()=="1" instead of assigning it to an alias. – James Murphy Nov 4 '15 at 5:41

## Ceylon, 91 88 bytes

Improved (explanation at the end):

shared void run()=>("0"<(process.readLine()else"")then{1}.cycled else{0}).each(print);

This was the original (91 bytes):

shared void run(){if("0"<(process.readLine()else"")){while(0<1){print(1);}}else{print(0);}}

Unfortunately the most part goes to reading the input and making sure it is defined.

shared void run() {
while(0<1) {
print(1);
}
} else {
print(0);
}
}

I merged this null check (in the else "" form) with the decision into one if, so when the input is ended without a line being read, it also prints 0. Also, any string sorting less than "0" lexicographically prints 0, and any string lexicographically > "0" will produce the 1-loop.

The 0<1 is used instead of true because it is shorter.

Here is a functional approach, unfortunately it can't compete (107 bytes after whitespace removal) due to the length of parseInteger:

shared void run() {
value i = parseInteger(process.readLine() else "") else 0;
(1:i).cycled.follow(i).each(print);
}

It cycles a range starting at 1 of length i (i.e. either {} or {1}), resulting in {} or {1,1,1,1,...}, prepends i (which results in {0} or {1,1,1,1,1,1,...}), and prints each element.

A different functional approach without variables and parsing is this one (88 bytes, shrinked version at the top):

shared void run() =>
("0" < (process.readLine() else "") then
{ 1 }.cycled else { 0 }).each(print);

This does the case distinction in an expression, using the then and else operators to produce either the {1,1,1,...} stream or the {0} singleton, and then calls print(...) on each element of that stream.

## C#, 120 98 bytes

using c=System.Console;class o{static void Main(){if(c.Read()=='1')for(;;c.Write(1));c.Write(0);}}

Ungolfed:

using c=System.Console;
class o
{
static void Main()
{
for(;;c.Write(1));
c.Write(0);
}
}

• 2-byte gain: int a=c.Read();do c.Write(a-48);while(a>48); – LegionMammal978 Dec 6 '15 at 16:10
• 95 bytes based on @LegionMammal978 answer using c=System.Console;class P{static void Main(){int a=c.Read()-48;do c.Write(a);while(a>0);}} – krontogiannis Aug 29 '16 at 10:26

## x86 (Linux / NASM syntax), 86 bytes

mov dx,1              ; 3rd argument to read(): length of buffer
mov ecx,esp           ; 2nd argument to read(): the buffer
mov ax,3              ; read system call number
int 128               ; invoke syscall, returns eax=1 == num of read bytes
l:mov ax,4            ; start of loop, eax=syscall number of write()
int 128               ; invoke syscall, returns eax=1 == num of written bytes
cmp byte[esp],49      ; compare buffer against '1'
jz l                  ; loop of it's the same
int 128               ; invoke syscall otherwise (syscall 1 == exit)

Compile with nasm -f elf h.asm && ld -o h h.o -m elf_i386 and ignore all warnings. :-)

## Swift, 187 bytes

import Foundation
let i = Int("\(String(data: NSFileHandle.fileHandleWithStandardInput().availableData, encoding: NSUTF8StringEncoding)!.characters.first!)")!
print(i)
while i>0{print(i)}

Sadly this has to read from stdin if it can :( Would be so much smaller if I could just declare it inside...

• Can you not remove the spaces around =, after :, and after ,? – Esolanging Fruit Dec 14 '17 at 0:36

## Scala, 46 bytes

if(readInt==0)print(0)else while(2>1)print(1)

Kinda uninteresting and obvious, but there we go

• ==0 can be replaced with <1 – V.G. Nov 12 '15 at 17:18
• val k=readInt;do{print(k)}while(k>0) – V.G. Nov 12 '15 at 17:24

# Atari Basic, 47 bytes

If I remember the syntax correctly, it will be something like this:

1 input a$2 IF a$="0" THEN end
3 ? a$4 goto 3  Please correct me if I'm wrong. • Do you need some spaces? ("0" THEN, ? a$) – Erik the Outgolfer Jul 22 '16 at 12:35
• @EʀɪᴋᴛʜᴇGᴏʟғᴇʀ I'm not sure, i produced this snippet from memory, i did't use atari basic for over 25 years. – user902383 Jul 22 '16 at 12:41

## Python 2, 46 bytes 34 bytes

x=input()
print x
while x:print x

Basically, it takes in the input, when 1, prints forever (while loop), but if it isn't 1 (when it is zero) it prints and then exits.

This is my first answer! Yay!

## Java, 90 97 bytes

class T{public static void main(String[]a){while(a[0].equals("1"))System.out.println(1);}}

I'm not sure if this counts because it takes 1 or 0 as an argument rather than STDIN. It's been emotional, either way.

Edit: The above does not print zero, the below does:

class T{public static void main(String[]a){do System.out.println(a[0]);while(a[0].equals("1"));}}

• You can save two characters by using print instead of println. (There was no requirement saying each 1 must be on a new line). Also, the command line can be added easily as while(a[0].equals(new java.util.Scanner(System.in).nextLine()). However, I don't think this meets the requirement, since it doesn't print 0. – Xynariz Nov 10 '15 at 1:42
• Fixed to print zero in 97 bytes. I had to use println because print must just be appending to the string so never actually prints a line for me. – ESP Nov 11 '15 at 9:45
• "print must just be appending to the string" .. .what? print and println do exactly the same thing, except that println prints the text plus the current OS's line delimiter. See the documentation: docs.oracle.com/javase/8/docs/api/java/io/… and docs.oracle.com/javase/8/docs/api/java/io/… – Xynariz Nov 13 '15 at 0:42
• @Xynariz You should only read the input once – SuperJedi224 Jan 3 '16 at 13:35
• @SuperJedi224 Um ... how is that even relevant to what I said? – Xynariz Jan 4 '16 at 20:57

## VB.NET, 106 Bytes

Imports c=System.Console
Module m
Sub Main
1:c.Write(i)
if i=1 then goto 1
end sub
end module

Straightforward, using goto instead of a loop. Compiles with Option Explicit and Option Strict Off, and Option Infer On

## STATA, 31 bytes

di _r(a)
m
do{$a }while($a)
end

First, get input from the user and store it in global variable a. Then switch to Mata for better commands. Print the value of a and then if it is truthy (i.e. 1), go to the start of the loop. If the end keyword is omitted, unexpected end of file (end statement missing) is output to standard error. I'm not sure if that's okay.

# Julia, 45 chars

readline()[1]>48?while 1>0 show(1)end:show(0)

# Staq, 5 chars

'[:]:

Explanation

'         input number, put it on top of the active stack
[        jump to corresponding ] if the top stack value = 0 or nonexistent
:       output top stack value as number
]      jump back to corresponding [ if top stack value >0
:     output top stack value as number

# Cardinal, 8 chars

%:> J.jN

Explanation

%                     create pointer
:                    enter number, put it on top of stack
>                   redirect pointer to the right
NOP
J                 skip next instruction if top stack value is > 0
.                output number to STDOUT
j               skip next instruction if top stack value is = 0
N              reflect pointer to the left

The original interpreter, written by Madk, is buggy, and some instructions are missing. I fixed the errors and recompiled the interpreter.

You can clone the fixed interpreter and readme from my GitHub repository.

• Does it use anything implemented after the question was asked? I think so. Sadly I think this is noncompeting. – Yet Another User Jan 7 '16 at 5:15
• @YetAnotherUser Cardinal is from 2010. Madk’s original interpreter (in BlitzMax) contains bugs that break the use of Cardinal, and he forgot to implement one or two commands that exist in his language spec. I fixed these errors and recompiled the fixed source in BlitzMax. Now everything works according to his specification. This is a catalog, the date of implementation does not matter. I uploaded my fix on GitHub yesterday, so everyone can enjoy it. The language is 5 years old; I fixed the errors around June 2015, as you can see e.g. here – M L Jan 7 '16 at 11:49

# Mouse16, 10 bytes

?0+[1!4\]0

Asks for input, then coerces it to an int and tests its truthiness. Then, if it's truthy, 1 is printed and the execution jumps to the 4th byte, where 1 is printed again, and so on forever (until the stack overflows), otherwise, 0 is printed.

# Pike, 94 bytes

Looks like C, but isn't C. Is interpreted. Is fast.

int main(){int x=(int)Stdio.stdin->gets();if(x!=0){for(;;){write("1");}}write("0");return 0;}

Ungolfed:

int main() {
int x = (int)Stdio.stdin -> gets();
if (x != 0) {
for(;;) {
write("1");
}
}
write("0");
return 0;
}

• I always want to pronounce Stdio as Studio :) Can you not write an integer to output? – ETHproductions Jan 22 '16 at 17:26
• @ETHproductions before I actually learned C, I always assumed stdio.h was some sorta studio something because of Visual Studio... I dunno. To write a number to stdout as far as I can tell you need to use write("%d", x); because write wants a string or array(char) argument, which is even longer – cat Jan 22 '16 at 17:29

## Boo, 34 bytes

def f(x):
print x;while x:print x

Boo is a language inspired by Python and implemented in .NET. Its syntax is very similar to Python 2's.

# CJam, 16 bytes

qi1={"1o_~"_~}&0


text:
1. ## Sum of series-Geometric?

How do i show that

$\displaystyle \sum_{n=2}^{n}1/2^{n}\le0.5$

I know $\displaystyle \sum_{k=0}^{\infty}r^k=\frac{1}{1-r}$ but the above starts from n=2 so can't work it out.

thanks for any help.

2. Originally Posted by charikaar
How do i show that

$\displaystyle \sum_{n=2}^{n}1/2^{n}\le0.5$

I know $\displaystyle \sum_{k=0}^{\infty}r^k=\frac{1}{1-r}$ but the above starts from n=2 so can't work it out.

thanks for any help.
$\displaystyle \sum_{n=2}^{n}1/2^{n}=\sum_{j=0}^{n-2}1/2^{j+2}$


text:
Clean/Potable Water Supply

1. Aug 10, 2016

Astronuc

Staff Emeritus
https://en.wikipedia.org/wiki/Drinking_water

SunToWater Technologies's units turn moisture in the air into drinkable water

http://suntowater.com/

They weren't the first though

I've often wonder about catching cloud moisture on screens placed in the hills or mountains where clouds form, e.g., along the west coast (marine layer), or using sunlight to evaporate seawater which is then condensed, as opposed to using fossil fuel as a thermal energy source.

Desalination is a big industry in the Middle East.

2. Aug 10, 2016

Staff: Mentor

I have seen something like that in a documentary. I think somewhere in south america they harvested mist or clouds if you will, because it has been at a high altitude.

On Lanzarote (av. rain $112 \; mm \cdot a^{-1}$) they make even wine only with the morning mist, which they capture with small half circular stone walls around the plants. But I have forgotten how it tasted.

To clean water in sunny places one could use PET bottles and let the UV radiation clean the water from bacteria. I'm not sure whether I would drink it, but it allegedly works.

3. Aug 11, 2016

orkamedus

Hey, glad to hear you talking about SunToWater! Full disclosure: I work for SunToWater Technologies, LLC.

There are actually a lot of systems like ours out there, mostly based on refrigerant technologies, which cycles through a compression/decompression state, producing a cooled surface for water to condense upon. Similar to those massive nets that collect morning dew and moisture, there is an inherent problem with condensing the air floating around you; the air around us is full of contaminates. You will always need to filter water generated in these ways.

Desalination has one massive problem: the majority of water scarcity stricken areas are not near a body of water. Desalination is only effective when the destination for water is also near the coast, as once you get a couple miles inland, the cost of trucking this water rapidly overshadows the cost to produce.

SunToWater may not be the ultimate solution, but we present a way to collect water from the air through a salt-based desiccant, which only absorbs water, and can produce water anywhere in the world (of course, not where it's snowing, because the air has 0% relative humidity when <32 degrees— also, if you're in a place where it's snowing, you don't need an atmospheric water generator to make water; you need a match).

I will definitely keep an eye on this topic if anyone has any company or technology specific questions!
For anything specific, you can email me at gordon@suntowater.com!

Last edited: Aug 11, 2016


text:
# Prove that the following algorithm has STOP property (number of steps is finite)

Prove that the following algorithm has STOP property. I am not sure if this term is widely know, so the definition of STOP property that I got during classes looks as follows:

STOP property (for all input data satisfying $$\alpha$$ the computation halts - the number of steps is finite)

$$\alpha: x \in N$$

void BB(int x)
{
int y = x;
int z = 0;
while((z != 0) || (y <= 300))
{
if(y <= 300)
{
y = y + 3;
z = z + 1;
}
else
{
y = y - 2;
z = z - 1;
}
}
}

I do not really have any idea how to approach such a problem. I was thinking about using the method of loop counters, but I couldn't success with it.

You have three possible cases:

• $$y > 300$$. Since $$z = 0$$ initially, the algorithm terminates.
• $$y = 300$$ and $$z = 0$$. You enter the first if and you get $$y = 303$$ and $$z = 1$$. Then you enter the second if and you get $$y = 301$$ and $$z = 0$$. Since $$y > 300$$ and $$z = 0$$ the algorithm stops.
• $$y < 300$$ and $$z = 0$$. After $$k$$ iterations $$y = 301$$ or $$y = 302$$ or $$y=303$$ and $$z = k$$. By executing the algorithm for each $$y$$ you can see that $$y$$ only takes values in a specific range while $$z$$ is always decreasing and will eventually reach 0 (or it will become less than 0). For example, let $$y = 301$$ and $$z = k$$. By executing the algorithm you get the following values:

$${\bf y = 301, z = k} \\ y = 299, z=k-1 \\ y=302, z = k\\ y = 300, z = k-1 \\ y = 303, z = k \\ {\bf y = 301, z = k-1}\\ y = 299, z = k-2 \\ y=302, z = k-1\\ y = 300, z = k-2 \\ y = 303, z = k-1 \\ {\bf y = 301, z = k-2}\\$$

Obviously each time you reach $$y = 301$$, z is decreased by 1. After showing that the same thing happens for the other two possible values of $$y$$ you have proved that for every possible starting value, the algorithm stops after a finite number of steps.

A simple case: What happens if x > 300? (Think about it). So that was easy, the program stops.

What if x ≤ 300, including x = 0? First there is a phase where y is increased by 3 each time, and that will happen at least once (if x ≥ 298) and at most 101 times (if x = 0), so we end that phase with x ≤ 101, and y is 301, 302, or 303.

Now comes a second phase: We have y = 301, 302, or 303. If y = 301 (you think what the next two steps will be), and we have y = 302 and x unchanged. If y = 302 (you think what the next two steps will be), and we have y = 303 and x unchanged. But in the last case y = 303 (you think what the next three steps will be), and we have y = 301 and x is one less than before!

If x isn't 0 already, you figure out what will happen after every 7 iterations of the loop, and then it is obvious that the program stops.


text:
# get.lineage

The get.lineage command reads a taxonomy file and taxon then generates a new file containing only sequences from the specified taxon. You may also include either a fasta, name, group, list, count or align.report file to this command and mothur will generate new files for each of those containing only the selected sequences. To complete this tutorial, you are encouraged to obtain the AbRecovery dataset.

## Default Settings

To run get.lineage, you must provide a taxonomy or constaxonomy file and one or more taxon names. The command will generate a *.pick.* file.

### Running with a taxonomy file

To generate an taxonomy file, let’s first run classify.seqs:

mothur > classify.seqs(fasta=abrecovery.fasta, template=silva.nogap.fasta, taxonomy=silva.bacteria.silva.tax)
mothur > get.lineage(taxonomy=abrecovery.silva.taxonomy, taxon=Bacteria;Firmicutes;)

This generates abrecovery.silva.pick.taxonomy a file containing the 106 sequences from Bacteria;Firmicutes;

You can select sequences from multiple taxa by separating them with dashes. Example:

 mothur > get.lineage(taxonomy=abrecovery.silva.taxonomy, taxon=Bacteria;Firmicutes;-Bacteria;Bacteroidetes;)

This generates abrecovery.silva.pick.taxonomy a file containing the 187 sequences from Bacteria;Firmicutes; or Bacteria;Bacteroidetes;

You may enter your taxon names with confidence scores, doing so will get only those sequences that belong to the taxonomy and whose confidence scores is above the scores you give.

mothur > classify.seqs(fasta=abrecovery.fasta, template=silva.nogap.fasta, taxonomy=silva.bacteria.silva.tax)
mothur > get.lineage(taxonomy=abrecovery.silva.taxonomy, taxon=Bacteria(100);Firmicutes(90);)

This generates abrecovery.silva.pick.taxonomy a file containing the 104 sequences from Bacteria;Firmicutes; whose confidence scores are at 100 percent for Bacteria and at or above 90 for Firmicutes.

### Running with a constaxonomy file

First we need to find the consensus taxonomies for each OTU with the classify.otu command:

mothur > classify.otu(list=final.an.list, name=final.names, taxonomy=final.taxonomy)
mothur > get.lineage(constaxonomy=final.an.0.03.cons.taxonomy, list=final.an.list, taxon=Bacteria;Firmicutes;, label=0.03)

This generates final.an.0.03.pick.list containing the 401 OTUs that classified to Bacteria;Firmicutes;.

## fasta option

To use the fasta option, follow this example:

mothur > get.lineage(taxonomy=abrecovery.silva.taxonomy, taxon=Bacteria;Firmicutes;, fasta=abrecovery.fasta)

This generates the file abrecovery.pick.fasta, which contains only sequences from Bacteria;Firmicutes;

## name option

To use the name option, follow this example:

mothur > get.lineage(taxonomy=abrecovery.silva.taxonomy, taxon=Bacteria;Firmicutes;, name=abrecovery.names)

This generates the file abrecovery.pick.names, which contains only the names of sequences from Bacteria;Firmicutes;

### dups

The dups parameter is only used in tandem with a namefile. By default, dups=TRUE, so if any sequence in a specific line in the name file is in your taxon, then all sequences in that line will be kept. This is especially useful when used with the groupfile, since for most commands your files can contain only the unique sequences, but the groupfile needs to contain all the sequences in your namefile.

## group option

To use the group option, follow this example:

mothur > get.lineage(taxonomy=abrecovery.silva.taxonomy, taxon=Bacteria;Firmicutes;, group=abrecovery.groups)

This generates the file abrecovery.pick.groups, which contains only sequences from Bacteria;Firmicutes;

## count option

The count file is similar to the name file in that it is used to represent the number of duplicate sequences for a given representative sequence. It can also contain group information.

mothur > get.lineage(taxonomy=abrecovery.silva.taxonomy, taxon=Bacteria;Firmicutes;, count=abrecovery.count_table)

## alignreport option

To use the alignreport option, follow this example:

mothur > get.lineage(taxonomy=abrecovery.silva.taxonomy, taxon=Bacteria;Firmicutes;, alignreport=abrecovery.align.report)

This generates the file abrecovery.pick.align.report, which contains only sequences from Bacteria;Firmicutes;

## list option

To use the list option, follow this example:

mothur > get.lineage(taxonomy=abrecovery.silva.taxonomy, taxon=Bacteria;Firmicutes;, list=abrecovery.fn.list)

This generates the file abrecovery.fn.pick.list, which contains only sequences from Bacteria;Firmicutes;

## constaxonomy option

If you provide a constaxonomy file, mothur will select the OTUs from a shared or list file that are assigned to the requested taxon. The constaxonomy parameter requires a list or shared file.

mothur > get.lineage(constaxonomy=final.an.0.03.cons.taxonomy, shared=final.an.shared, taxon=Bacteria;Firmicutes;, label=0.03)

or

mothur > get.lineage(constaxonomy=final.an.0.03.cons.taxonomy, list=final.an.list, taxon=Bacteria;Firmicutes;, label=0.03)