text:
# Whether this PRG is secure or not

This is the question.

Suppose $G$ is a secure PRG with expansion factor $\ell(n) = 2n$ such that $n$ is a security parameter. Is it always the case that, $G'\colon \lbrace 0,1 \rbrace^n \to \lbrace 0,1 \rbrace^{3n}$, defined by, $G'(s) := G(s) || \bar{s}$ is also a PRG ? Here, $||$ represents concatenation of bit strings, and $\bar{s}$ represents the bitwise complement of s (e.g., if $s$ is $100010$, then $\bar{s}$ is $011101$).

My unsure attempt of solving this says it is a broken PRG (i.e. not secure) because, I always check on following points for a construction to be a secure PRG: .. $\ell(n) > n$, .. efficient, .. deterministic, &, .. pseudorandom, i.e., $| Pr[D(G(s) = 1] - Pr[D(r) = 1] | \leq \operatorname{negl}(n)$.

And the construction in question failed in passing the pseudorandomness.

My attempt was, let's say $w$ is final output (of $3n$ size, which is given to the distinguisher) and I leaked the first bit of my construction (i.e., only $n-1$ bits i.e., $s[2:n]$, are passed into G and are expanded to $2n-1$ bits) such that first bit of $w$, i.e., $w[1]$ is complement of $w[2n+1]$ (because last $n$ bits are simply concatenated and $2n+1$ refers to the first bit among the last $n$ bits).

XORing $w[1]$ with $w[2n+1]$ gives us $1$ which clearly depicts inefficient randomness and failure of computational adversarial indistinguishability (i.e., ability to guess bits better than a probability of $1/2$ exist).

I'm unsure whether this is the right approach though. When we are talking about PRGs, my knowledge says we cannot modify/control the seed (nor we can see it, though we control its size), and then we know that $G$ will output $2n$ bits (i.e., an expansion factor of $2|s|$). Is it possible to explicitly only send $s[2:n]$ bits to a PRG to get the expanded $2n-1$ bits back and then attach that first bit in the starting of the pseudorandom string ?.

What's your verdict towards my approach ?. Thank you, for your time &, I really liked you read it.

I have another explanation that proves $G'$ is secure, however, I'm sure with a probability of 50% that, that is not right and rather this is right (i.e. $G'$ is not secure).

• Comments are not for extended discussion; this conversation has been moved to chat. Mar 14 '16 at 11:30

Your intuition that $G'$ is insecure is correct, but your approach is a bit off. In the PRG security game, the adversary is not allowed to influence the choice of seed, which is always chosen uniformly at random.
To attack $G'$, notice that given just $G'(s)$, you can reconstruct $s$ from $\bar{s}$. Therefore a distinguisher, when given a challenge output $w$, can compute $G'(\bar{w}[2n+1] \cdots \bar{w}[3n])$ and check whether this gives $w$.


text:
# Arc-y!

Geometry Level pending

Two chords AB and AC are drawn inside a circle. If its radius is 17 inches, and arc CAB is 46 inches, find the angle formed between the two chords.

×

format: plain


text:
# Does dark energy pulling the universe evenly from outside it? [closed]

I understand that the accepted theory is that dark energy is scattered pretty much evenly between galaxies and pushes all galaxies outwards one from another another, with some exceptions of collisions such as the expected event in which Andromeda will collide in Milky Way in about 4.5 billion years.

Unorthodoxly, I wondered if the universe is expanding equally in a cosmos by dark energy that surrounds it from the outside and pulling everything towards it evenly while such pulling outwards might be finite if it's actually a giant mass sphere pulling everything towards it or infinite if it's infinitely expanding outwards along with galaxies.

Does either of the two unorthodox ideas supported, or dismissed, by evidence?

No, it is not possible. Actually, Dark Energy can neither be repulsion from inside, nor attraction from outside. (Outside attraction is ruled out by Anna V's comment anyway).

There is an observational evidence for the above. That evidence is in the expansion rate of universe which exceeds speed of light at large enough distances. Any attraction, or repulsion would be eventually a force (gravity included, see next para) and could not make the "universe expand" (objects move wrt one another), at FTL inside space, if we were to go by relativity. Therefore, it can neither be internal repulsion, nor be external attraction, it has to be just expansion of space itself.

I mentioned gravity in context of attraction and repulsion because - if gravity (given sufficient distance to accelerate) was capable of accelerating something to FTL, then we know that escape speed from a black hole is $c$. That would also be ~speed at which a free falling object would enter the event horizon. Therefore if we were to shoot an object towards event horizon with fast speed, then it may have been possible for that object to attain FTL speeds prior to reaching EH, which is prohibited by relativity. I have not done any calculations about it but it seems at least with the help of slingshots with multiple black holes, it could have been possible for an object to attain FTL. Which goes against relativity as far as I know.

One more point to note is that the expansion of universe has been accelerating only for last ~5 billion years. Before that it was a slowing expansion. As we know for sure that it started out as accelerated expansion at big bang. So we already know that the expansion has switched from accelerating, to slowing down and then again to accelerating. Therefore the expansion is fluctuating between accelerating, and slowing down. Given the age of universe as 14 billion years and already two switches taken place, 5*3 = 15. In a billion years or so, it may again switch to slowing down expansion.

This fluctuation between accelerating, and slowing down of expansion suggests that both - inside attraction, and outside repulsion can be ruled out.

No, does not make any sense.

I'll treat it a s a possible tentative hypothesis and explain why it makes little sense. See the wiki article on Dark Energy.

https://en.m.wikipedia.org/wiki/Dark_energy

The inner layer would act on the outer layer, but Dark Energy is repulsive, not attractive. So inside or not does not matter.

Also, if you mean a spatial 3D spherical universe, what that means is that evert high is on the surface, there's nothing inside. If you mean a 3D spherical space which is expanding in the fourth dimension, time, to fill spacetime, that Dark Energy if it is that, it means it was there at one time and then disappeared. When it was there it was attracting or repelling (if normal matter attracting, if abnormal dark energy repelling), and then it stopped doing that. But we know that dark energy has been active at least the last 5-7 billion years, we think there before also but too weak to have affected us much [yes, dark energy affects us more as the universe expands].


text:
• ### Announcements

#### Archived

This topic is now archived and is closed to further replies.

# How do I keep things separate????? (see inside)

## Recommended Posts

Cobra    122
Hey ppl, I am really really hoping that some of you know how to do this. Basically, I want to know how to keep all of my functions separate, but let them all run at the same time.. for example. If I make it so that the sky texture rotates in a certain direction, I want it so that even if the camera turns upside down, or the world destroys itself, or whatever, I still want the sky to rotate in the same way as it was. Another example would be gravity... I want to make it so that no matter which direction you are looking at e.t.c, gravity always applies downwards.... Can anyone help me with this.. it''s really bugging me ''cause I used to know how to do it! Thanx in advance for any help. ~Cobra~

##### Share on other sites
ragonastick    134
Ummm... If I understand your question (doubtful), then the answer is to use a game loop:

(VB, since my C++ really stinks... I can''t even remember how to write a Do loop )

Do While bRunning GetInput MovePlayer DoGravity SpinSky DrawEverything FlipBackBufferLoop

Trying is the first step towards failure.

##### Share on other sites
Cobra    122
Actually, I think I''ll just have to start using gluLookAt from now on.. this actually works like a camera, so it won''t affect anything in the rest of the level.

But thanx anyway.

~Cobra~

##### Share on other sites
rileyriley    235
I think that the reason that gluLookAt doesn''t mess up all the other junk is that it modifies the projection matrix, while normal transformations modify the model view matrix. So if you wanted to do it _without_ gluLookAt for some reason then you could glMatrixMode(GL_PROJECTION); mess with your camera, and go back to glMatrixMode(GL_MODEL_VIEW); (there''s about a 90% chance that I have every single one of those names wrong).

I just started with ogl about a month ago, so my understanding of how it works is still pretty shaky, but I think this is right. Someone please correct me if it isn''t.

/riley

##### Share on other sites
davepermen    1047
Do While bRunning
GetInput
MovePlayer
DoGravity
SpinSky
DrawEverything
FlipBackBuffer
Loop

  do{ GetInput(); MovePlayer(); DoGravity(); SpinSky(); DrawEverything();}while(bRunning);

we wanna play, not watch the pictures

##### Share on other sites
zedzeek    528
DONT mess with the projection matrix AT ALL

gluLookat works in modelview space (have a look at the mesa source for a sample code of what it does )

http://members.xoom.com/myBollux

##### Share on other sites
Guest Anonymous Poster
what about glPushMatrix(), glPopMatrix()?? Maybe you''re rotating the sky, which then rotates the camera (since the camera is rotated after), which inturn rotates nething after... crappy explaination but I think u get it...
to stop this:

glPushMatrix()
// rotate 1 thing
glPopMatrix() <- resets the transformation matrix or whatever so you''re back where u started before glPushMatrix()
glPushMatrix() (again)
// rotate/move something else
glPopMatrix...

This way you can separate all your calls to rotate/move... You could draw a car for example like:

pushmatrix()
// move to car pos and draw car body
pushmatrix()
// move to front left wheel pos (relative to car pos) and draw it
popmatrix()
pushmatrix()
// move to front right wheel pos (relative to car pos) and draw it
popmatrix()
... do other wheels
popmatrix()
and this pop matrix gets you back to the state u were at before you moved to draw the car body

if this didnt help very much, look up glPushMatrix in the redbook, has a pretty good explaination, or NeHe

##### Share on other sites
Cobra    122
THATS IT!!!!!!!!

Thanx mr anonymous poster!..

I think that''s it.. I''ll go test it out now.. but I''m pretty sure that''s it.

~Cobra~

##### Share on other sites
Cobra    122
Wow, I never knew just how useful glPushMatrix and glPopMatrix were! I never used them before! Now I''ll ALWAYS use them! hehehe.

I''ve managed to totally move all of my functions out of DrawGLScene, and just make calls to it using function calls now, so my DrawGLScene looks a lot like the loop you guys were showing earlier.

There''s just one thing that I don''t get now.

What is this FlipBackBuffer that you guys were mentioning?

Thanx in advance for any help.

~Cobra~

##### Share on other sites
ARID    122
OpenGL dosen''t use a back buffer call it does it automaticly (I think) all a buffer is is a place to draw to then you swap the buffers front buffer is your current view back buffer is your next view. It eliminates flicker and increases framerates. You can impliment one in OGL i''m not shure how but i know you can DirectX requires you use one. Just another point at why OGL is a generaly better API.

A man walks into a bar.....ouch!?! Ya get it, do ya huh huh well....awww I give up.

##### Share on other sites
Cobra    122
Oh right, I''ve already done that....

Thanx

~Cobra~


text:
## Calculus with Applications (10th Edition)

Published by Pearson

# Chapter R - Algebra Reference - R.4 Equations - R.4 Exercises - Page R-16: 36

#### Answer

This equation has no solution.

#### Work Step by Step

$\dfrac{2}{x^{2}-2x-3}+\dfrac{5}{x^{2}-x-6}=\dfrac{1}{x^{2}+3x+2}$ Factor all three rational expressions completely: $\dfrac{2}{(x-3)(x+1)}+\dfrac{5}{(x-3)(x+2)}=\dfrac{1}{(x+2)(x+1)}$ Multiply the whole equation by $(x-3)(x+1)(x+2)$: $(x-3)(x+1)(x+2)\Big[\dfrac{2}{(x-3)(x+1)}+\dfrac{5}{(x-3)(x+2)}=\dfrac{1}{(x+2)(x+1)}\Big]$ $2(x+2)+5(x+1)=x-3$ $2x+4+5x+5=x-3$ Take all terms to the left side and simplify: $2x+4+5x+5-x+3=0$ $6x+12=0$ Take $12$ to the right side: $6x=-12$ Take $6$ to divide the right side: $x=-\dfrac{12}{6}$ $x=-2$ The original equation is undefined for $x=-2$, so this equation has no solution.

After you claim an answer you’ll have 24 hours to send in a draft. An editor will review the submission and either publish your submission or provide feedback.


text:
# Phylogenetic tree manipulation

## tree.merger tool

### tree.merger basics

The function tree.merger is meant to merge phylogenetic information derived from different phylogenies into a single supertree. Given a backbone (backbone) and a source trees (source.tree), tree.merger drops clades from the latter to attach them on the former according to the information provided in the dataset object data. Individual tips to add can be indicated in data as well. Once the supertree is assembled, tips and nodes ages are calibrated based on user-specified values.

### Input tree and data

The backbone phylogeny serves as the reference to locate where single tips or entire clades extracted from the source.tree have to be attached. The backbone is assumed to be correctly calibrated so that nodes and tips ages (including the age of the tree root) are left unchanged, unless the user specifies otherwise. The source.tree is the phylogeny where the clades to add are extracted from. For each clade attached to the backbone, the time distances between the most recent common ancestor of the clade and its descendant nodes are kept fixed, unless the ages for any of these nodes are indicated by the user. All the new tips added to the backbone, irrespective of whether they are attached as a clade or as individual tips, are placed at the maximum distance from the tree root, unless calibration ages are supplied by the user. The data object is a dataframe including information about “what” is attached, where and how. data must be made of three columns:

• bind: the tips or clades to be attached;

• reference: the tips or clades where bind will be attached;

• poly: a logical indicating whether the bind and reference pair should form a polytomy.

If different column names are supplied, tree.merger assumes they are ordered as described and eventually fails if this requirement is not met. Similarly, with duplicated bind supplied the function stops and throws an error message. A clade, either to be bound or to be the reference, must be indicated by collating the names of the two phylogenetically furthest tips belonging to it, separated by a “-”. The ‘bound’ tips/clades can be used as reference for another tip/clade to be attached. The order with which clades and tips to attach are supplied does not matter. Tips and nodes are calibrated within tree.merger by means of the function scaleTree. To this aim, named vectors of tips and nodes ages, meant as time distance from the youngest tips within the phylogeny, must be supplied. As for the data object, the nodes to be calibrated should be identified by collating the names of the two phylogenetically furthest tips it subtends to, separated by a “-”.

### Attaching individual tips to the backbone tree

If only individual tips are attached the source.tree can be left unspecified. Tips set to be attached to the same reference are considered to represent a polytomy. Tips set as bind which are already on the backbone tree are removed from the latter and placed according to the reference. In the example below, tips “a1” and “a8” are set to be attached to the same reference “t6”, “t5” belonging to the backbone is indicated to be moved, and “a7” is added to the tree root thus changing the total height of the tree.

dato
bind reference poly
a1 t6 FALSE
a2 t10 FALSE
a3 t9 FALSE
a4 a2-t5 FALSE
a5 t10-t2 TRUE
a6 t2-a3 FALSE
a7 a1-t10 FALSE
t5 t7-t10 FALSE
a8 t6 FALSE
tree.merger(backbone=tree.back,data=dato,plot=FALSE)
#> Warning in tree.merger(backbone = tree.back, data = dato, plot = FALSE): t5
#> removed from the backbone tree
#> Warning in tree.merger(backbone = tree.back, data = dato, plot = FALSE): Root
#> age not indicated: the tree root arbitrarily set at 3.31

As no tip.ages are supplied to tree.merger, all the new tips are placed at the maximum distance from the tree root. Since no age for the root of the merged tree is indicated, the function places it arbitrarly and produces a warning to inform the user about its position with respect to the youngest tip on the phylogeny.

To calibrate the the ages of either tips or nodes within the merged tree, the arguments tip.ages and node.ages must be indicated.

ages.tip
#>  a7  a1  t6  a8  a6  a4  a2  a5  a3
#> 1.0 2.0 1.7 1.5 0.8 1.5 0.3 1.2 0.2
ages.node
#>  t2-t1  a1-a8 a7-t10
#>    2.2    2.9    3.5
tree.merger(backbone=tree.back,data=dato,tip.ages=ages.tip,node.ages = ages.node,plot=FALSE)
#> Warning in tree.merger(backbone = tree.back, data = dato, tip.ages = ages.tip, :
#> t5 removed from the backbone tree

### Attaching clades to the backbone tree

When clades are attached, the nodes subtending to them on source.tree are identified as the most recent common ancestors of the tip pairs indicated in bind. If one or more tips within any of the bind clades are also set to be added as individual tips, they are removed from the clade they belong to and attached independently. In the example below, “s7” is removed from the clade subtended by the most recent common ancestor of “s1” and “s4” and attached as sister to “t3” independently.
dato.clade
bind reference poly
a1 s3 FALSE
s2-s5 t10 FALSE
s1-s4 t3-t9 FALSE
s7 t3 FALSE
a2 s2-t7 FALSE
tree.merger(backbone=tree.back,data=dato.clade,source.tree=tree.source,plot=FALSE)

### Guided examples

### load the RRphylo example dataset including Cetaceans tree
data("DataCetaceans")
DataCetaceans$treecet->treecet # phylogenetic tree ### Select two clades and some species to be removed tips(treecet,131)->liv.Mysticetes tips(treecet,193)->Delphininae c("Aetiocetus_weltoni","Saghacetus_osiris", "Zygorhiza_kochii","Ambulocetus_natans", "Kentriodon_pernix","Kentriodon_schneideri","Kentriodon_obscurus")->extinct plot(treecet,show.tip.label = FALSE,no.margin=TRUE) nodelabels(frame="n",col="blue",font=2,node=c(131,193),text=c("living\nMysticetes","Delphininae")) tiplabels(frame="circle",bg="red",cex=.3,text=rep("",length(c(liv.Mysticetes,Delphininae,extinct))), tip=which(treecet$tip.label%in%c(liv.Mysticetes,Delphininae,extinct)))

### Create the backbone and source trees
drop.tip(treecet,c(liv.Mysticetes[-which(tips(treecet,131)%in%
c("Caperea_marginata","Eubalaena_australis"))],
Delphininae[-which(tips(treecet,193)=="Tursiops_aduncus")],extinct))->backtree
drop.tip(treecet,which(!treecet$tip.label%in% c(liv.Mysticetes,Delphininae,extinct)))->sourcetree ### Create the data object data.frame(bind=c("Balaena_mysticetus-Caperea_marginata", "Aetiocetus_weltoni", "Saghacetus_osiris", "Zygorhiza_kochii", "Ambulocetus_natans", "Kentriodon_pernix", "Kentriodon_schneideri", "Kentriodon_obscurus", "Sousa_chinensis-Delphinus_delphis", "Kogia_sima", "Grampus_griseus"), reference=c("Fucaia_buelli-Aetiocetus_weltoni", "Aetiocetus_cotylalveus", "Fucaia_buelli-Tursiops_truncatus", "Saghacetus_osiris-Fucaia_buelli", "Dalanistes_ahmedi-Fucaia_buelli", "Kentriodon_schneideri", "Phocoena_phocoena-Delphinus_delphis", "Kentriodon_schneideri", "Sotalia_fluviatilis", "Kogia_breviceps", "Globicephala_melas-Pseudorca_crassidens"), poly=c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE))->dato dato bind reference poly Balaena_mysticetus-Caperea_marginata Fucaia_buelli-Aetiocetus_weltoni FALSE Aetiocetus_weltoni Aetiocetus_cotylalveus FALSE Saghacetus_osiris Fucaia_buelli-Tursiops_truncatus FALSE Zygorhiza_kochii Saghacetus_osiris-Fucaia_buelli FALSE Ambulocetus_natans Dalanistes_ahmedi-Fucaia_buelli FALSE Kentriodon_pernix Kentriodon_schneideri FALSE Kentriodon_schneideri Phocoena_phocoena-Delphinus_delphis FALSE Kentriodon_obscurus Kentriodon_schneideri FALSE Sousa_chinensis-Delphinus_delphis Sotalia_fluviatilis FALSE Kogia_sima Kogia_breviceps FALSE Grampus_griseus Globicephala_melas-Pseudorca_crassidens FALSE ### Merge the backbone and the source trees according to dat without calibrating tip and node ages tree.merger(backbone = backtree,data=dato,source.tree = sourcetree,plot=FALSE) #> Warning in tree.merger(backbone = backtree, data = dato, source.tree = #> sourcetree, : Kogia_sima, Grampus_griseus removed from the backbone tree #> Warning in tree.merger(backbone = backtree, data = dato, source.tree = #> sourcetree, : Eubalaena_australis, Caperea_marginata, Tursiops_aduncus already #> on the source tree: removed from the backbone tree #> Warning in tree.merger(backbone = backtree, data = dato, source.tree = #> sourcetree, : Root age not indicated: the tree root arbitrarily set at 45.06 ### Set tips and nodes calibration ages c(Aetiocetus_weltoni=28.0, Saghacetus_osiris=33.9, Zygorhiza_kochii=34.0, Ambulocetus_natans=40.4, Kentriodon_pernix=15.9, Kentriodon_schneideri=11.61, Kentriodon_obscurus=13.65)->tipages c("Ambulocetus_natans-Fucaia_buelli"=52.6, "Balaena_mysticetus-Caperea_marginata"=21.5)->nodeages ### Merge the backbone and the source trees and calibrate tips and nodes ages tree.merger(backbone = backtree,data=dato,source.tree = sourcetree, tip.ages=tipages,node.ages=nodeages,plot=FALSE) #> Warning in tree.merger(backbone = backtree, data = dato, source.tree = #> sourcetree, : Kogia_sima, Grampus_griseus removed from the backbone tree #> Warning in tree.merger(backbone = backtree, data = dato, source.tree = #> sourcetree, : Eubalaena_australis, Caperea_marginata, Tursiops_aduncus already #> on the source tree: removed from the backbone tree ## scaleTree tool The function scaleTree is a useful tool to deal with phylogenetic age calibration written around Gene Hunt’s scalePhylo function (https://naturalhistory.si.edu/staff/gene-hunt). It rescales branches and leaves of the tree according to species and/or nodes calibration ages (meant as distance from the youngest tip within the tree). If only species ages are supplied (argument tip.ages), the function changes leaves length, leaving node ages and internal branch lengths unaltered. When node ages are supplied (argument node.ages), the function shifts nodes position along their own branches while keeping other nodes and species positions unchanged. #> t9 t73 t11 t43 t78 t46 t52 t26 #> 1.250 1.205 0.000 2.430 3.150 1.050 0.000 1.550 scaleTree(tree,tip.ages=sp.ages)->treeS1 #> 98 152 123 85 118 127 164 143 #> 10.7 0.7 1.2 12.6 5.1 5.8 18.8 12.8 scaleTree(tree,node.ages=nod.ages)->treeS2 treeS2->treeS1 It may happen that species and/or node ages to be calibrated are older than the age of their ancestors. In such cases, after moving the species (node) to its target age, the function reassembles the phylogeny above it by assigning the same branch length (set through the argument min.branch) to the all the branches along the species (node) path, so that the tree is well-conformed and ancestor-descendants relationships remain unchanged. In this way changes to the original tree topology only pertain to the path along the “calibrated” species. c(sp.ages,nod.ages) #> t1 96 #> 20.5 15.6 # scaleTree(tree,tip.ages = sp.ages,node.ages = nod.ages,min.branch = 1)->treeS ### Guided examples # load the RRphylo example dataset including Felids tree data("DataFelids") DataFelids$treefel->tree

# get species and nodes ages
# (meant as distance from the youngest species, that is the Recent in this case)
max(nodeHeights(tree))->H
H-dist.nodes(tree)[(Ntip(tree)+1),(Ntip(tree)+1):(Ntip(tree)+Nnode(tree))]->age.nodes
H-diag(vcv(tree))->age.tips

# apply Pagel's lambda transformation to change node ages only
rescaleRR(tree,lambda=0.8)->tree1

# apply scaleTree to the transformed phylogeny, by setting
# the original ages at nodes as node.ages
scaleTree(tree1,node.ages=age.nodes)->treeS1

# change leaf length of 10 sampled species
tree->tree2
set.seed(14)
sample(tree2$tip.label,10)->sam.sp age.tips[sam.sp]->age.sam age.sam[which(age.sam>0.1)]<-age.sam[which(age.sam>0.1)]-1.5 age.sam[which(age.sam<0.1)]<-age.sam[which(age.sam<0.1)]+0.2 tree2$edge.length[match(match(sam.sp,tree$tip.label),tree$edge[,2])]<-age.sam

# apply scaleTree to the transformed phylogeny, by setting
# the original ages at sampled tips as tip.ages
scaleTree(tree2,tip.ages=age.tips[sam.sp])->treeS2

# apply Pagel's kappa transformation to change both species and node ages,
# including the age at the tree root
rescaleRR(tree,kappa=0.5)->tree3

# apply scaleTree to the transformed phylogeny, by setting
# the original ages at nodes as node.ages
scaleTree(tree1,tip.ages = age.tips,node.ages=age.nodes)->treeS3

## cutPhylo tool

The function cutPhylo is meant to cut the phylogentic tree to remove all the tips and nodes younger than a reference (user-specified) age, which can also coincide with a specific node. When an entire clade is cut, the user can choose (by the argument keep.lineage) to keep its branch length as a tip of the new tree, or remove it completely.

cutPhylo(tree,age=5,keep.lineage = TRUE)
cutPhylo(tree,age=5,keep.lineage = FALSE)

cutPhylo(tree,node=129,keep.lineage = TRUE)
cutPhylo(tree,node=129,keep.lineage = FALSE)

## fix.poly tool

The function fix.poly randomly resolves polytomies either at specified nodes or througout the tree (Castiglione et al. 2020). This latter feature works like ape’s multi2di. However, contrary to the latter, polytomies are resolved to non-zero length branches, to provide credible partition of the evolutionary time among the nodes descending from the dichotomized node. This could be useful to gain realistic evolutionary rate estimates at applying RRphylo. Under the type = collapse specification the user is expected to indicate which node/s must be transformed into a multichotomus clade.

 ### load the RRphylo example dataset including Cetaceans tree
data("DataCetaceans")
DataCetaceans$treecet->treecet ### Resolve all the polytomies within Cetaceans phylogeny fix.poly(treecet,type="resolve")->treecet.fixed ## Set branch colors unlist(sapply(names(which(table(treecet$edge[,1])>2)),function(x)
c(x,getDescendants(treecet,as.numeric(x)))))->tocolo
unlist(sapply(names(which(table(treecet$edge[,1])>2)),function(x) c(getMRCA(treecet.fixed,tips(treecet,x)), getDescendants(treecet.fixed,as.numeric(getMRCA(treecet.fixed,tips(treecet,x)))))))->tocolo2 colo<-rep("gray60",nrow(treecet$edge))
names(colo)<-treecet$edge[,2] colo2<-rep("gray60",nrow(treecet.fixed$edge))
names(colo2)<-treecet.fixed$edge[,2] colo[match(tocolo,names(colo))]<-"red" colo2[match(tocolo2,names(colo2))]<-"red" par(mfrow=c(1,2)) plot(treecet,no.margin=TRUE,show.tip.label=FALSE,edge.color = colo,edge.width=1.3) plot(treecet.fixed,no.margin=TRUE,show.tip.label=FALSE,edge.color = colo2,edge.width=1.3)  ### Resolve the polytomies pertaining the genus Kentriodon fix.poly(treecet,type="resolve",node=221)->treecet.fixed2 ## Set branch colors c(221,getDescendants(treecet,as.numeric(221)))->tocolo c(getMRCA(treecet.fixed2,tips(treecet,221)), getDescendants(treecet.fixed2,as.numeric(getMRCA(treecet.fixed2,tips(treecet,221)))))->tocolo2 colo<-rep("gray60",nrow(treecet$edge))
names(colo)<-treecet$edge[,2] colo2<-rep("gray60",nrow(treecet.fixed2$edge))
names(colo2)<-treecet.fixed2$edge[,2] colo[match(tocolo,names(colo))]<-"red" colo2[match(tocolo2,names(colo2))]<-"red" par(mfrow=c(1,2)) plot(treecet,no.margin=TRUE,show.tip.label=FALSE,edge.color = colo,edge.width=1.3) plot(treecet.fixed2,no.margin=TRUE,show.tip.label=FALSE,edge.color = colo2,edge.width=1.3)  ### Collapse Delphinidae into a polytomous clade fix.poly(treecet,type="collapse",node=179)->treecet.collapsed # Set branch colors c(179,getDescendants(treecet,as.numeric(179)))->tocolo c(getMRCA(treecet.collapsed,tips(treecet,179)), getDescendants(treecet.collapsed,as.numeric(getMRCA(treecet.collapsed,tips(treecet,179)))))->tocolo2 colo<-rep("gray60",nrow(treecet$edge))
names(colo)<-treecet$edge[,2] colo2<-rep("gray60",nrow(treecet.collapsed$edge))
names(colo2)<-treecet.collapsed\$edge[,2]
colo[match(tocolo,names(colo))]<-"red"
colo2[match(tocolo2,names(colo2))]<-"red"

par(mfrow=c(1,2))
plot(treecet,no.margin=TRUE,show.tip.label=FALSE,edge.color = colo,edge.width=1.3)
plot(treecet.collapsed,no.margin=TRUE,show.tip.label=FALSE,edge.color = colo2,edge.width=1.3)

## References

Castiglione, S., Serio, C., Piccolo, M., Mondanaro, A., Melchionna, M., Di Febbraro, M., Sansalone, G., Wroe, S.,& Raia, P. (2020). The influence of domestication, insularity and sociality on the tempo and mode of brain size evolution in mammals. Biological Journal of the Linnean Society, 132: 221-231.


text:
# zbMATH — the first resource for mathematics

Developable hyperspaces are metrizable. (English) Zbl 1066.54009
For a Hausdorff topological space $$X$$ let $$CL(X)$$ denote the hyperspace of all nonempty closed subsets of $$X$$ and $$K(X)$$ the hyperspace of all nonempty compact subsets of $$X$$. In the context of $$CL(X)$$ and $$K(X)$$ endowed with various topologies (as Vietoris topology, Fell topology, locally finite topology, bounded Vietoris topology) the following properties are studied: developability, metrizability, having a $$G_{\delta}$$-diagonal, submetrizability. Some characterization theorems are proved. For example, the following are equivalent: (i) $$CL(X)$$ with the Vietoris topology is Moore; (ii) $$CL(X)$$ with the Vietoris topology is developable; (iii) $$CL(X)$$ with the Vietoris topology is metrizable; (iv) $$X$$ is compact and metrizable.

##### MSC:
 54B20 Hyperspaces in general topology
Full Text:


text:
# Particle swarm optimization - follow-up

This is a followup post to Particle Swarm Optimization.

I wrote a script in Python for particle swarm optimization and I posted it here to get comments on the design. I was told that encapsulating the list used to hold the particles in a class would be a good idea, but it seemed like putting the Particle class I already had inside as a subclass was a good idea.

Now, I'm asking if it was indeed a good idea, and moreover if I made any rookie errors in using a subclass. For example, I wasn't completely sure about shared variables from a parent to a child subclass, so I just passed the ones I needed in the subclass initialization (worldWidth, worldHeight, and k).

Here is the "top" of the class, with the initialization of the parent class, the initializer function for the list, and the entirety of the the subclass. I've omitted all of the public methods of the parent class. For the whole code, see the repository.

class ParticleList:
"""ParticleList encapsulates the list of particles and functions used to
manipulate their attributes
"""

def __init__(self, NP, I, C, SR, LR, WW, WH, MV, K, FN):
"""create an array, assign values, and initialize each particle"""
self.pList        = []
self.numParticles = NP
self.inertia      = I
self.cognition    = C
self.socialRate   = SR
self.localRate    = LR
self.worldWidth   = WW
self.worldHeight  = WH
self.maxVelocity  = MV
self.k            = K
self.fname        = FN
self.createParticles()

def createParticles(self):
"""create a list of particles and then create neighborhoods if it's called for (k > 0)"""
for i in range(0,self.numParticles):
self.pList.append(self.Particle(i, self.worldWidth, self.worldHeight, self.k))

#fill neighbor lists
if self.k > 0:
for p in self.pList:
for x in range(p.index-(self.k/2),p.index+(self.k/2)+1):
if x > self.numParticles:
p.neighbors.append(x%self.numParticles)
elif x < 0:
p.neighbors.append(self.numParticles+x)
elif x == self.numParticles:
p.neighbors.append(0)
else:
p.neighbors.append(x)
self.updatelBest()

#initialize global and local bests
self.updategBest()

###########

class Particle:
"""this class is used for each particle in the list and all of their attributes"""
#[Q value, x_pos, y_pos]
gBest     = [0.0, 0, 0]
bestIndex = 0

#takes index in pList as constructor argument
def __init__(self, i, worldWidth, worldHeight, K):
#x,y coords, randomly initialized
self.x          = randint(-worldWidth/2,worldWidth/2)
self.y          = randint(-worldHeight/2,worldHeight/2)
#x,y velocity
self.velocity_x = 0.0
self.velocity_y = 0.0
#personal best
#[fitness value, x coord, y coord]
self.pBest      = [Q(self.x, self.y), self.x, self.y]
self.index      = i
#local best
self.lBest      = []
self.lBestIndex = 0
#array for neighbor indicies
self.neighbors  = []
self.k          = K
#for printing particle info
def __str__(self):
"""Creates string representation of particle"""
ret = """  i: {self.index!s}
x: {self.x!s}
y: {self.y!s}
v_x: {self.velocity_x!s}
v_y: {self.velocity_y!s}
b: {self.pBest[0]!s}""".format(**locals())
if self.k > 0:
return ret+'  l: '+str(self.lBest)+'\n'
else:
return ret+'\n'

###########

Here are two example Q functions:

def Q(p_x,p_y):
return float(100.0 * (1.0 - (pdist(p_x,p_y)/mdist())))

and

def Q(p_x,p_y):
return float((9.0 * max(0.0, 10.0 - (pdist(p_x,p_y)**2))) + (10.0 * (1.0 - (pdist(p_x,p_y)/mdist()))) + (70.0 * (1.0 - (ndist(p_x,p_y)/mdist()))))

• I'm hoping that you do post a followup as there's a few suggestions I have that would help move this in the direction of a high quality library. As it happens I'm quite interested in this algorithm and I have a bit of a vested interest in seeing this progress, if you aren't wanting to write a follow up for whatever reason perhaps I can fork the repository and do some work on this in the fork. The only reason I hesitated to fork in the first place was that I was somewhat under the impression that this code was part of some coursework you were doing. – shuttle87 Jul 18 '15 at 15:41
• @shuttle87 It was originally part of some coursework, but I've since graduated. I was working on expanding it and wanted to learn more about Python through it because Python itself was never part of my coursework. I will finish making my updates and post a follow up! You're also more than welcome to fork it – dockleryxk Jul 22 '15 at 18:10

I'm not experienced enough at OOP to give you meaningful feedback on your class models, but here are two quick things I noticed when scanning my novice eyes over your code:

1. Undocumented parameters. I don't know if NP, I, C, etc. are meant to be ints, floats, tuples, or what. I'd suggest adding comments to explain the parameters and their types in the docstring of your __init__ function.

2. Too many parameters. One thing that would simultaneously clean up your code and make it easier to use would be to pass all those parameters to your ParticleList.__init__() as a single dictionary. You could form the dictionary like this:

params = {'number_of_particles': NP, 'max_velocity': MV, 'world_width': WW, ...}

, and then your __init__() would just be def __init__(self, params). In the body of the function you could unpack it:

self.number_of_particles = params['number_of_particles']
self.max_velocity = params['max_velocity']
...

The advantage of doing that is you don't have to remember what order parameters get passed into your initialization function when you use it.

• Those are great ideas. Thank you so much! I'll definitely update it and incorporate them. – dockleryxk Jul 14 '15 at 16:26

I want to add my 2 cents to the code in general.

1. Try to use pythonic variable naming, e.g. particles_list instead of pList. It will be easier to read your code in the future.

2. I will rewrite create_particles method to make it more easier to read and a bit more efficient:

def create_particles(self):
"""
create a list of particles and then create neighborhoods if it's
called for (k > 0)
"""
for i in range(self.numParticles):
particle = self.Particle(i, self.worldWidth, self.worldHeight, self.k)
self.pList.append(particle)

# fill neighbor lists
if self.k > 0:
for p in self.pList:
start = p.index - (self.k / 2)
stop = p.index + (self.k / 2) + 1
for x in range(start, stop):
neighbor = x
if x > self.numParticles:
neighbor = x % self.numParticles
elif x < 0:
neighbor = self.numParticles + x
elif x == self.numParticles:
neighbor = 0
p.neighbors.append(neighbor)
self.update_local_bests()

self.update_global_bests()

3. I will use more format() magic in __str__ method as well:

def __str__(self):
"""Creates string representation of particle"""
# Yes, it's a bit explicit, but we are not using locals() which
# is kind of antipattern
extras = 'l: {}\n'.format(self.lBest) if k > 0 else '\n'
result = """
i: {index!s}
x: {x!s}
y: {y!s}
v_x: {velocity_x!s}
v_y: {velocity_y!s}
b: {best_particle!s}
{extras}
""".format(
index=self.index, x=self.x, y=self.y,
velocity_x=self.velocity_x, velocity_y=self.velocity_y,
best_particle=self.pBest[0], extras=extras
)
return result

4. If you consider createParticles method as a private one, start it's name with underscore _create_particles.

5. I'm not 100% sure of making Particle class as a class which lives in scope of ParticleList. I will make it global. I believe you can use it later outside of the ParticleList.

6. As an alternative solution for __init__ parameters, I can propose using def __init__(self, **kwargs): trick. But it will make your code harder to understand, so I agree with Curt F. solution.

• Thank you so much for your two cents, I promise it's worth way more than that to me. Could you further explain your format() magic? Specifically the second call. – dockleryxk Jul 14 '15 at 22:39
• also, I made Particle a subclass because this is simulating a swarm. Thus there will never be only one particle, and a list will always be needed. – dockleryxk Jul 14 '15 at 22:54
• @dockleryxk, in the second format call I've tried to escape using of locals() method and use more explicit approach to map the exact values of the variables to the exact placeholders in the string. I believe my call will be more efficient from the performance perspective. – Mikhail Chernykh Jul 15 '15 at 20:11


text:
# Tag Info

Here is a concrete example of how the receiver could extract information about the senders input: Assume the circuit to be evaluated is the simple circuit computing $(x \oplus (y \wedge z)) = w$, where $x, y$ is the input of the sender and $z$ the input of the receiver. Note, that $w$ and $z$ alone does not reveal the value of $y$ (you can write down the ...


text:
## The projective interpretation of the eight 3-dimensional homogeneous geometries.(English)Zbl 0889.51021

Let $$X$$ be a 3-dimensional simply connected complete Riemannian manifold, and let $$G$$ be the group of all isometries of $$X$$. The pair $$(X,G)$$ is called a 3-dimensional (homogeneous) geometry, if $$G$$ acts transitively on $$X$$ and there is a discrete subgroup $$\Gamma$$ of $$G$$ such that the quotient of $$X$$ modulo $$\Gamma$$ is compact.
W. P. Thurston proved in [Bull. Am. Math. Soc., New. Ser. 6, 357-379 (1982; Zbl 0496.57005)], that any 3-dimensional geometry $$(X,G)$$ is equivariantly equivalent to one of the eight spaces $$E^3$$, $$H^3$$, $$S^3$$, $$S^2\times R$$, $$H^2\times R$$, $$\widetilde{\text{SL}}_2\text{R}$$, $$\mathbf{Nil}$$ and $$\mathbf{Sol}$$, with $$G=\text{Isom}(X)$$.
In Felix Klein’s spirit the author constructs in great detail embeddings of these geometries in the 3-dimensional real projective space $$P_3$$R (together with a suitable bilinear form), where $$G$$ appears as a subgroup of the collineation group of $$P_3R$$. These embeddings are evident if $$X$$ is $$E^3$$, $$H^3$$, or $$S^3$$. For most of the other spaces, however, this is much more complicated.

### MSC:

 51H25 Geometries with differentiable structure 53C30 Differential geometry of homogeneous manifolds 52C22 Tilings in $$n$$ dimensions (aspects of discrete geometry)

Zbl 0496.57005
Full Text:


text:
When we mention ‘education’ many traders think about expensive colleagues, business schools, and courses, but they are not a necessity. There are many free alternatives. For example, here on binaryoptions.org.za traders can read free articles about different strategies and topics from binary options trading. Most brokers also offer free webinars, reading materials, videos etc.
In 2016 The Times of Israel ran several articles on binary options fraud. "The wolves of Tel Aviv: Israel's vast, amoral binary options scam exposed" revealed that the industry is a scam.[13] A second article describes in detail how a binary options salesman fleeced clients. "According to one ex-employee of a firm that employs over 1,000 people in a high-rise office building in Tel Aviv, losses are guaranteed because the 'dealing room' at the binary options firm controls the trading platform — like the crooked ownership of a rigged casino manipulating the roulette wheel".[14]
Like other brokers, this option too offers a wide range of assets from different parts of the world. However, not to forget, all assets are born equal. If there is any asset that can assist you standing out in the crowd and become very successful, then it is the EUR/USD currency pair. It allows the traders to invest in Euro in connection with the U.S. dollar. Moreover, it offers the highest payout.
There has long been a lively debate concerning whether or not binary options trading constitutes gambling. Binary options brokers tend to argue that it is not gambling, suggesting that there are third parties involved in payments (meaning it isn't just the customer against the house), as well as that brokers collect no commission for a trade that ends in a "draw."
Learn how a contract price is determined. The offer price of a binary options contract is roughly equal to the market's perception of the probability of the event happening. The price of a binary option is presented as a bid/offer price that shows the bid (sell) price first and offer (buy) price second, for example, 3/96, which represents a bid price of $3 and an offer price of$96.

# One of the best things about trading is that you can make small low risk investments. You can start trading in our recommended trading platforms such as Boss Capital, 24Option, Optionfair, Tradorax, Exbino, Opteck, Stockpair, ETX Capital or HighLow, in as low as \$100, which you may double in a single transaction. Select your preferred trading broker from the top of the page, register, start trading and earning money.

There has long been a lively debate concerning whether or not binary options trading constitutes gambling. Binary options brokers tend to argue that it is not gambling, suggesting that there are third parties involved in payments (meaning it isn't just the customer against the house), as well as that brokers collect no commission for a trade that ends in a "draw."
If we denote by S the FOR/DOM exchange rate (i.e., 1 unit of foreign currency is worth S units of domestic currency) we can observe that paying out 1 unit of the domestic currency if the spot at maturity is above or below the strike is exactly like a cash-or nothing call and put respectively. Similarly, paying out 1 unit of the foreign currency if the spot at maturity is above or below the strike is exactly like an asset-or nothing call and put respectively. Hence if we now take {\displaystyle r_{\mathrm {FOR} }} , the foreign interest rate, {\displaystyle r_{DOM}} , the domestic interest rate, and the rest as above, we get the following results.


text:
If you're seeing this message, it means we're having trouble loading external resources on our website.

Hvis du er bak et webfilter, vær vennlig å sørge for at domenene .kastatic.org og .kastatic.org ikke er blokkert.

Hovedinnhold

Geometric series as a function

Videotranskripsjon

We have a function right over here defined as an infinite series. What I want to attempt to do in this video is to see if we can express it in a more traditional form. And so the thing that might jump out at you is, well, look, if this is a geometric series, we know how to take the sum of an infinite geometric series, at least over the x values where the thing will actually converge. And so let's first see if this is a geometric series. Well, the telltale pattern of a geometric series is when you go from one term to the next, you're multiplying by a common ratio. So let's see. To go from 2 to negative 8x squared, what do you have to multiply by? We have to multiply by negative 4x squared. So we've multiplied by negative 4x squared. Now, do we multiply by that same amount to get to 32x to the fourth? Well sure. Negative 4x squared times negative 8x squared is going to be positive 32x to the fourth. Multiply by negative 4x squared again, you're going to get to negative 128x to the sixth. So the common ratio is negative 4x squared, our first term is 2, so we can rewrite this. We can rewrite f of x as being equal to the sum from n equals 0 to infinity of-- let's see, our first term here is 2-- 2 times negative 4x squared to the n-th power. This is a geometric series where our common ratio is negative 4x squared to the n-th power. Now, when will this thing right over here converge? Well, we know that a geometric series will converge if the absolute value of its common ratio is less than 1. So let me write this down. So converge if the absolute value of the common ratio, negative 4x squared, is less than 1. Well, this-- the way it's written right now-- is going to be a negative value. So the absolute value of this is just going to be 4x squared. Right? x squared is going to be non-negative, so 4x squared is going to be non-negative. Negative 4x squared is going to be non-positive. So if you're taking the absolute value of a non-positive thing, that's going to be the same thing as the absolute value of the negative of it. So this just has to be less than 1. And the absolute value of something that is strictly non-negative like this, well, that's just going to be 4x squared-- these two statements are equivalent-- and that has to be less than 1. Can divide both sides by 4, you get x squared is less than 1/4. And so we can say that the absolute value of x has to be less than 1/4, or we could say that negative 1/4 has to be less than x, which has to be less than positive 1/4. So expressed this way, we're giving the interval of convergence. This thing will converge as long as x is in this interval. Expressed this way, we're really saying the radius of convergence. This will converge as long as x is less than our radius of convergence, as long as the absolute value of x is less than our radius of convergence, as long as x stays less than 1/4 away from 0. To make it a little bit clearer, you could rewrite this as the distance between x and 0, as long as this- this, you could view this as the distance between x and 0-- as long as this stays less than 1/4, this thing is going to converge. So this is the interval of convergence, this, you could view, 1/4, you could view as the radius of convergence. Now with that out of the way, we've thought about where this thing converges, let's think about what it converges to. Well, we've done this multiple times. This is going to be equal to our first term, 2 over 1 minus our common ratio. Our common ratio is negative 4x squared. So this is going to give us-- and we deserve a drum roll-- 2 over 1 plus 4x squared. So this expression is going to be equal to this, as long as x is within our interval of convergence.


text:
# Lambda is a linking scheme

The lambda expression is implemented by the invokedynamic JVM instruction, and in this article let’s see why the invokedynamic instruction is actually a way for method linkage.

Firstly let’s define a interface and a class to be called by lambda expression:

/**
* Created by weinanli on 11/06/2017.
*/
public class Calculator {
interface IntegerMath {
int operation(int a, int b);
}

public int operateBinary(int a, int b, IntegerMath op) {
return op.operation(a, b);
}
}

From the above code, we can see the Calculator class has a operateBinary(...) method. The method accepts two integers and a IntegerMath interface for calculation. The IntegerMath interface defines an operation(...) method for the actual calculation process.

Before JDK7, we need to implement the IntegerMath interface by creating a class. With lambda expression, we can reduce the amount of code. Here is the example:

/**
* Created by weinanli on 11/06/2017.
*/
public class PlayWithLambda {
public static void main(String[] args) throws Exception {
Calculator myApp = new Calculator();
Calculator.IntegerMath addition = (a, b) -> a + b;
Calculator.IntegerMath subtraction = (a, b) -> a - b;

myApp.operateBinary(20, 10, subtraction);
}
}

From the above code, we have created two IntegerMath instances with lambda expressions: one is addition, and the other is subtraction.

The lambda expression let us define two anonymous class instances that implements the IntegerMath interface. We just need to write the implemented code of the operation(...) method in lambda expression, and this greatly reduce the amount of the code we need to write.

This works because in the IntegerMath interface, it just contain one method, so the lambda expression won’t have ambiguous meaning: it just implement the sole method defined in the interface.

In the IntelliJ IDE environment, it can detect the lambda expressions and display the link between the expression and the interface method. Here is the screenshot:

From the above screenshot, we can see the $\lambda$ symbol displayed at the left of the two lines of lambda expression symbols. If we click the symbol, it will navigate the code to the interface definition. Here is the screenshot:

After clicking the $\lambda$ symbol in PlayWithLambda class, it navigates to the IntegerMath interface method as shown above.

Now we can check the bytecode to see how this link works in the underlying level. Here is the decompiled byte code of the PlayWithLambda class:

$javap -c -v PlayWithLambda.class Classfile /Users/weinanli/Desktop/java/PlayWithLambda.class Last modified Jun 11, 2017; size 1161 bytes MD5 checksum 54fe2e615e51b6eea59f94252110b2c9 Compiled from "PlayWithLambda.java" public class PlayWithLambda minor version: 0 major version: 52 flags: ACC_PUBLIC, ACC_SUPER Constant pool: #1 = Methodref #8.#22 // java/lang/Object."<init>":()V #2 = Class #23 // Calculator #3 = Methodref #2.#22 // Calculator."<init>":()V #4 = InvokeDynamic #0:#28 // #0:operation:()LCalculator$IntegerMath;
#5 = InvokeDynamic      #1:#28         // #1:operation:()LCalculator$IntegerMath; #6 = Methodref #2.#30 // Calculator.operateBinary:(IILCalculator$IntegerMath;)I
#7 = Class              #31            // PlayWithLambda
#8 = Class              #32            // java/lang/Object
#9 = Utf8               <init>
#10 = Utf8               ()V
#11 = Utf8               Code
#12 = Utf8               LineNumberTable
#13 = Utf8               main
#14 = Utf8               ([Ljava/lang/String;)V
#15 = Utf8               Exceptions
#16 = Class              #33            // java/lang/Exception
#17 = Utf8               lambda$main$1
#18 = Utf8               (II)I
#19 = Utf8               lambda$main$0
#20 = Utf8               SourceFile
#21 = Utf8               PlayWithLambda.java
#22 = NameAndType        #9:#10         // "<init>":()V
#23 = Utf8               Calculator
#24 = Utf8               BootstrapMethods
#25 = MethodHandle       #6:#34         // invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; #26 = MethodType #18 // (II)I #27 = MethodHandle #6:#35 // invokestatic PlayWithLambda.lambda$main$0:(II)I #28 = NameAndType #36:#40 // operation:()LCalculator$IntegerMath;
#29 = MethodHandle       #6:#41         // invokestatic PlayWithLambda.lambda$main$1:(II)I
#30 = NameAndType        #42:#43        // operateBinary:(IILCalculator$IntegerMath;)I #31 = Utf8 PlayWithLambda #32 = Utf8 java/lang/Object #33 = Utf8 java/lang/Exception #34 = Methodref #44.#45 // java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
#35 = Methodref          #7.#46         // PlayWithLambda.lambda$main$0:(II)I
#36 = Utf8               operation
#37 = Class              #47            // Calculator$IntegerMath #38 = Utf8 IntegerMath #39 = Utf8 InnerClasses #40 = Utf8 ()LCalculator$IntegerMath;
#41 = Methodref          #7.#48         // PlayWithLambda.lambda$main$1:(II)I
#42 = Utf8               operateBinary
#43 = Utf8               (IILCalculator$IntegerMath;)I #44 = Class #49 // java/lang/invoke/LambdaMetafactory #45 = NameAndType #50:#53 // metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
#46 = NameAndType        #19:#18        // lambda$main$0:(II)I
#47 = Utf8               Calculator$IntegerMath #48 = NameAndType #17:#18 // lambda$main$1:(II)I #49 = Utf8 java/lang/invoke/LambdaMetafactory #50 = Utf8 metafactory #51 = Class #55 // java/lang/invoke/MethodHandles$Lookup
#52 = Utf8               Lookup
#53 = Utf8               (Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; #54 = Class #56 // java/lang/invoke/MethodHandles #55 = Utf8 java/lang/invoke/MethodHandles$Lookup
#56 = Utf8               java/lang/invoke/MethodHandles
{
public PlayWithLambda();
descriptor: ()V
flags: ACC_PUBLIC
Code:
stack=1, locals=1, args_size=1
1: invokespecial #1                  // Method java/lang/Object."<init>":()V
4: return
LineNumberTable:
line 1: 0

public static void main(java.lang.String[]) throws java.lang.Exception;
descriptor: ([Ljava/lang/String;)V
flags: ACC_PUBLIC, ACC_STATIC
Code:
stack=4, locals=4, args_size=1
0: new           #2                  // class Calculator
3: dup
4: invokespecial #3                  // Method Calculator."<init>":()V
7: astore_1
8: invokedynamic #4,  0              // InvokeDynamic #0:operation:()LCalculator$IntegerMath; 13: astore_2 14: invokedynamic #5, 0 // InvokeDynamic #1:operation:()LCalculator$IntegerMath;
19: astore_3
21: bipush        40
23: iconst_2
25: invokevirtual #6                  // Method Calculator.operateBinary:(IILCalculator$IntegerMath;)I 28: pop 29: aload_1 30: bipush 20 32: bipush 10 34: aload_3 35: invokevirtual #6 // Method Calculator.operateBinary:(IILCalculator$IntegerMath;)I
38: pop
39: return
LineNumberTable:
line 3: 0
line 4: 8
line 5: 14
line 7: 20
line 8: 29
line 9: 39
Exceptions:
throws java.lang.Exception
}
SourceFile: "PlayWithLambda.java"
InnerClasses:
static #38= #37 of #2; //IntegerMath=class Calculator$IntegerMath of class Calculator public static final #52= #51 of #54; //Lookup=class java/lang/invoke/MethodHandles$Lookup of class java/lang/invoke/MethodHandles
BootstrapMethods:
0: #25 invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; Method arguments: #26 (II)I #27 invokestatic PlayWithLambda.lambda$main$0:(II)I #26 (II)I 1: #25 invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
Method arguments:
#26 (II)I
#29 invokestatic PlayWithLambda.lambda$main$1:(II)I
#26 (II)I

From the above decompiled code, we can see the two lines invokedynamic instructions:

$javap -c -v PlayWithLambda.class | grep invokedynamic 8: invokedynamic #4, 0 // InvokeDynamic #0:operation:()LCalculator$IntegerMath;
14: invokedynamic #5,  0              // InvokeDynamic #1:operation:()LCalculator$IntegerMath;  We know the above two lines of instructions are corresponding to the two lines of lambda expressions in the Java code. In above code, the #4, and #5 parameters are the indexes to the constant pool of the code. In the comments of the above code, it has already translated the real contents of the indexes to us, and they are two InvokeDynamic instances. We can also see the table in above decompiled code like this: Constant pool: #4 = InvokeDynamic #0:#28 // #0:operation:()LCalculator$IntegerMath;
#5 = InvokeDynamic      #1:#28         // #1:operation:()LCalculator$IntegerMath;  The InvokeDynmaic instances also receives two parameters. The first one is an index to the bootstrap method table, and they are #0 and #1. The second parameter is an index to the constant pool, and in the comment is has translated the index into the content of the index. Here is the relative info in the constant pool: Constant pool: #28 = NameAndType #36:#40 // operation:()LCalculator$IntegerMath;

From the above output, we can see the parameter is an instance of NameAndType class, and it refers to the interface method to be invoked.

Now let’s see the bootstrap methods table:

BootstrapMethods:
0: #25 invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite; Method arguments: #26 (II)I #27 invokestatic PlayWithLambda.lambda$main$0:(II)I #26 (II)I 1: #25 invokestatic java/lang/invoke/LambdaMetafactory.metafactory:(Ljava/lang/invoke/MethodHandles$Lookup;Ljava/lang/String;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodType;Ljava/lang/invoke/MethodHandle;Ljava/lang/invoke/MethodType;)Ljava/lang/invoke/CallSite;
Method arguments:
#26 (II)I
#29 invokestatic PlayWithLambda.lambda$main$1:(II)I
#26 (II)I

The above two LambdaMetafactory.metafactory(...) methods are invoked by the two lambda expressions, and they will link the lambda expressions with the two anonymous class instances that implements the IntegerMath interface.

The final result returned by LambdaMetafactory.metafactory(...) is a CallSite class instance, and it contains the MethodHandle class instance to be invoked.

From the above process, we can see the lambda expression helps us to create anonymous class and the Java compiler will generate the invokedynamic instruction for the lambda expression. At last, the bootstrap method like LambdaMetafactory.metafactory(...) will be put into the bootstrap methods table, and they are used to do the real linking job.


text:
# How can I simulate a model electronic hole?

Suppose I can solve time-dependent Schrödinger equation for several 1D particles (currently 3). I'd like to see, what an electronic hole is and how it behaves — in a series of numerical experiments.

I know that a hole is lack of electron in a sea of occupied electron states, but I think I don't quite understand, what it really is: do I need to have electron repulsion to see any useful effects? Do I need much more electrons for such a simulation than 3? What initial conditions should I use to see the hole? I'm thinking of using a model "crystal" potential with 3 cells — would this be enough?

As an example of what I'd like to actually see is exciton, namely how its wave packet wanders across the crystal. For an electron in conductivity band, taken as a wavepacket, I'd expect it to look like increase in probability density in the place where the wavepacket is located, and for hole it might be a similar decrease in charge density, so I guess the exciton should look like an increase of charge density in a wave packet and decrease around this wave packet. Is it right? Or is it actually invisible as a charge density?

Another example would be seeing excitonic states in band gap, but for this I don't really understand, what to compare it with — should I use some single-particle approximation to compute band structure without excitonic states, and then after computation of true energy states search for extra states in band gap, or how should I go about finding them?

For example, consider a bubble rising in a glass of cola... yes, you could create a complicated model of all the liquid moving within the glass, but it's much easier to just focus on the way the bubble moves (i.e. the tiny area with no liquid). In the same way, you can just pretend that the "hole" in the valence band is a single positively-charged particle rather than a gap in the middle of a complicated sea of electrons. The simplest model then just assigns an effective mass to the hole $m_h^*$, and its motion in the solid is described using a dispersion relation: $$E_k = \frac{\hbar^2k^2}{2m_h^*}$$
The simplest model of an exciton (in a bulk semiconductor) could then treat the hole and an electron as an orbital pair with a reduced mass of: $$\frac{1}{\mu} = \frac{1}{m_e^*} + \frac{1}{m_h^*}$$
The Bohr radius and exciton binding energy for the lowest (1s) exciton state are then given by an analogy with a hydrogen atom: $$\lambda = \frac{4\pi\epsilon_r\epsilon_0\hbar^2}{\mu e^2}$$ and $$E_b = \frac{\mu e^4}{32\pi^2\hbar^2\epsilon_r^2\epsilon_0^2}$$
Note, though that there are several energy bands that a hole can occupy, and the simple effective-mass model breaks down as the kinetic energy becomes larger. In those cases, you'd need a more sophisticated model, such as $k\cdot p$ theory. Also, the bulk exciton model only really works if you are considering a single electron-hole pair in a material. You start to need complicated many-body models if you want to go any further than that. It is possible, though, to consider single excitons in heterostructures (quantum wells etc) through a variational approach to minimising the binding energy. See, for example, Chapter 6 in "Quantum Wells, Wires and Dots", P. Harrison, 3rd Ed., Wiley, Chichester (2009).


text:
Documentation

# phasez

Phase response of digital filter

## Syntax

[phi,w] = phasez(b,a,n)
[phi,w] = phasez(sos,n)
[phi,w] = phasez(d,n)
[phi,w] = phasez(...,n,'whole')
phi = phasez(...,w)
[phi,f] = phasez(...,n,fs)
phi = phasez(...f,fs)
[phi,w,s] = phasez(...)
phasez(...)

## Description

[phi,w] = phasez(b,a,n) returns the n-point unwrapped phase response vector, phi, in radians and the frequency vector, w, in radians/sample for the filter coefficients specified in b and a. The values of the frequency vector, w, range from 0 to π. If n is omitted, the length of the phase response vector defaults to 512. For best results, set n to a value greater than the filter order.

[phi,w] = phasez(sos,n) returns the unwrapped phase response for the second order sections matrix, sos. sos is a K-by-6 matrix, where the number of sections, K, must be greater than or equal to 2. If the number of sections is less than 2, phasez considers the input to be the numerator vector, b. Each row of sos corresponds to the coefficients of a second-order (biquad) filter. The ith row of the sos matrix corresponds to [bi(1) bi(2) bi(3) ai(1) ai(2) ai(3)].

[phi,w] = phasez(d,n) returns the unwrapped phase response for the digital filter, d. Use designfilt to generate d based on frequency-response specifications.

[phi,w] = phasez(...,n,'whole') returns frequency and unwrapped phase response vectors evaluated at n equally-spaced points around the unit circle from 0 to 2π radians/sample.

phi = phasez(...,w) returns the unwrapped phase response in radians at frequencies specified in w (radians/sample). The frequencies are normally between 0 and π. The vector w must have at least two elements.

[phi,f] = phasez(...,n,fs) return the unwrapped phase vector phi in radians and the frequency vector in hertz. The frequency vector ranges from 0 to the Nyquist frequency, fs/2. If the 'whole' option is used, the frequency vector ranges from 0 to the sampling frequency.

phi = phasez(...f,fs) return the phase response in radians at the frequencies specified in the vector f (in hertz) using the sampling frequency fs (in hertz). The vector f must have at least two elements.

[phi,w,s] = phasez(...) return plotting information, where s is a structure array with fields you can change to display different frequency response plots.

phasez(...) with no output arguments plots the phase response of the filter. If you input the filter coefficients or second order sections matrix, the current figure window is used. If you input a digitalFilter, the step response is displayed in FVTool.

### Note

If the input to phasez is single precision, the phase response is calculated using single-precision arithmetic. The output, phi, is single precision.

## Examples

collapse all

Use designfilt to design an FIR filter of order 54, normalized cutoff frequency $0.3\pi$ rad/s, passband ripple 0.7 dB, and stopband attenuation 42 dB. Use the method of constrained least squares. Display the phase response of the filter.

Nf = 54;
Fc = 0.3;
Ap = 0.7;
As = 42;

d = designfilt('lowpassfir','CutoffFrequency',Fc,'FilterOrder',Nf, ...
'PassbandRipple',Ap,'StopbandAttenuation',As, ...
'DesignMethod','cls');
phasez(d)

Design the same filter using fircls1. Keep in mind that fircls1 uses linear units to measure the ripple and attenuation.

pAp = 10^(Ap/40);
Apl = (pAp-1)/(pAp+1);

pAs = 10^(As/20);
Asl = 1/pAs;

b = fircls1(Nf,Fc,Apl,Asl);
phasez(b)

Design a lowpass equiripple filter with normalized passband frequency $0.45\pi$ rad/s, normalized stopband frequency $0.55\pi$ rad/s, passband ripple 1 dB, and stopband attenuation 60 dB. Display the phase response of the filter.

d = designfilt('lowpassfir', ...
'PassbandFrequency',0.45,'StopbandFrequency',0.55, ...
'PassbandRipple',1,'StopbandAttenuation',60, ...
'DesignMethod','equiripple');
phasez(d)

Design an elliptic lowpass IIR filter with normalized passband frequency $0.4\pi$ rad/s, normalized stopband frequency $0.5\pi$ rad/s, passband ripple 1 dB, and stopband attenuation 60 dB. Display the phase response of the filter.

d = designfilt('lowpassiir', ...
'PassbandFrequency',0.4,'StopbandFrequency',0.5, ...
'PassbandRipple',1,'StopbandAttenuation',60, ...
'DesignMethod','ellip');
phasez(d)


text:
De Morgan's Laws (Set Theory)/Set Difference/Family of Sets

Theorem

Let $S$ and $T$ be sets.

Let $\left\langle{T_i}\right\rangle_{i \mathop \in I}$ be a family of subsets of $T$.

Then:

Difference with Intersection

$\displaystyle S \setminus \bigcap_{i \mathop \in I} T_i = \bigcup_{i \mathop \in I} \left({S \setminus T_i}\right)$

where:

$\displaystyle \bigcup_{i \mathop \in I} T_i := \left\{{x: \exists i \in I: x \in T_i}\right\}$

that is, the Definition:Union of Family of $\left\langle{T_i}\right\rangle_{i \mathop \in I}$.

Difference with Union

$\displaystyle S \setminus \bigcup_{i \mathop \in I} T_i = \bigcap_{i \mathop \in I} \left({S \setminus T_i}\right)$

where:

$\displaystyle \bigcap_{i \mathop \in I} T_i := \left\{{x: \forall i \in I: x \in T_i}\right\}$

that is, the intersection of $\left\langle{T_i}\right\rangle_{i \mathop \in I}$

Source of Name

This entry was named for Augustus De Morgan.


text:
# Spending and Tax Multipliers

The spending (or expenditure) multiplier is a concept that measures the change in expenditure, which causes a more-than-proportionate change in gross domestic product (GDP). The tax multiplier affects expenditures but at a lower level than spending.

The spending multiplier is one of the key concepts of Keynesian economics. The spending multiplier is the factor by which gains in total output are greater than the change in spending that caused it. The spending multiplier is a formula for determining how much an increase in government spending will affect the economy. This concept is a way to describe how government intervention impacts the overall economy by its changes in spending. A fiscal injection magnifies the initial amount spent by the government in the economy due to the multiplier effect. Thus, for each dollar the government invests, the impact on the economy is multiplied. For instance, if the government invests $1 million on an infrastructure project, it can be seen as contributing more than$1 million to the economy. This creates a domino effect because additional workers must be hired for the project, who will receive incomes. In turn, their incomes are spent elsewhere, and that money spent becomes another person's income, and so on. The benefit of that project expenditure, then, is multiplied. The use of government spending adds to output because it contributes to the workers' disposable income, and the workers can either spend it or save it. The increase in disposable income raises consumption, which increases gross domestic product (GDP). According to the spending multiplier concept, the consumption, as a result of spending, will further increase future consumption and additionally increase GDP.

The numerical value of the multiplier is dependent on marginal propensity to consume (MPC) and marginal propensity to save (MPS). The basic equation for the spending multiplier is:
$\frac1{1-\;\mathrm{MPC}}=\mathrm{The}\;\mathrm{spending}\;\mathrm{multiplier}$
MPC is the marginal propensity to consume. If a nation, on average, receives $20 and spends$16, the MPC would be 0.8. Then, following the equation, 1 is divided by (1 – 0.8), or 1 is divided by 0.2. When 1 is divided by 0.2, the multiplier is 5. In this scenario, therefore, the economy benefited five times more than the monetary amount of the spending. The multiplier concept is helpful in many stimulus scenarios and is not limited to direct cash payments. A stimulus is the use of expansionary fiscal or monetary policy to help kickstart economic growth in a sluggish or depressed economy.

The multiplier effect implies that the government should invest money in the economy during an economic downturn. From the Keynesian viewpoint, when the economy is underperforming, government intervention is crucial to its recovery. Keynes argued that if the government curbs spending in an economic depression, which might be a natural choice when revenue is smaller, the economy could weaken further. The domino effect from the spending multiplier helps support the decision for a government to spend money, even during recessionary times. The multiplier concept influenced policy-making decisions in developed countries in the 20th century and continues to influence government policy today.

The tax multiplier is the effect on the economy from changes in tax policy. This multiplier is different than spending multipliers. Its effects are much smaller than spending multipliers. This is because when the government lowers taxes, it is not actually injecting new income into the economy as new spending would because consumers can choose to either spend or save. Conversely, the spending multiplier is a direct injection of spending. The tax multiplier is calculated as the negative MPC divided by the MPS, which can also be written as 1 minus the MPC.
$\frac{-MPC}{(1-MPC)}=\mathrm{The}\;\mathrm{tax}\;\mathrm{multiplier}$
For example, if the government decides to increase expenditures and spend $10 million on a project, that money is injected in the economy. With an MPC of 0.8, the spending multiplier was shown to be 5. The total impact would be$50 million in the economy with a $10 million government spending project. If the total amount of tax dollars is reduced by$10 million, only the amount ($10 million) multiplied by the tax multiplier will be spent in the economy. Because a reduction in taxes leads to an increase in income, the relationship is negative. Thus, the tax multiplier is dependent on what amount a consumer will spend or save with the tax cut. In this example where MPC = 0.8, the tax multiplier is calculated as $-0.8/(1-0.8)$ . Multiplying this value by the$10 million spent, we find that the total injection from a tax cut of $10 million would be$40 million.
$-\10,000\;\times\;\left(\frac{-0.8}{1-0.8}\right)=\;-\10,000\;\times\;-\;4\;=\;\40,000\;$


text:
# RADIOACTIVE DECAY : Science, Physics, Chemistry

Learners observe a model of radioactive decay using paper and then consider various related issues.

Concepts

Resource Details


text:
{{ message }}
/ concordialang Public
Switch branches/tags
Could not load branches
Nothing to show

Cannot retrieve contributors at this time
993 lines (769 sloc) 28.6 KB

# Overview of the Concordia Language

👉 TIP: See also the supported actions.

Translations: Português 🌎

## Language constructions

# This is a comment

Feature: Foo # This is also a comment

### Language

Defines the language used in the current specification file.

Notes:

• Local declaration.
• Just one declaration per file.
• Defined as a special comment.

Example 1:

#language: pt

Example 2:

#language: es-ar

### Import

Imports the definitions of another file.

Notes:

• Local declaration.
• Allowed more than one declaration per file.

Examples:

import "file1.feature"
import "path/to/file2.feature"

### Tag

Adds information to a language construction.

Notes:

• Local declaration.
• Allowed more than one declaration per language construction.

Example 1 - single tag per line:

@critical

Example 2 - more than one per line:

@critical @slow @gui @generated

Example 3 - tag with number:

@importance( 5 )

Example 4 - tag with text:

@extends( Full Name )

Reserved tags:

• @scenario( <number> ): references a scenario.
• @variant( <number> ): references a variant.
• @importance( <number> ): indicates the importance of a declaration. The importance is as high as its number.
• @generated: indicates that a Test Case was computer-generated.
• @fail: indicates that a Test Case should fail.
• @global: defines a User Interface Element as global. *Yet not available in the tool
• @ignore: whether applied to a Variant, it will not produce Test Cases; whether applied to a Test Case, it will not produce test scripts.
• @generate-only-valid-values: avoids that a UI Element's property be used for generating values considered invalid. This is specially useful for using with masked input fields, in which the system does not let a user to type invalid characters on it. For instance:
UI Element: Year
- data type is integer
@generate-only-valid-values
- format is "/^[0-9]{1-3}$/" Otherwise I must see "Year must be a number."  The above example will avoid generating invalid input values (e.g.,, "A") for testing the format of the Year. Reserved for future use: • @extends( <name> ) allows inheritance of User Interface Elements. • @category( <name> ) specifies a category. Useful for organizing the documentation and for filtering it. • @issue( <number> ) references an Issue. ### Feature Feature of the system. Notes: • Global declaration. • Just one declaration per file. Example 1: Feature: Admininistrator Login Example 2: Feature: Admininistrator Login As an administrator I would like to login So that I can access the system Example 3: Feature: Admininistrator Login In order to access the system As an administrator I would like to login ### State State of the system. Notes: • Local declaration. • Only declared inside Variant steps. • Declaration in a Given step means that the state is a precondition. • Declaration in a When step means that the state is a state call. • Declaration in a Then step means that the state is a postcondition. Precondition: Given that I have ~user logged in~ State Call - that is the producer of state will be called: When I need the state ~payment method selected~ Postcondition: Then I have ~paid~ ### Scenario Used to describe a usage scenario for a feature, in business terms. Its sentences are not used to generate test cases. Notes: • Local declaration. • Allowed more than one declaration per Feature. Example 1: Scenario: Successful login Given that I start the system And I am not logged in When I inform my credentials Then I am able to enter the system Example 2: Scenario: Unsuccessful login Given that I start the system And I am not logged in When I inform invalid credentials Then I am not able to enter the system ### Constants Declaration block with constant values. Notes: • Global declaration. • Just one declaration per file. • A declaration may have more than one constant. • Namespace is shared with Tables and Databases. Example: Constants: - "PI" is 3.14159 - "AppName" is "My App" ### User Interface Element Element of the User Interface. Notes: • Local or global declaration - although global is not yet supported by Concordia. • Allowed more than one declaration per Feature. • Global declarations allowed through the tag @global - not supported yet. • Inheritance allowed through the the tag @extends, e.g., @extends(Other Element) - not supported yet. • May have properties. • Properties must be preceded by a dash (-). Allowed properties: • id • type, defaults to textbox • editable, defaults to true when an editable type is used, that is, when it accepts input data. • data type, defaults to string • value • minimum length • maximum length • minimum value • maximum value • format • required, defaults to false #### Property id • Example: - id is "name" • Default value is the element name in camel case and without spaces, e.g., "Some Name" becomes "someName" • Value must be declared between quotes ("). Internal quotes must be escaped. Example: "//*[id=\"phone\"]" • Support the following notation: • "value" denotes an id • "#value" denotes an id • "//value" denotes a xpath • "@value" denotes a name • "~value" denotes a mobile name • ".value" denotes a css • Multiple identifiers are denoted by id in [ "<value1>", "<value2>", ... ] Yet not supported by the tool • Example: id in [ "birthDate", "~birthDate" ] #### Property type • Example: - type is button • Default value is textbox • Does not need quotes (") • Allowed values are: • button • checkbox or check • cookie • div • file input • image • label • list item or li • link • ordered list or ol • page • paragraph • radio or radio button • screen • select or combo or combobox or combo box or selection box • slider • span • tab • table • text • textbox or input • textarea or text area • title • window • unordered list or ul • url or address or ip or site #### Property editable • Example: - editable is true • Allowed values are true and false • Does not need quotes (") • Default value is false, but assumes true automatically when a least one of the following conditions occur: • A type considered editable is used, that is: • checkbox • fileInput • select • table • textbox • textarea • One of the following properties is defined: • minimum length • maximum length • minimum value • maximum value • value #### Property data type • Example: - data type is double • Does not need quotes (") • Allowed types are: • string • integer • double • date • time • datetime • Precision of double values is inferred from declared rules, e.g., 12.50 makes Concordia to know that the precision is 2. • By default, date values assume the format YYYY-MM-DD (that is, year-month-day). #### Property value • Accepted values: • Examples: • - value is "hello" • - value is 5 • - value is [PI] • - value is "2019-12-25" • - value is in [ "Male", "Female", "Other" ] • - value comes from "SELECT ..." • - value is equal to {Other UI Element} • Accepts negation. Examples: • - value is not in [ 10, 20, 30 ] • - value is not in "SELECT ..." • - value is not equal to {Other UI Element} #### Property minimum value • Accepted values: • Examples: • - minimum value is 5 • - minimum value is [PI] • - minimum value is in [ 5, 10, 20 ] • - minimum value comes from "SELECT ..." • - minimum value is equal to {Other UI Element} #### Property maximum value • Same syntax as minimum length • Examples: • - maximum value is 5 • - maximum value is [PI] • - maximum value is in [ 5, 10, 20 ] • - maximum value comes from "SELECT ..." • - maximum value is equal to {Other UI Element} #### Property minimum length • Same syntax as minimum value • Examples: • - minimum length is 5 • - minimum length is [MIN] • - minimum length is in [ 5, 10, 20 ] • - minimum length comes from "SELECT ..." • - minimum length is equal to {Other UI Element} #### Property maximum length • Same syntax as minimum length • Examples: • - maximum length is 50 • - maximum length is [MAX] • - maximum length is in [ 10, 20, 30 ] • - maximum length comes from "SELECT ..." • - maximum length is equal to {Other UI Element} #### Property format • Accepted values: • Must be a valid Regular Expression • Examples: • - format is "/[A-Za-z ._-]{2,50}/" • - format is "/^[0-9]{2}\.[0-9]{3}\-[0-9]{3}$/"
• - format is [Some Constant with RegEx]

#### Property required

• Accepted values are true or false
• When not declared, the property assumes false (that is, not required)
• The value true is optional. For example, the following declaration is accepted as true:
• - required
• Examples:
• - required
• - required is true
• - required is false

#### Examples of UI Elements

Example 1:

UI Element: Username
- id is "#user"
- minimum length is 2
Otherwise I must see [min_length_msg]
- maximum length is 30
- value is queried by "SELECT username FROM [MyDB].users"
Otherwise I must see [max_length_msg]

UI Element: Enter
- type is button

Example 2:

UI Element: Profession
- type is select
- value is queried by "SELECT name FROM [Professions]"

UI Element: Salary
- data type is double
- minimum value is queried by "SELECT min_salary FROM [Professions] WHERE name = {Profession}"

Example 3:

UI Element: Brazilian Zip Code
- format is "/^[0-9]{2}\.[0-9]{3}\-[0-9]{3}$/" ### Table Declares a data table that can be used by UI elements. Notes: • Global declaration. • Namespace is shared with Constants and Databases. • Allowed more than one declaration per file. • Tables are loaded as in-memory tables and can be queried with SQL. Example 1: Table: Users | username | password | | Bob | bobp4ss | | Joey | joeypwd |  ### Database Declares a reference to a database, with its connection parameters. Notes: • Global declaration. • Namespace is shared with Constants and Tables. • Allowed more than one declaration per file. • Property values must be declared between quotes ("). #### Properties Property Description Required type Database type. See supported values ahead. Yes host URL that indicates where the database is hosted. Vary port Network communication port used to connect to the database. Whether not defined, the default database port will be used, according to the property type. No name Database name. Used when there is a database server (whose location is defined by the property host) and the database is accessible by its name. Vary path Database path. Used when the database is accessed through the file system, such as the types csv, ini, json, sqlite and xlsx. Vary username Username used to connect to the database. When not defined, the database's default user will be used, according to the property type. No password Password used to connect to the database. When not defined, the database's default password will be used, according to the property type. No options Database-specific connection options. No Currently supported values for type: Value Database Installation command* Note "adodb" MS Access and MS SQL Server through ActiveX Data Objects npm install database-js-adodb MS Windows Only "csv" CSV files npm install database-js-csv "firebase" Firebase databases npm install database-js-firebase "ini" INI files npm install database-js-ini "json" JSON files npm install database-js-json Installed by default "mysql" MySQL databases npm install database-js-mysql "mssql" MS SQL Server npm install database-js-mssql "postgres" PostgreSQL databases npm install database-js-postgres "sqlite" SQLite databases npm install database-js-sqlite "xlsx" Excel spreadsheets npm install database-js-xlsx Notes (*) • To connect and handle databases during test executions, you have to install their corresponding NPM packages. • Go to your application's root folder and type the corresponding Installation command (see above). #### Examples Example 1: Database: My DB - type is "mysql" - host is "http://127.0.0.1" - name is "mydb" - username is "admin" - password is "p4sss"  Example 2: Database: Another DB - type is "json" - path is "C:\path\to\db.json"  ### Variant Allow to express the interaction between a user and the system in order to perform a Scenario. It serves as a template to generate Test Cases. Notes: • Local declaration. • Belongs to a Scenario. • Should be declared after a Scenario. Example: Variant: Successful login Given that I am on the [Login Page] When I fill {Username} And I fill {Password} And I click on {Enter} Then I have the state ~user logged in~ And I see the text [welcome text] And I see {Logout} See also: Examples of Actions ### Test Case Test case produced for a Variant Notes: • Local declaration. • Belongs to a Variant. • Can be declared in a different file, .testcase - strongly recommended • Must have tag @scenario( <index> ) that references its Scenario by the index, starting at 1. • Must have tag @variant( <index> ) that references its Variant by the index, starting at 1. • It does not allow references, such as UI Elements, Constants, and States Generated automatically from: A generated test case will: • Receive the same name of the Variant, plus a number; • Receive the tag @generated; • Receive the tag @scenario to refer to its Scenario; • Receive the tag @variant to refer to its Variant; • Replace a precondition, i.e., a Given step with a state, by a Variant able to produce this same state; • Replace a state call, i.e., a When step with a state, by a Variant able to produce this same state; • Replace a postconditions, i.e., Then steps with states, when the current test case generates an invalid value for a certain UI Element and the respective UI Element has defined Otherwise steps that describe the expected behavior in case of an invalid value. When there are no Otherwise steps defined, the Test Case receives a tag @fail to indicate that it should not behave the same way as its Variant; • Replace all the involved Constants by their corresponding values; • Replace all the involved references to UI Elements by their UI Literals, that is, their ids; • Keep any declared UI Literals; • Generate random values for UI Literals without value; • Keep any declared values or numbers; • Generate values for UI Elements according to their properties and the applicable test cases. Example: @generated @scenario( 1 ) @variant( 1 ) Test Case: Successful login - 1 Given that I am on the page "/login" When I fill <#username> with "Bob" And I fill <#password> with "bobp4ss" And I click on "Enter" Then I see "Welcome" And I see a button <#logout> ### Test Events Declares events before, after, or around test cases or features. Console commands or SQL scripts can be executed when these events occur. Notes: • Local declaration. • Just one declaration per Feature. They are: • Before Each Scenario: occurs before each scenario. • After Each Scenario: occurs after each scenario. • Before Feature: occurs before a feature. • After Feature: occurs after a feature. • Before All: occurs before all the features. • After All: occurs after all the features. These events support three type of commands: 1. SQL script: runs a SQL script into a declared database. See the actions connect, disconnect, and run. 2. Console command: runs a command in the console and waits for its termination. 3. File command: runs a command that checks or handles a file. (NOT SUPPORTED YET) Test Events for Features and Scenarios also support interactions with the user interface, like those commonly used in Variants. Both Console and SQL commands must declared values between apostrophes ('), as known as single quotes. Example 1: Before Feature: When I connect to the database [MyDB] Example 2: After Feature: When I run the command 'rmdir some-folder' and I run the script 'DELETE FROM [MyDB].users' and I disconnect from the database [MyDB] Example 3: Before Each Scenario: When I run the script 'DELETE FROM [MyDB].users' and I run the script 'INSERT INTO [MyDB].users ( login, password ) VALUES ( "Clark", "Kent" ), ( "Bruce", "Wayne" )' Example 4: After Each Scenario: When I create the file 'path/to/foo.json' with { "name": "John", "surname": "Doe" } and I see the file 'path/to/bar.xml' with <person><name>John</name><surname>John</surname></person> Some plug-ins may not support some Test Events: +--------------------------+--------------------------------+ | PLUGIN | After/Before | | | All | Feature | Each Scenario | +--------------------------+------+---------+---------------+ | CodeceptJS + WebDriverIO | no | yes | yes | | CodeceptJS + Appium | no | yes | yes | +--------------------------+------+---------+---------------+  ## Literals ### User Interface Literal Always between < and > A UI Literal is an identification (id) of a User Interface element. This identification will be used by the test script to locate the element in the application during the test. For instance, in a web application, an input declared using HTML as <input id="foo" > has #foo as its identification. In the following example, #foo is a UI Literal. When I fill <#foo> with "Bob" Formats accepted: • <#value> denotes an id • <@value> denotes a name • <value> denotes a css • <//value> denotes a xpath • <~value> denotes a mobile name Make sure to escape CSS locators properly. Example: Then I see <ul \> li \> div \> a> locate ul > li > div > a. ### Value Always between quotes ("). In the following example, Bob is a value: When I fill <name> with "Bob" ### Number No quotes. In the following example, 500 is a value: When I fill <quantity> with 500 In the following example, 12.50 is a value: When I fill <price> with 12.50 ### List of values Always between [ and ] Currently accepted only for UI Elements Example 1: UI Element: Sex - value comes from [ "Male", "Female", "Other" ] Example 2: UI Element: Age - value comes from [ 12, 16, 18, 21, 65 ] Example 3: UI Element: Price - value comes from [ 12.50, 20.00 ] Example 4: UI Element: Example - value comes from [ 12, 12.50, "Male" ] ### Query Always between quotes (") and starting with SELECT Currently accepted only for UI Elements Example: UI Element: Product - value comes from "SELECT name FROM ..." Note: To force a query to be a value, it must be used an exclamation mark (!) right before it. E.g., !"SELECT * FROM foo". Notes about queries: 1. May use grave accents to refer to names with spaces, as in ANSI-SQL. E.g., my table 2. Must use apostrophes to denote non-numeric values. Example: SELECT * FROM user WHERE username = 'bob' 3. May reference a Table, a Database, or a Constant using the format [some name], where the content does not contain a dollar sign, $. A dollar sign may be use to reference valid Excel table names, instead of referencing names declared in Concordia.

Example 1: references a declared table and a declared constant.

SELECT column1 FROM [My Table] WHERE name = [My Constant]

Example 2: references a declared database and a declared constant.

SELECT column1 FROM [My DB].table WHERE name = [My Constant]

Example 3: name that is not a reference (e.g., an Excel table)

SELECT column1 FROM [Some Excel Table\$] WHERE name = [My Constant]
4. May reference UI Elements using the format {feature name:ui element name}, in which feature name: is optional. The lack of the feature name should make the tool assuming that the UI element belongs to the feature. Example:

SELECT password FROM [Users] WHERE username = {Login:Username}
5. May reference a UI Element from the current Feature using the format {UI Element Name}. Example:

SELECT password FROM [Users] WHERE username = {Username}

## References to declarations

### User Interface Elements

Always between { and }

In the following example, {Name} is a reference to a UI Element called Name :

When I fill {Name} with "bob"

The name of the Feature is optional when a reference is declared for the same Feature, but mandatory otherwise.

Explicit references to a Feature must be separated from the UI Element name by a colon (:). For instance {Add an Employee:Profession} :

When I fill {Add an Employee:Profession} with "Dentist"

#### Inside queries

In the following example, {Profession} is a reference to a UI Element:

Feature: Add an Employee

...

UI Element: Profession
- value comes from "SELECT name FROM [Professions]"

UI Element: Salary
- minimum value comes from "SELECT min_salary FROM [Professions] WHERE name = {Profession}"

If desired, the reference could also be declared as {Add an Employee:Profession}.

### User Interface Element Properties

Added in version 1.2.0

• Syntax similar to references to User Interface Elements
• Must use | to denote a property
• A property can be one of the properties of a User Interface Element. See the currently supported properties in #44 and #45.

In the following example, {Password|value} is a reference to the property value of a UI Element called Password :

When I fill {Password Confirmation} with {Password|value}

Feature is optional when the referenced UI Element belongs to the Feature. It is mandatory otherwise. A Feature must be separated from a UI Element name by a colon (:).

In the following example, New User is the Feature name, Password is the UI Element name, and value is the property.

When I fill {Password Confirmation} with {New User:Password|value}

#### Properties inside values

Added in version 1.3.0

• Declared inside Variant sentences and Otherwise sentences.
• See supported properties at #44 and #45.

A UI Element property can be declared inside a value. For example:

Then I see "Welcome, {Username|value}."

### Constants

Always between [ and ]

In the following example, [PI] is a reference to a Constant:

...
When I fill <firstNumber> with [PI]
...

Constants:
- "PI" is 3.14159

Note: Constants, Tables, and Databases are global declarations and share the same namespace, so pay attention to name collisions.

### Tables

Always between [ and ]

References to tables are only allowed inside queries.

In the following example, [Professions] is a reference to a Table:

UI Element: Profession
- value comes from "SELECT name FROM [Professions]"

Table: Professions
| name       |
| Accountant |
| Dentist    |
| Mechanic   |

Note: Constants, Tables, and Databases are global declarations and share the same namespace, so pay attention to name collisions.

### Databases

Always between [ and ]

References to databases are only allowed inside queries.

In the following example, [Professions] is a reference to a Database:

UI Element: Profession
- value comes from "SELECT name FROM [Professions]"

Database: Professions
- type is "json"
- path is "/path/to/professions.json"

In this other example, [MyTestDB] is a reference to another Database:

UI Element: Profession
- value comes from "SELECT name FROM [MyTestDB].profession"

Database: MyTestDB
- type is "mysql"
- name is "mydb"
- username is "tester"
- password is "testing123"

Note: Constants, Tables, and Databases are global declarations and share the same namespace, so pay attention to name collisions.

## States

Always between tilde (~)

Example:

  Given that I have ~user logged in~


text:
# How to derive 2nd order Butterworth condition for the damping coefficient mathematically?

The magnitude of 2nd order low pass filter is given as $$|H(\omega)|^2= \frac{1}{(1-(\frac{\omega}{\omega_o})^2)^2+(\frac{2\zeta\omega}{\omega_o})^2}$$ Now in order to achieve maximally flat within pass band, we take the derivative of this equation and set it to zero to find the extremums. $$\begin{equation*} \frac{\partial(\frac{1}{|H(\omega)|^2})}{\partial\omega} = \frac{\partial[(1-\omega^2)^2+(2\zeta\omega)^2]}{\partial\omega} \end{equation*}$$

$$\begin{equation*} \begin{split} 2(1-\omega^2)(-2\omega)+8 \zeta^2\omega &= 0 \\ \omega(\omega^2-1)+2\zeta^2\omega &= 0 \\ \omega (\omega^2-1+2\zeta^2) &=0 \\ \end{split} \end{equation*}$$

Then we get $$\omega =0$$ or $$\omega^2 = 1-2\zeta^2$$

Now my question is, why do we set the second root to be zero to obtain no ripples in the passband so that we can derive: $$\zeta=1/\sqrt{2}$$ I understand that the slope of the magnitude is zero at these roots, but I couldn't really interpret the idea here. Any help is appreciated.

You have to check the next derivative, because the first one is zero anyway at $$\omega=0$$. The second derivative is
$$3\omega^2+2\zeta^2-1\Big|_{\omega=0}=2\zeta^2-1\tag{1}$$
which can be made zero by choosing $$\zeta=1/\sqrt{2}$$.


text:
# Albert Einstein's Theory Of Special Relativity

What was the actual equation given by Sir Albert Einstein for the theory of special relativity in his original 1905 paper?

×