text:
# Dump core on Linux [duplicate]

Write the shortest program which, when run with no arguments, stdin, or user input, triggers a core dump.

Your code must behave this way when run on some common out-of-the-box Linux distribution. Other than installing support for your target language, you may not reconfigure the system to make it more fragile than it is as provided.

25-byte C example: int main(){*((int*)0)=0;} on my Ubuntu outputs

Segmentation fault (core dumped)

• related – Arnauld Dec 2 '16 at 11:53
• I'm posting here since I'm not sure if this is right, but is perl -ue '' a valid solution? (question intended for people knowing perl) – Dada Dec 2 '16 at 12:40
• @Dada, when running that I get Aborted (core dumped) instead of Segmentation fault (core dumped). – redstarcoder Dec 2 '16 at 13:42
• @redstarcoder It doesn't have to be a segfault, so that would work. – mbomb007 Dec 2 '16 at 14:37
• We already have questions for the fastest way to create a SIGSEGV and the fastest way to create a SIGILL. Dumping core on Linux without a signal is likely to be very verbose compared to crashing in a way that creates a core file, so this question is basically "shortest way to cause a SIGQUIT, SIGILL, SIGABRT, SIGFPE, SIGSEGV, SIGBUS, SIGSYS, SIGTRAP, SIGXCPU, or SIGXFSZ". I think we'd be better off with those as separate questions, rather than having a combined question for any (especially as some of the existing SIGSEGV/SIGILL are very short). – user62131 Dec 2 '16 at 16:19

# C, 5 bytes

main;

Try it online!

## Slightly longer, 7 bytes

main=0;

• Why did I get downvoted? This is my first post ever. – Henrik Hasell Dec 2 '16 at 15:57
• I can't guarantee this is what happened, but it's possible that your post was flagged as low-quality because it was short, and then the system itself casted a downvote because you edited. We really dislike this behavior, but it's something the system does that we can't change. – James Dec 2 '16 at 16:13
• Welcome to Programming Puzzles & Code Golf! The downvote was cast automatically by the Community user when you edited your answer. I consider this a bug. – Dennis Dec 2 '16 at 16:15
• The "maximum golfed" answer counts as 9 bytes; it's 2 in the file itself, but has 7 bytes of penalties (Dm=main) because it requires an unusual compiler configuration (you'd write it as "2+7 = 9 bytes"). In general, trying to hide code in the compiler configuration or the program's filename is a cheap tactic, and the penalties are intended to prevent it improving your score except in cases where it's interesting. – user62131 Dec 2 '16 at 16:22
• Well said! I will remove it. – Henrik Hasell Dec 5 '16 at 11:04

# Jelly, 2 bytes

×ß

TryItOnline!

A dyadic atom (here ×, but there are swathes of others) followed by the quick ß which instructs to call the same link (the whole line of code) with the same arity - calling it once more with any arity would also work, so, since it is the only line of code, ß could be replaced by any of ¢ÇçÑñ (last link as a nilad, last link as a monad, last link as a dyad, next link as a monad, or next link as a dyad).

## NASM, 3 bytes

ret

I guess it tries to jump to whatever is on the default stack and immediately segfaults :).

Built with: nasm -f elf64 golf.asm && ld golf.o -o golf

## BASH, 10 bytes

kill -6

kill -6 precisely does this

# C, 14 bytes

main(c){c/=0;}

It's that simple 8-)


text:
Question

Areas of two similar triangles are 49 cm2 and 100 cm2. If the length of a side of the smaller triangle is 14 cm, the length of the corresponding side of the other triangle is:

A
17 cm
B
19 cm
C
18 cm
D
20 cm

Solution

The correct option is D 20 cmLet x be the side length of a side of the bigger triangle corresponding to the side which is of length 14 cm in the smaller triangle. Areas of similar triangles are proportional to the square on their corresponding sides. Thus, 49100=142x2 ⇒x=±20 Since length can’t be negative, the required side length is 20 cm.

Suggest corrections

format: plain


text:
# C++ Program to Calculate Standard Deviation

C++ProgrammingServer Side Programming

Standard deviation is the measure of how spread out the numbers in the data are. It is the square root of variance, where variance is the average of squared differences from the mean.

A program to calculate the standard deviation is given as follows.

## Example

Live Demo

#include <iostream>
#include <cmath>
using namespace std;
int main() {
float val[5] = {12.5, 7.0, 10.0, 7.8, 15.5};
float sum = 0.0, mean, variance = 0.0, stdDeviation;
int i;
for(i = 0; i < 5; ++i)
sum += val[i];
mean = sum/5;
for(i = 0; i < 5; ++i)
variance += pow(val[i] - mean, 2);
variance=variance/5;
stdDeviation = sqrt(variance);
cout<<"The data values are: ";
for(i = 0; i < 5; ++i)
cout<< val[i] <<" ";
cout<<endl;
cout<<"The standard deviation of these data values is "<<stdDeviation;
}

## Output

The data values are: 12.5 7 10 7.8 15.5
The standard deviation of these data values is 3.1232

In the above program, first the sum of the data values is obtained. Then the mean is found by dividing the sum by the number of elements. This is given in the following code snippet.

for(i = 0; i < 5; ++i)
sum += val[i];
mean = sum/5;

The variance of the data is found by squaring the differences from the mean, adding them and then finding their average. This is shown in the following code snippet.

for(i = 0; i < 5; ++i)
variance += pow(val[i] - mean, 2);
variance=variance/5;

The standard deviation is found by obtaining the square root of the variance. Then all the data values and the standard deviation is displayed. This is given as follows.

stdDeviation = sqrt(variance);
cout<<"The data values are: ";
for(i = 0; i < 5; ++i)
cout<< val[i] <<" ";
cout<<endl;
cout<<"The standard deviation of these data values is "<<stdDeviation;
Published on 05-Oct-2018 11:44:30


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

 It is currently 16 Oct 2019, 12:41

GMAT Club Daily Prep

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

Customized
for You

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

Track

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

Practice
Pays

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

The figure above represents a right circular cylindrical tube made out

Author Message
TAGS:

Hide Tags

Math Expert
Joined: 02 Sep 2009
Posts: 58381
The figure above represents a right circular cylindrical tube made out  [#permalink]

Show Tags

08 Dec 2017, 03:46
2
4
00:00

Difficulty:

85% (hard)

Question Stats:

33% (01:54) correct 67% (02:03) wrong based on 69 sessions

HideShow timer Statistics

The figure above represents a right circular cylindrical tube made out of paper. The circumference of each circular base is 10 centimeters, the length of AB is 12 centimeters, and BD is a diameter of a base. If the tube is cut along AB, opened and flattened, what is the length of AD in centimeters?

(A) 13
(B) 17
(C) 22
(D) 2√61
(E) √146.5

Attachment:

2017-12-08_1440_002.png [ 6.2 KiB | Viewed 1294 times ]

_________________
Current Student
Joined: 18 Aug 2016
Posts: 609
Concentration: Strategy, Technology
GMAT 1: 630 Q47 V29
GMAT 2: 740 Q51 V38
Re: The figure above represents a right circular cylindrical tube made out  [#permalink]

Show Tags

08 Dec 2017, 04:01
Bunuel wrote:

The figure above represents a right circular cylindrical tube made out of paper. The circumference of each circular base is 10 centimeters, the length of AB is 12 centimeters, and BD is a diameter of a base. If the tube is cut along AB, opened and flattened, what is the length of AD in centimeters?

(A) 13
(B) 17
(C) 22
(D) 2√61
(E) √146.5

Attachment:
2017-12-08_1440_002.png

2*pie * r = 10
r = 5/pie
ABD will be right angle Triangle
AD is Hypotenuse and hence can be calculated
AD = $$\sqrt{(12^2 + (5/pie)^2)}$$
AD = $$\sqrt{(144 + 25/~9.5)} = \sqrt{146.5}$$
E
_________________
We must try to achieve the best within us

Thanks
Luckisnoexcuse
Director
Joined: 24 Nov 2016
Posts: 589
Location: United States
Re: The figure above represents a right circular cylindrical tube made out  [#permalink]

Show Tags

Updated on: 09 Dec 2017, 09:06
1
Bunuel wrote:

The figure above represents a right circular cylindrical tube made out of paper. The circumference of each circular base is 10 centimeters, the length of AB is 12 centimeters, and BD is a diameter of a base. If the tube is cut along AB, opened and flattened, what is the length of AD in centimeters?

(A) 13
(B) 17
(C) 22
(D) 2√61
(E) √146.5

Attachment:
2017-12-08_1440_002.png

If the tube is opened and flattened, then we have a rectangle with length 12 = AB, and width 10 = the circumference.

Now, lines BD and AC are equal to half the width = 10/2 = 5.

So to find the distance AD, we need to find the diagonal of the rectangle with length 12 = AB and width 5 = BD

$$a^2+b^2=c^2, 12^2+5^2=c^2, 169=c^2, c=13$$

Originally posted by exc4libur on 08 Dec 2017, 06:44.
Last edited by exc4libur on 09 Dec 2017, 09:06, edited 1 time in total.
Veritas Prep GMAT Instructor
Joined: 16 Oct 2010
Posts: 9705
Location: Pune, India
Re: The figure above represents a right circular cylindrical tube made out  [#permalink]

Show Tags

08 Dec 2017, 07:15
3
1
Bunuel wrote:

The figure above represents a right circular cylindrical tube made out of paper. The circumference of each circular base is 10 centimeters, the length of AB is 12 centimeters, and BD is a diameter of a base. If the tube is cut along AB, opened and flattened, what is the length of AD in centimeters?

(A) 13
(B) 17
(C) 22
(D) 2√61
(E) √146.5

Attachment:
2017-12-08_1440_002.png

When you cut along AB and open it, you get a rectangle. Notice that in this rectangle, A is on the corner and D is in the centre of the opposite edge. So ABD will form a right triangle.

AB is simply the length of the tube at 12 cm but notice what BD is. It is half the circumference of the circular base (since it is opened and flattened) which is 10 cm. So BD = 10/2 = 5 cm

This will be a 5-12-13 triangle then and AD will be 13 cm.

_________________
Karishma
Veritas Prep GMAT Instructor

Veritas Prep GMAT Instructor
Joined: 16 Oct 2010
Posts: 9705
Location: Pune, India
Re: The figure above represents a right circular cylindrical tube made out  [#permalink]

Show Tags

08 Dec 2017, 21:15
2
VeritasPrepKarishma wrote:
Bunuel wrote:

The figure above represents a right circular cylindrical tube made out of paper. The circumference of each circular base is 10 centimeters, the length of AB is 12 centimeters, and BD is a diameter of a base. If the tube is cut along AB, opened and flattened, what is the length of AD in centimeters?

(A) 13
(B) 17
(C) 22
(D) 2√61
(E) √146.5

Attachment:
The attachment 2017-12-08_1440_002.png is no longer available

When you cut along AB and open it, you get a rectangle. Notice that in this rectangle, A is on the corner and D is in the centre of the opposite edge. So ABD will form a right triangle.

AB is simply the length of the tube at 12 cm but notice what BD is. It is half the circumference of the circular base (since it is opened and flattened) which is 10 cm. So BD = 10/2 = 5 cm

This will be a 5-12-13 triangle then and AD will be 13 cm.

Responding to a pm:

Quote:
Can you help me understand how BD is half the circumference of the circular base. I am unable to visualize and hence not getting the point.

Here is the original roll.

Attachment:

Rectangular Roll Original.jpg [ 11.96 KiB | Viewed 1003 times ]

When you open it, this is what it looks like.

Attachment:

Rectangular Roll.jpg [ 14.09 KiB | Viewed 1004 times ]

_________________
Karishma
Veritas Prep GMAT Instructor

Intern
Joined: 19 Aug 2017
Posts: 15
Re: The figure above represents a right circular cylindrical tube made out  [#permalink]

Show Tags

22 Dec 2017, 06:48
1
Got the answer to be A

Can anyone explain how it is D??
Math Expert
Joined: 02 Sep 2009
Posts: 58381
Re: The figure above represents a right circular cylindrical tube made out  [#permalink]

Show Tags

22 Dec 2017, 06:57
1
MSarmah wrote:
Got the answer to be A

Can anyone explain how it is D??

The correct answer is A. Edited. Thank you.
_________________
Intern
Joined: 19 Aug 2017
Posts: 15
Re: The figure above represents a right circular cylindrical tube made out  [#permalink]

Show Tags

22 Dec 2017, 07:06
Bunuel wrote:
MSarmah wrote:
Got the answer to be A

Can anyone explain how it is D??

The correct answer is A. Edited. Thank you.

Welcome Brunnel
Non-Human User
Joined: 09 Sep 2013
Posts: 13210
Re: The figure above represents a right circular cylindrical tube made out  [#permalink]

Show Tags

20 Jun 2019, 06:26
Hello from the GMAT Club BumpBot!

Thanks to another GMAT Club member, I have just discovered this valuable topic, yet it had no discussion for over a year. I am now bumping it up - doing my job. I think you may find it valuable (esp those replies with Kudos).

Want to see all other topics I dig out? Follow me (click follow button on profile). You will receive a summary of all topics I bump in your profile area as well as via email.
_________________
Re: The figure above represents a right circular cylindrical tube made out   [#permalink] 20 Jun 2019, 06:26
Display posts from previous: Sort by


text:
## Chemistry: The Molecular Science (5th Edition)

We know that 1 kPa is equal to .145 psi. Thus, we find: $=303 \times .145 \approx 44$ psi


text:
# If the equation of the base of an equilateral triangle is x + y = 2 and the vertex is (2, – 1), then find the length of the side of the triangle  [Hint: Find length of perpendicular (p) from (2, – 1) to the line and use $p = l \: \sin 60^{\circ}$, where $l$ is the length of side of the triangle]

$\begin {array} {1 1} (A)\;\large\frac{2}{\sqrt 3} & \quad (B)\;\large\frac{2}{ 3} \\ (C)\;\large\frac{\sqrt 2}{ 3} & \quad (D)\;\sqrt{\large\frac{2}{3}} \end {array}$

Toolbox:
• Length of the perpendicular from $(x_1, y_1)$ to the line $ax+by+c=0$ is $p = \bigg| \large\frac{ax_1+by_1+c}{\sqrt{a^2+b^2}} \bigg|$
Step 1 :
Let $a$ be the length of each side of the equilateral triangle.
The length of the perpendicular p from (2,-1) on $x+y-2=0$
$\Rightarrow p = \bigg| \large\frac{2-1-2}{\sqrt{1^2+1^2}}\bigg|$
$= \large\frac{1}{\sqrt 2}$
Step 2 :
Consider the $\Delta$ ABD
$\sin 60^{\circ} = \large\frac{p}{a}$
$\Rightarrow \large\frac{\sqrt 3}{2} $$= \large\frac{\Large\frac{1}{\sqrt 2}}{a} \Rightarrow a = \large\frac{2}{\sqrt 3}$$ \times \large\frac{1}{\sqrt 2}$
$a = \large\frac{\sqrt 2}{3}$
hence the length of the side of the equilateral triangle is $\large\frac{\sqrt 2}{3}$
edited Jul 1, 2014
Option D is the correct answer root 2 by root 3. Thanks


text:
This package implements ring buffers. A ring buffer can be used as a first-in-first-out (FIFO) buffer where the maximum size is known ahead of time. Because they do not grow in size, they are useful to avoid using more and more memory as a process runs. Because the data reading and writing happens in an (apparently) circular way, once data is added to the buffer it is not copied (in contrast if you used a vector then every time data is consumed you’d have to shuffle the vector around).

ring implements two different ring buffers that will likely suit different applications.

• ring_buffer_bytes is imlemented as a byte array in C, possibly with a “stride” indicating a set of bytes that go together. Once the data reaches the end of the array we start writing to the beginning again.
• ring_buffer_env is implemented as a doubly linked list using R’s environments. This buffer can hold arbitrary R objects at each position.

The target audience for this package is either other package developers who need a ring buffer in their package, or modellers who have decided that a ring buffer is the right data structure to help with their simulation model.

For all buffers, head will refer to the next bit of the buffer to be written to, and tail will refer to the next bit of the buffer to be read. That is, elements are pushed onto the head of the buffer and retrieved from the tail. (There is no direct analogy between these termas and the R functions head and tail which operate on fixed-size vectors.)

# The environment buffer ring_buffer_env

This is the simplest buffer to understand because we don’t have to deal with raw vectors.

To create a buffer that can hold up to 100 elements, use the ring_buffer_env function:

buf <- ring::ring_buffer_env(100)

This is an R6 class, with several methods:

buf
## <Ring Buffer (ring_buffer_env)>
##   Public:
##     copy: function (dest, n)
##     duplicate: function ()
##     free: function ()
##     grow: function (n)
##     is_empty: function ()
##     is_full: function ()
##     mirror: function (dest)
##     push: function (data, iterate = TRUE)
##     reset: function (clear = FALSE)
##     set: function (data, n)
##     size: function ()
##     tail: function ()
##     tail_offset: function (n)
##     tail_pos: function ()
##     take: function (n)
##     used: function ()

Operations on the class happen by running methods using $. So the size of the buffer: buf$size()
## [1] 100

…the number of elements free and used:

buf$free() ## [1] 100 buf$used()
## [1] 0

…whether the buffer is empty or full:

buf$is_empty() ## [1] TRUE buf$is_full()
## [1] FALSE

To start using the buffer we need to put some data in it. There are two main functions for adding data:

• buf$set(data, n) sets n elements to be the value data • buf$push(data, iterate) pushes data into the buffer, with the iterate argument indicating if we should iterate over data or treat it as a single element

So to set the first 5 elements to be “a”, “b”, …, “e”, use:

buf$push(letters[1:5]) The buffer is no longer empty buf$is_empty()
## [1] FALSE

…having 5 elements:

buf$used() ## [1] 5 …and room for 95 more: buf$free()
## [1] 95

To read the content of the buffer without modifying it, use read(n) where n is the number of elements to read. This always returns a list of length n:

buf$read(1) ## [[1]] ## [1] "a" buf$read(2)
## [[1]]
## [1] "a"
##
## [[2]]
## [1] "b"

If you try to read too far, then the buffer will underflow and you will get an error:

buf$read(20) ## Error: Buffer underflow (requested 20 elements but 5 available) If you just want the the first element, use tail() buf$tail()
## [1] "a"

The tail returns the first element in (so the buffer naturally operates as a first-in-first-out queue).

You can also read the most recently added element with head()

buf$head() ## [1] "e" And you can offset these by an integer number of steps. So moving one position into the buffer from the tail gets the second element added: buf$tail_offset(1)
## [1] "b"

or moving three elements into the buffer from the head (most recently added elemnt) gets the same bit of data

buf$head_offset(3) ## [1] "b" The above operations are all nondestructive – they leave the buffer unchanged. To consume elements, use take(n) which operates the same way as read but it also moves the buffer tail; it consumes elements leaving space for more. buf$free()
## [1] 95
buf$take(1) ## [[1]] ## [1] "a" buf$free()
## [1] 96

Now we have consumed an element the tail has moved along, so tail contains “b” and “a” is removed from the buffer:

buf$tail() ## [1] "b" To reset the buffer, use reset(). This empties the buffer of all data: buf$reset()
buf$used() ## [1] 0 buf$is_empty()
## [1] TRUE

While the ring buffer is fixed in size in typical use, you can grow it explicitly. To add additional space, use the grow method:

buf$size() ## [1] 100 buf$grow(20)
buf$size() ## [1] 120 ## Application: simulation with recent history The whole point of the ring buffer though is that we can push things onto it and pull the most recent out, even when the number of things pushed overall is larger than the buffer size. So imagine a simulation where we need to keep track of the last 5 steps. The simulation is a random walk. step <- function(x) { if (runif(1) < 0.5) x - 1L else x + 1L } x <- 0L buf <- ring::ring_buffer_env(5) h <- integer(20) buf$push(x)
h[1L] <- x

set.seed(1)
for (i in seq_len(length(h) - 1L)) {
x <- step(x)
buf$push(x) h[i + 1L] <- x } The whole history: h ## [1] 0 -1 -2 -1 0 -1 0 1 2 3 2 1 0 1 0 1 0 1 2 1 The last 5 steps: unlist(buf$read(5))
## [1] 1 0 1 2 1

So we could rewrite the simulation so that the random walk tends up if the last few steps have been increases and tends down if the last few steps have been decreases:

step <- function(x) {
if (length(x) > 1) {
p <- mean(diff(x)) / 2 + 0.5
} else {
p <- 0.5
}
if (runif(1) < p) x[length(x)] - 1L else x[length(x)] + 1L
}

x <- 0L
buf <- ring::ring_buffer_env(5)
h <- integer(100)
buf$push(x) h[1L] <- x set.seed(1) for (i in seq_len(length(h) - 1L)) { x <- step(unlist(buf$read(buf$used()))) buf$push(x)
h[i + 1L] <- x
}

Now we have a simulation with a strong mean reverting tendency:

par(mar = c(4, 4, .5, .5))
plot(h, type = "l", xlab = "step", ylab = "y", las = 1)

Because the buffer always holds the last 5 (or fewer) elements the book-keeping involved in working with the last few elements out is simlified. Ignoring the fact that we hold the entire history in the fixed size vector h, only the last few elements need to be retained which may be useful if the simulation generates a lot of data.

A downside of this implementation is that buf$read() returns a list that must be turned into a vector with unlist, even though we know in this case that the simulation will always produce an integer vector. The ring buffers described below can help with that problem. # The bytes buffer ring_buffer_bytes This is the classical implementation of a ring buffer, and the implementation is broadly based on the one here, by @dhess. This operates basically the same way as ring_buffer_env, and presents a very similar interface to R, but with a few key differences: • The contents of the buffer are raw bytes (using R’s raw vectors). These are a bit fiddly to work with but can be very powerful. • The iterate distinction of push disappears because there is no ambiguity with R objects To construct a buffer of 1000 bytes: buf <- ring::ring_buffer_bytes(1000) Most of the same methods apply directly: buf$free()
## [1] 1000
buf$used() ## [1] 0 buf$is_full()
## [1] FALSE
buf$is_empty() ## [1] TRUE Generate a byte sequence: bytes <- as.raw(0:255) …and push them into the buffer: buf$push(bytes)

buf$read(10) ## [1] 00 01 02 03 04 05 06 07 08 09 …destructively take the oldest elements buf$used()
## [1] 256
buf$take(20) ## [1] 00 01 02 03 04 05 06 07 08 09 0a 0b 0c 0d 0e 0f 10 11 12 13 buf$used()
## [1] 236

## Striding

Single bytes can hold only values 0 to 255 (or character equivalents, such as a becomes 61 via charToRaw("a"). But if you want to hold a full integer, that (usually) takes 4 bytes, a double (usually) takes 8.

To allow this, a bytes buffer can be “strided”; this indicates the number of consecutive bytes that should together make up one logical entry. The buffer then contains size of these. So to create a buffer of 100 entries, each of 8 bytes you could do:

buf <- ring::ring_buffer_bytes(100, 8)

Each element pushed onto the buffer must have the correct size. So to push the byte sequence 1..8 onto the buffer:

buf$push(as.raw(1:8)) but if you pushed more or less it would be an error: buf$push(as.raw(1:4))
## Error in buf$push(as.raw(1:4)): Incorrect size data (4 bytes); expected multiple of 8 bytes Reading happens in logical units, not bytes: buf$read(1)
## [1] 01 02 03 04 05 06 07 08

and you can get the number of elements used:

buf$used() ## [1] 1 or the number of bytes buf$used(bytes = TRUE)
## [1] 8

## The typed bytes buffer ring_buffer_bytes_typed

If 8 bytes is a double, it should be possible to make a bytes buffer that holds one (or more) doubles per entry. That is what the ring_buffer_bytes_typed buffer does, with a few corner cases dealt with. To use, you decide what the R interpretation of an entry is, it will determine the size per entry and appropriate encoding and decoding functions and you can ignore that it is storing bytes. For performance reasons this does not use R’s serialisation and simply copies the data stored in vectors.

For example, to make a buffer of 10 elements, each of which is a single real number (double), use:

buf <- ring::ring_buffer_bytes_typed(10, double(1))

onto which real numbers can be pushed:

buf$push(pi) And retrieve the data. buf$take(1)
## [1] 3.141593

Entries can contain more than one number; to make a buffer of length 10, each element of which is a vector of 5 doubles:

buf <- ring::ring_buffer_bytes_typed(10, double(5))
buf$push(rnorm(5)) buf$read(1)
## [1]  0.26613736 -0.37670272  2.44136463 -0.79533912 -0.05487747

Because this is just implemented as a byte array, we can just push a bunch of numbers straight into the buffer:

buf$push(rnorm(5 * 10)) With elements in the buffer, we can request them. The integer argument of take indicates the number of groups of 5 doubles we would like back: buf$take(1)
## [1]  0.2501413  0.6182433 -0.1726235 -2.2239003 -1.2636144

If you try to take more than is in the buffer it is an error:

buf$take(10) ## Error in super$take(n): Buffer underflow (requested 10 elements but 9 available)

## The translating bytes buffer ring_buffer_bytes_translate

The ring_buffer_bytes_typed function is implemented by translating R objects to bytes (when storing with $set(), $push(), etc). and from bytes back to R objects (when retrieving with $read(), $take(), etc). ring_buffer_bytes_translate exposes this interface.

The “typed” buffers do not allow storing strings because they can be any number of bytes long (the bytes buffers require a fixed “stride” within a buffer). But we can store fixed length strings.

To convert a string to a byte sequence, use charToRaw (or as.raw(utf8ToInt(x)), but then multi-byte sequences might start being difficult).

(bytes <- charToRaw("hello world"))
##  [1] 68 65 6c 6c 6f 20 77 6f 72 6c 64

The inverse transformation is rawToChar (or intToUtf8(as.integer(x))):

rawToChar(bytes)
## [1] "hello world"

The function ring_buffer_bytes_translate takes these functions as its 3rd and fourth arguments. So to make a buffer that will hold up to 100 strings, each of 8 bytes:

b <- ring::ring_buffer_bytes_translate(100, 8, charToRaw, rawToChar)

We can now store 8 character strings:

b$push("abcdefgh") b$tail()
## [1] "abcdefgh"

But other length strings cannot be added:

b$push("hello!") ## Error in super$push(self\$.to(data)): Incorrect size data (6 bytes); expected multiple of 8 bytes

Probably this would be most useful storing just single characters as then it would make a buffer of text.

# The C API

The ring package can be used in other R packages using the LinkingTo mechanism. To do so:

• In your DESCRIPTION, add a line LinkingTo: ring (you do not need to include ring in Depends or Imports as we need it only for the package build).

• In your src/ directory, add a file ring.c containing just the line #include <ring/ring.c> (but see the note in the documentation for ring_buffer_create below).

• Anywhere in your code you want to use the ring buffer, include the line #include <dde/dde.h> to include the prototypes and use the interface as described below.

(I am not sure what the best practice way of doing this with a standalone shared library compiled with R CMD SHLIB is though; probably best to make a package.)

The C API is documented only in the header file, and it should be fairly straightforward to use (with reference to the docs above; this is the code underlying the ring_buffer_bytes interface).

#ifndef _RING_H_
#define _RING_H_
#include <stddef.h>
#include <stdbool.h>

#ifndef RING_USE_STDLIB_ALLOC
#ifndef USING_R
#define USING_R
#endif
#endif

// Allow use from C++
#ifdef __cplusplus
extern "C" {
#endif

// What to do on overflow.
//
// The OVERFLOW_ERROR action (which calls R's error function) is only
// available when using R, which is detected by the <R.h> header
// included.  If you are using RING_USE_STDLIB_ALLOC (see below) but
// want to use OVERFLOW_ERROR then you'll need to include <R.h> as
// well, and be willing to deal with an R error and the longjmp that
// it causes.
typedef enum overflow_action {
OVERFLOW_OVERWRITE,
OVERFLOW_GROW
#ifdef USING_R
, OVERFLOW_ERROR
#endif
} overflow_action;

// The underlying data structure.  None of the fields here should be
// directly accessed in normal use; use the accessor functions
//
// The ring buffer is a FIFO (first-in-first-out) queue.  It is
// implemented as a single block of memory (data) and a pair of
// pointers:
//
//   head: the starting location where data should be written when
//         copying data *into* the buffer.
//
//   tail: the starting location where data should be read when
//         copying data *from* the buffer.
//
// The buffer has a concept of a stride; the number of bytes per
// buffer entry.  This is fixed across the entire ring.  As such, some
// functions that return size_t have a booleanargument "bytes" that
// switches between measuring in bytes and measuring in logical
// elements.  In the case where stride=1, these are identical.
//
// In general, the ring buffer is totally happy to overflow; if you
// write too much into the ring buffer it will destructively erase
// data (i.e., your tail will move).  The ring buffer will never
// underflow, but functions may return NULL on underflow - read the
// documentation below carefully.
typedef unsigned char data_t;
typedef struct ring_buffer {
size_t size;
size_t stride;
size_t bytes_data;
overflow_action on_overflow;

data_t *data;
data_t *tail;
} ring_buffer;

//// Creation, deletion, etc: ////

// Create a ring buffer.  After creating, be sure to free the memory
// with ring_buffer_destroy.
//
//   size: (maximum) number of elements that the ring buffer may contain
//
//   stride: number of *bytes* per ring buffer element
//
// See the note above the struct for details on size/stride.
//
// If the buffer cannot be allocated (e.g., too big a buffer is
// requested) then an R error will be thrown as this uses Calloc.
//
// This may not always be desirable (e.g., if using from within C++,
// or in a project that does not actually use R).  To use plain C
// stdlib calloc/free, in the ring.c use:
//
//     #define RING_USE_STDLIB_ALLOC 1
//     #include <ring/ring.c>
//
// which will not depend on *any* R code and use stdlib calloc/free
// (except for the issue with USING_R/OVERFLOW_ERROR above).  With
// RING_USE_STDLIB_ALLOC defined, if an allocation fails, then
// ring_buffer_create (and ring_buffer_duplicate below) will return
// NULL.  So if using this approach be sure to check the return value!
//
// The main wrinkle to using RING_USE_STDLIB_ALLOC 1 is that the
// overflow_action OVERFLOW_ERROR will not work.  At present this
// will fail to compile, but in future I may add an error handler.
ring_buffer * ring_buffer_create(size_t size, size_t stride,
overflow_action on_overflow);

// Destroy a ring buffer.  Frees the memory
//
//   buffer: the ring buffer to copy; after calling this function all
//           memory associated with the buffer is freed.
void ring_buffer_destroy(ring_buffer *buffer);

// Duplicate (copy) a ring buffer.  Copies both the underlying data and
// the position of the head and tail.  A new buffer will be allocated
// and must be freed when finished with, using ring_buffer_destroy
//
//   buffer: a ring buffer to copy from; will not be modified
ring_buffer * ring_buffer_duplicate(const ring_buffer *buffer);

// Increase the size of the ring buffer so that it can hold additional
// elements.  This does not alter existing elements but increases the
// capacity (similar to he reserve method in the C++ standard
// library).
//
//   buffer: a ring buffer to increase the size of
//
//   n: the number of elements to increase the buffer by
//
//   exact: boolean, indicating if the buffer should be increased by
//          exactly n elements (if true) or by at least n elements
//          (if false).  If using the inexact method, the buffer is
//          increased in size using geometric growth using the golden
//          ratio.
//
// After using this function, all references to the head or tail are
// broken and the memory may have been freed and the contents moved
// elsewhere.
//
// If RING_USE_STDLIB_ALLOC is defined, and if an allocation fails,
// then this may leave things in an undesirable state (this is
// particularly a problem when using on_overflow = OVERFLOW_GROW).
// Currently, if R is used an R error will be thrown (possibly not a
// good idea if running under Rcpp) and if running as a standalone
// application then the data will be set to NULL, probably causing a
// crash pretty quickly (improvements welcome).
void ring_buffer_grow(ring_buffer *buffer, size_t n, bool exact);

// Reset the state of the buffer.  This "zeros" the head and tail
// pointer (and may or may not actually reset the data) so that the
// buffer can be used as if fresh.
//
//   buffer: a ring buffer to reset
//
//   clear: boolean, indicating if memory should also be zeroed
void ring_buffer_reset(ring_buffer *buffer, bool clear);

//// Basic querying: ////

// Return the maximum size of the ring buffer
//
//   buffer: the ring buffer to test (will not be modified)
//
//   bytes: indicates if size should be in bytes (if true) or elements
//          (if false)
size_t ring_buffer_size(const ring_buffer *buffer, bool bytes);

// Report the free and used space in the ring buffer
//
//   buffer: the ring buffer to test (will not be modified)
//
//   bytes: indicates if used/free space should be in bytes (if true)
//          or elements (if false)
size_t ring_buffer_free(const ring_buffer *buffer, bool bytes);
size_t ring_buffer_used(const ring_buffer *buffer, bool bytes);

// Report the number of bytes of data that have been allocated.  Note
// that this is likely stride more bytes than was requested as this
// avoids a lot of awkward bookkeeping later, allowing the "full"
// state to be distinguished from the "empty" state.
size_t ring_buffer_bytes_data(const ring_buffer *buffer);

// Report if the ring buffer is full or empty
bool ring_buffer_is_full(const ring_buffer *buffer);
bool ring_buffer_is_empty(const ring_buffer *buffer);

// Return the position of the head and tail pointers relative to the
// data pointer (this is an offset, so 0 means the pointer is at the
// start of the data array).
//
//   bytes: indicates if offset should be bytes (if true) or elements (if false)
size_t ring_buffer_head_pos(const ring_buffer *buffer, bool bytes);
size_t ring_buffer_tail_pos(const ring_buffer *buffer, bool bytes);

// Return pointers to the the data, head and tail members of the ring
// buffer.  These are preferred over directly accessing the "data",
// "head" and "tail" elements of the ring buffer structure itself
// because with these the compiler will enforce read-only access for
// you.
//
// WARNING: the head buffer is *not* the most recently added element,
// but instead the bit of memory that will be written to next; it's
// generally not terribly useful and a better way of getting the last
// written element is to use:
//
//
// which will look after wrapping the ring buffer appropriately.
const void * ring_buffer_data(const ring_buffer *buffer);
const void * ring_buffer_head(const ring_buffer *buffer);
const void * ring_buffer_tail(const ring_buffer *buffer);

//// Setting repeated values: ////

// Set all bytes of a length of the buffer to 'c'.  Here, 'len' is the
// number of *entries*, so stride * len bytes will be set.  This will
// mostly be uesful with c=0.
//
//   buffer: the ring buffer to set data into
//
//   c: value (0-255) to set all bytes to
//
//   n: number of elements to set
//
// This starts adding data at head.  If the buffer will overflow, at
// most bytes_data bytes will be written (i.e., each element will be
// written to once).
//
// Returns the number of bytes actually written to the buffer (so if
// the buffer overflows this may be less than len).
size_t ring_buffer_set(ring_buffer *buffer, data_t c, size_t n);

// Set a number of the elements of the buffer to a particular byte
// pattern.  In contrast with ring_buffer_set, this does not set
// individual bytes, but instead complete elements.
//
//    buffer: the ring buffer to set data into
//
//    x: pointer to a set of data to copy into the ring buffer.  This
//            must be (at least) stride bytes long.
//
//    n: number of elements to set
//
// This starts adding data at head.  If the buffer will overflow, at
// most bytes_data bytes will be written (i.e., each element will be
// written to once).
size_t ring_buffer_set_stride(ring_buffer *buffer, const void *x, size_t n);

// Copy n entries, each of stride bytes from a contiguous memory
// area src into the ring buffer. Returns the ring buffer's new head
// pointer.
//
// It is possible to overflow the buffer with this function
//
//   buffer: the ring buffer to copy data into
//
//   src: the source memory to copy from (make sure this is big enough
//           or you will get crashes and other terrible things).
//
//   n: the number of entries to copy from src into buffer (each
//           of which is stride bytes long).
const void * ring_buffer_push(ring_buffer *buffer, const void *src, size_t n);

// Destructively copy n entries (each of which is stride bytes)
// from a ring buffer buffer into contiguous memory region dest.
// This updates the tail pointers in the ring buffer and returns the
// new tail pointer.
//
// The n entries will no longer be available in the ring buffer.
// To do a nondestructive read, use ring_buffer_read().
//
//   buffer: the ring buffer to copy data from
//
//   dest: the destination memory to copy into (make sure this is big enough
//           or you will get crashes and other terrible things).
//
//   n: the number of entries to copy from src into buffer (each
//           of which is stride bytes long).
//
// This function will not allow the ring buffer to underflow.  If
// n is greater than the number of available entries, then
// nothing is copied (and the ring buffer remains unmodified) and NULL
// is returned.
const void * ring_buffer_take(ring_buffer *buffer, void *dest, size_t n);

// Nondestructively read from a ring buffer.  This function is
// essentially identical to ring_buffer_take but does not alter the
// tail pointer.
const void * ring_buffer_read(const ring_buffer *buffer, void *dest, size_t n);

// ring_buffer_take and ring_buffer_read (respectively) but operate on
// the *head* of the ring (i.e., removing the most recently added
// elements rather than the oldest elements).
//
// Neither will underflow, returning NULL if there are not enough
// elements, and without copying anything.
const void * ring_buffer_take_head(ring_buffer *buffer, void *dest, size_t n);
size_t n);

// Copy n entries (each of stride bytes) from one ring buffer
// src into another dest.  The copy starts at the tail of this
// ring buffer, pushing onto the head of the destination buffer.
//
//   src: A ring buffer to copy data from

//   dest: A ring buffer to copy data into
//
//   n: the number of entries to copy (each of which is stride bytes)
//
// This is destructive to both buffers as pointers will be updated in
// both.
//
// This function returns the new head pointer of the destination buffer.
//
// It is not possible to underflow src; if too few entries are
// available, then nothing is copied, src and dest are not
// modified, and the function returns NULL
//
// It is possible to overflow dest and the tail pointer will be
// updated appropriately if so.
//
// Warning: the two buffers must have the same stride.  If the buffers
// do not have the same stride, the function will return NULL (this
// means if the function returns NULL it could either be an underflow
// or an incompatible buffer).
const void * ring_buffer_copy(ring_buffer *src, ring_buffer *dest, size_t n);

// Mirror the contents of ring buffer src into ring buffer dest.
// This differs from ring_buffer_copy in that the src buffer is
// not modified and that the *entire* state of the ring buffer is
// duplicated.
//
// The function requires (and checks) that src and dest agree on
// size and stride (and therefore total bytes).  It returns true if
// the mirror was done, and false if the buffers are incompatible.
//
// This function will destroy all data in dest, but not allocate any
// memory.
//
// Warning: the two buffers must have the same stride *and* the same
// size.  If they do not, the function will return NULL (this means if
// the function returns NULL it could either be an underflow or an
// incompatible buffer).
bool ring_buffer_mirror(const ring_buffer *src, ring_buffer *dest);

// Returns a pointer to the tail (reading end) of the buffer, offset
// by offset entries.  When used as ring_buffer_tail_offset(x, 0)
// this is equivalent to ring_buffer_tail(x) except that it will do
// underflow checking.
//
//   buffer: the ring buffer to use
//
//   offset: the number of entries (each of which are stride bytes)
//           to offset by
//
// It is not possible to underflow the buffer here; if offset is so
// large that it would underflow, then NULL will be returned.
const void * ring_buffer_tail_offset(const ring_buffer *buffer, size_t offset);

// As for ring_buffer_tail_offset, but offsetting the *head*
// pointer.  This offsets in the opposite direction (moving from the
// most recently added element towards the oldest element).
const void * ring_buffer_head_offset(const ring_buffer *buffer, size_t offset);

// Advance the ring buffer by one entry and return a pointer to the
// memory *without writing anything to it*.  In this case, the calling
// function is responsible for setting the memory to something
// sensible.  This is currently used in the dde package where we want
// to write directly to the head.
//
// This is (roughly) equivalent to:
//
//    ring_buffer_set(buffer, 0, 1);
//
// but does not actually copy any data.
//
// Note that the pointer returned is *not* const; this is always used
// in a case where the aim is to write to the head directly!

//// Search: ////

// There are two functions for searching for data within a ring buffer
// that consists of *sorted* entries.  This might be the case if
// entries are added sequentially with (say) a timestamp.
//
// To locate an entry, a predicate function (pointer) must be
// provided.  This must be a function taking two void pointers as
// arguments; the first will be the pointer to an entry in the ring
// buffer, the second will be any data that *you* provide (may be
// NULL).  This function must return "true" if the value is *less
// than* the target value (i.e. true if we should search *earlier* in
// the buffer).  The "x" argument must be treated as read-only.
//
// For example, a predictate function that would find an entry where
// the first 8 bytes of a ring buffer entry represent doubles could be
// written as:
//
//     bool test_find_double(const void *x, void *data) {
//       double x_value = *((double*) x);
//       double data_value = *((double*) data);
//       return x_value <= data_value;
//     }
//
// Where the "data" argument will be passed through as the number to
// search for.
//
// These functions return NULL if no entry is found, otherwise they
// return the pointer to the largest entry in the buffer that the
// predicate returns false.
//
// The _linear search does a naive linear search from the tail of the
// buffer (i.e., the last entry that was added) towards the beginning.
//
// The _bisect search tries to be more clever and does a bisect
// search.  It requires an initial guess "i" to the location of the
// data.  You can provide '0' as 'i' to start at the tail.
//
// The "data" argument to both functions will be passed through to the
// predicate function.
typedef bool ring_predicate(const void *x, void *data);
const void * ring_buffer_search_linear(const ring_buffer *buffer,
ring_predicate pred, void *data);
const void * ring_buffer_search_bisect(const ring_buffer *buffer, size_t i,
ring_predicate pred, void *data);

#ifdef __cplusplus
}
#endif
#endif

For a complete real-world example of use, see dde, which uses a ring buffer to hold the history of a set of differential equations, and uses that to implement delay equations. Here, the ring buffer means that the memory requirements don’t grow with the length of running the simulation (as it only cares about fairly recent history, the natural overflow from the ring buffer is well suited). The memory is only allocated at the beginning of the simulation so there is no additional memory allocations. And because ring returns (const) pointers to the appropriate place in memory there is little copying.

A simple application that implements the same mean-reverting simulation from above:

#include <ring/ring.h>

#include <R.h>
#include <Rinternals.h>

// Definition used below (can't be called step() because that may
// conflict with regexp.h on some platforms).
int step_x(ring_buffer *r, int x);

void example(size_t nstep, double *ret) {
// Construct a ring buffer of (max) size 5, each element of which is
// big enough to contain an integer (probably 4 bytes).
ring_buffer *r = ring_buffer_create(5, sizeof(int), OVERFLOW_OVERWRITE);

// Starting point of the simulation, as in the R version:
int x = 0;

// Push the initial state into the ring buffer:
ring_buffer_push(r, &x, 1);
ret[0] = x;

for (size_t i = 1; i < nstep; ++i) {
x = step_x(r, x);
ring_buffer_push(r, &x, 1);
ret[i] = x;
}

// Cleanup:
ring_buffer_destroy(r);
}

int step_x(ring_buffer *r, int x) {
size_t n = ring_buffer_used(r, false);
double p;
if (n < 2) {
p = 0.5;
} else {
// Oldest non-overflowed element is in the tail.  Note that the
// return value (which is void*) must be first cast to (int*) then
// dereferenced.
///
// NOTE: In general, check that the return value here is not NULL
// (indicating an underflow); here we're OK because we checked the
// number of used elements at the beginning.
int x0 = *(int*)ring_buffer_tail(r);
size_t increases = 0;
for (size_t i = 1; i < n; ++i) {
// Moving through the more recently added elements:
int x1 = *(int*)ring_buffer_tail_offset(r, i);
if (x1 > x0) {
increases++;
}
x0 = x1;
}
p = ((double)increases) / (n - 1);
}

if (unif_rand() < p) {
--x;
} else {
++x;
}

return x;
}

// This function collects all the R API bits that deal with
// communication between C and R.  "Writing R extensions" is the
// canonical documentation source.
SEXP r_example(SEXP r_nstep) {
size_t nstep = (size_t) INTEGER(r_nstep)[0];
SEXP ret = PROTECT(allocVector(REALSXP, nstep));
GetRNGstate(); // because we'll work with random numbers
example(nstep, REAL(ret));
// Cleanup:
PutRNGstate();
UNPROTECT(1);
return ret;
}

// This can be included in a different file, or, for a single file
// project like this one, include here.
#include <ring/ring.c>

# The C++ API

If you’re using C++ you may find the Boost circular buffer is likely to be far better; you can use this by LinkingTo: the BH package and using #include <boost/circular_buffer.hpp> in your code.

Alternatively, the ring C code can be directly used in C++ as above. Or, there is a class-based approach available:

• In your src/ directory, add a file ring.cpp containing just the line #include <ring/ring.cpp>

• Anywhere in your code you want to use the ring buffer, include the line #include <dde/dde.hpp> to include the class definition:

#ifndef _RING_HPP_
#define _RING_HPP_

// NOTE: the C++ version always uses non-R memory allocation functions
// because otherwise the R error can jump over destructors causing
// memory leaks or worse.  Errors will be thrown with "throw", which
// Rcpp will catch if you use that.
//
// However, note that if using overflow_action of anything other than
// OVERFLOW_OVERWRITE is possibly unsafe; OVERFLOW_GROW is fine so
// long as you never run out of memory, and OVERFLOW_ERROR is probably
// never safe.
#define RING_USE_STDLIB_ALLOC 1
#include <ring/ring.h>

class RingBuffer {
ring_buffer * buffer;
public:
RingBuffer(size_t size, size_t stride, overflow_action on_overflow);
~RingBuffer();
RingBuffer(const RingBuffer& other);
RingBuffer& operator=(RingBuffer other);

void grow(size_t n, bool exact);
void reset(bool clear);
size_t size(bool bytes) const;
size_t free(bool bytes) const;
size_t used(bool bytes) const;
size_t bytes_data() const;
bool is_full() const;
bool is_empty() const;
const void * data() const;
const void * tail() const;
#endif


text:
# How to add a framed box inside a paragraph?

I'm using little markers in some parts of my text and I wanted to add one of those to a paragraph entitling a list:

\newcommand{\hip}{{\color{BlueViolet}\framebox[1.1\width]{HIP}}}

\paragraph*{\hip{} Following that description, we can infer the following hypothesis:}

However, that fails with:

! Use of \reserved@a doesn't match its definition.
\@ifnextchar ... \reserved@d =#1\def \reserved@a {
#2}\def \reserved@b {#3}\f...
l.219 ..., we can infer the following hypothesis:}

! Use of \@framepicbox doesn't match its definition.
\@ifnextchar ...eserved@d =#1\def \reserved@a {#2}
\def \reserved@b {#3}\futu...
l.219 ..., we can infer the following hypothesis:}

Both errors come with this explanation, that doesn't make sense for me... "If you say, e.g., '\def\a1{...}', then you must always put '1' after '\a', since control sequence names are made up of letters only. The macro here has not been followed by the required stuff, so I'm ignoring it."

What does it mean and how do I fix that?

Example of command in a normal text line:

• there's not enough here to actually test this, but i think that if you add \protect just before \hip this will probably work. this is the old "fragile" command situation. – barbara beeton Mar 8 '15 at 19:44
• Do you really want to use \paragraph? Why not just set it without a \paragraph? – Werner Mar 8 '15 at 19:45
• Compiles fine here if I add a standard preamble. Please post a complete MWE so we can reproduce the problem. – cfr Mar 9 '15 at 2:57
• @barbarabeeton I'll be happy to accept your comment as an answer! That solved the matter. – igorsantos07 Apr 25 '15 at 2:45

without evidence to the contrary, \hip appears to be a "fragile" command.

adding \protect before a fragile command in a "moving argument" (the argument to a command like \paragraph that can potentially also be used somewhere else, such as in the toc) will avoid the problem. so here, \protect\hip.

more information on this situation can be found with the question What is the difference between Fragile and Robust commands?

I don't have any errors using the following:

\documentclass{article}
\usepackage{color}
\definecolor{BlueViolet}{rgb}{0.54, 0.17, 0.89}
\newcommand{\hip}{{\color{BlueViolet}\framebox[1.1\width]{HIP}}}
\begin{document}
\paragraph*{\hip{} Following that description, we can infer the following hypothesis:}
\end{document}

The issue was solved by using \protect, as suggested by @barbarabeeton. If she posts an answer I'll be happy to remove this and accept hers :)
\paragraph*{\protect\hip{} Following...}


text:
Why is this seemingly more-restricted set of possible passwords larger than this less-restricted set?

I'm doing a password cracking challenge right now, and I know several restrictions of the password.

• The password is 8 characters long
• The first character is a lowercase letter, the second character is a digit
• The seventh and eighth characters are both lowercase letters
• The remaining characters (third, fourth, fifth, sixth) are all uppercase letters, EXCEPT for one, which is a lowercase letter, and another, which is a digit.

I'm considering taking two approaches to cracking this password: a masked brute-force approach and a hybrid rules/brute force approach.

The masked brute force approach would see me processing a maximum of $$26\times10\times62\times62\times62\times62\times26\times26 \approx \bf{2.597\times10^{12}},$$ candidates, which for a decent GPU processing at $$8000 \text{ kH/s}$$ would take around 90 hours.

This approach doesn't take advantage of the knowledge that the third, fourth, fifth, and sixth characters can only contain one digit and one lowercase letter, so I figured I could optimize this brute force approach by generating a much more restricted set of candidates and using rules to generate possibilities based on that.

I did this by generating a list of $$26*10*26*26*26*26*26*26 \approx 8*10^{10}$$ candidates, using lowercase letters for the first, seventh, and eighth characters, a digit for the second character, and uppercase letters for the third, fourth, fifth, and sixth characters. This list of candidates is then put through a list of 120 rules (40 possible permutations of a random digit in positions 3, 4, 5, or 6 times 3 possible ways to lowercase a singe remaining letter) which cover all combinations of one added digit + one lowercase character, giving me $$8*10^{10} * 120 = 9.6*10^{12}$$ total candidates.

My question is:

How is it possible that the first, brute-forced list, including candidates that could not possibly be correct (too many lowercase chars or digits), is smaller by almost four times than the tailored list that should exclusively contain candidates that fit the restrictions?

Am I unknowingly creating tons of duplicates, or did I make a mistake somewhere in my math that I missed?

• Well, your second computation ignores the case of the letters. As there are two choices for case, the $26's$ should be $52's$.
– lulu
Oct 3, 2020 at 17:09
• The second computation purposely only calculates lowercase letters in the first, seventh, and eighth positions, and uppercase letters in the third, fourth, fifth, and sixth positions; since we know there can only be one lowercase letter in positions three, four, five, and six, and one of those has to be a digit, there are only three possible ways for each candidate's case to be toggled (which is why I used rules to calculate those instead, and why the second computation's intermediate value is multiplied by 120 to get the final result.) Oct 3, 2020 at 17:12
• I think it isn't clear what your two cases are counting. There are so many options involved.
– lulu
Oct 3, 2020 at 17:14
• The two cases are counting possible password candidates for breaking a password that matches the given restrictions. Oct 3, 2020 at 17:18
• Yes, but there are so many options that it isn't clear which restrictions you are following at any time. Just say exactly what rules you are following for the first count, and what rules you are following for the second count.
– lulu
Oct 3, 2020 at 17:21

I'll focus only on the third, fourth, fifth and sixth characters, as the rest is the same in both cases.

In your first approach, where you overestimate the number of passwords, you simply consider all options for all four characters, yielding $$(26+26+10)^4=62^4,$$ options. In your second approach, which is less clear, you start from $$26^4$$ options, suggesting $$4$$ characters and then consider some permutations: You consider $$40$$ options for the digit, and then $$3$$ options for the lowercase letter, yielding $$26^4\times40\times3.$$ But then you should have started with only $$3$$ characters, i.e. with $$26^3$$ instead of $$26^4$$.

A more structured approach would be to first choose the positions of the digit and the lowercase letter; there are $$4\times3=12$$ options. Then choose $$2$$ uppercase letters, $$1$$ lowercase letter and a digit, yielding $$12\times26^3\times10.$$

• Thank you for the edit! This helped me realize where I was wrong; I'm going to try generating the list of candidates in a different way, choosing where the digits are first. Oct 3, 2020 at 19:57

Consider only the $$4$$ central characters in your second calculation. Start by creating all possible upper-case four-letter strings, $$AAAA, AAAB, AAAC, \dots, AAAZ, \dots, ZZZY, ZZZZ$$.

Next, for each of the generated strings, replace one of the letters with a digit. As an example, consider only replacing the last letter with the digit $$1$$.

The above sequence becomes $$AAA1, AAA1, AAA1, \dots, AAA1, \dots, ZZZ1, ZZZ1$$, and it's easy to see that it is checking the same case several times. Ultimately, this leads to more checks overall.

It's not simply $$26$$ times as may checks though, because strings such as $$aaa1, bbb1, 1111, a1Z1$$ and many, many more are no longer checked.


text:
# Does commutativity imply Associativity?

Does commutativity imply associativity? I'm asking this because I was trying to think of structures that are commutative but non-associative but couldn't come up with any. Are there any such examples?

NOTE: I wasn't sure how to tag this so feel free to retag it.

-
Commutative operations that are associative are the exception. But an important exception! Let $x\ast y=|x-y|$. –  André Nicolas Jun 20 '12 at 20:41
Not even in the presence of an identity element and an opposite, see this. In fact, William's answer is already in that post ;) –  lentic catachresis Jun 20 '12 at 21:58
The interchange law $(x * y) \cdot (z * w) = (x \cdot z) * (y \cdot w)$, in the presence of a two-sided common unit element, implies commutativity and associativity of $*$ and $\cdot$. (In fact, they have to be the same operation!) –  Zhen Lin Jun 20 '12 at 22:14
See my 3 February 2009 sci.math post A natural example of a commutative, non-associative operator (see Google archive version or Math Forum archive version) for some examples and references. –  Dave L. Renfro Jun 22 '12 at 21:31

Consider the operation $(x,y) \mapsto xy+1$ on the integers.

-
Very nice example! –  Eugene Jun 20 '12 at 20:41
@marlu Could you explain this some more please? It doesn't say why, or (for people like me who don't know much about maths), what that arrow even means. –  user673679 Jan 12 at 13:13
Well, associativity and commutativity are properties of maps $X\times X \to X$ for a set $X$. In other words, such a map takes two elements as an "input" and returns a single element. In my example, the set under consideration is the set of integers and the map sends each pair of integers $(x,y)$ to $xy+1$. Commutativity means $xy + 1 = yx + 1$ for all $x$ and $y$, which is satisfied. Associativity would mean $x(yz+1) + 1 = (xy+1)z+1$ for all $x$, $y$ and $z$, but it's easy to find examples where this equation does not hold, so the operation is not associative. –  marlu Jan 14 at 4:14
Short, sweet. Nice. –  AJFarmar Mar 20 at 20:55

A basic example is the "midpoint" binary operation: $a*b = \frac{a+b}{2}$

In general, if $P(u,v)$ is any polynomial in two variables with rational coefficients, then $x*y = P(x+y,xy)$ is rarely associative - I'd be curious under what conditions on $P$ this operation would be associative.

My example is $P(u,v)=\frac{u}{2}$ and Marlu's example is $P(u,v)=1+v$.

-
In general, a symmetric function $P(x,y)$ is rarely associative. You could take $P(x,y)=\arctan xy+e^{(x+y)^9}$, too. –  Mariano Suárez-Alvarez Sep 14 '12 at 16:38

The easiest Jordan algebra is symmetric square matrices with the operation $$A \ast B = (AB + BA)/2,$$ similar to a Lie algebra but with a plus sign.

http://en.wikipedia.org/wiki/Jordan_algebra

-

Let $A = \{e,x,y\}$. Define $\cdot$ on $A$ to be $a\cdot e=a$ for all $a$, $e\cdot a= a$ for all a, and $a\cdot b=e$ for all $a$ and $b$ such that $a\neq e$ and $b\neq e$, (i.e. $a,b \in \{x,y\}$).

This operation is commutative, $e$ is the identity, (everything even has an inverse), but is not associative since $(x \cdot y) \cdot y = e \cdot y = y$ and $x \cdot (y \cdot y) = x \cdot e = x$.

-


text:
# Weighted harmonic mean of rates expressed as decimals

Wikipedia defines the weighted harmonic mean of a set of rates as follows:

$$H=\frac{\sum\limits_{i=1}^n w_i}{\sum\limits_{i=1}^n\frac{w_i}{x_i}}=\left(\frac{\sum\limits_{i=1}^n w_ix_i^{-1}}{\sum\limits_{i=1}^n w_i}\right)^{-1}$$

It then proceeds to give examples using rates expressed in terms of km/h. if the rates of which i want to calculate the harmonic mean are decimals less than 1 (as in rates of precision or recall), and i wish to arbitrarily weigh some of the rates as more important than others, what constraints if any must govern which weights i select? do they need to be decimals and sum to one?

Thanks!

• The only circumstances in which this formula is undefined are when any division by zero is attempted; viz. (a) $\sum w_i=0$, (b) any $x_i=0,$ or (c) $\sum w_i x_i^{-1}=0.$ In your case (a) doesn't hold and (b) or (c) can hold only when at least one $x_i$ is zero. Thus, the answer depends on whether by "between 0 and 1" can possibly include $0$ or not. Which does it mean?
– whuber
Aug 12 '19 at 19:59
• Sorry -- definitely does not include 0. edited to clarify. Aug 12 '19 at 20:06
• Okay, thank you. Please explain what it means to "matter": since there is no mathematical issue to decide, what is your intended meaning of this? Is there some possibility that it makes no sense to compute a mean for the quantities represented by your decimals? If so, what kinds of quantities would those be?
– whuber
Aug 12 '19 at 20:07
• @whuber i clarified my question -- asking about constraints on possible value of weights. thanks! Aug 13 '19 at 2:28
• It's unclear what you mean by "decimals." The weights have to be nonnegative, as is almost always the case in any weighted average. The result is unchanged when you multiply them all by the same positive number--it just cancels in the fraction--so the sum-to-unity restriction is without meaning.
– whuber
Aug 13 '19 at 13:06

Harmonic mean for summarizing MPG. Suppose I take a weekend trip to mountains 100 miles away. Going uphill my car gets 15mpg and returning it gets 25mpg. That doesn't mean my average fuel efficiency for the trip is 20mpg. I used a total of $$\frac{100}{15} + \frac{100}{25} = 10.67$$ gallons to go $$200$$ miles, so the overall fuel efficiency is $$200/10.67 = 18.74$$mpg. Notice that this is a harmonic mean.
Distributions. Suppose the 1000 cars in a small US car rental company have fuel efficiencies distributed approximately $$\mathsf{Norm}(\mu = 30, \sigma = 5)$$ mpg. Then the metric fuel efficiencies could not be normal, but considerably right-skewed. (This may be reasonable because stopped, waiting for a green light, my instantaneous metric fuel efficiency is infinite.)
The histograms below show the US and metric fuel efficiencies of this hypothetical fleet of rental cars. Histogram bins for mpg in the left panel are of equal width. The density curve of $$\mathsf{Norm}(30, 5)$$ is shown.
In the panel at right, the bins are of unequal widths. They correspond to the bins at left, but in reverse order. A kernel density estimator of the transformed values is shown. (Transformation: mtr = 235.2/mpg.)


text:
# Negation

{{#invoke:Hatnote|hatnote}} Template:More footnotes {{ safesubst:#invoke:Unsubst||$N=Use dmy dates |date=__DATE__ |$B= }}

In logic, negation, also called logical complement, is an operation that takes a proposition p to another proposition "not p", written ¬p, which is interpreted intuitively as being true when p is false and false when p is true. Negation is thus a unary (single-argument) logical connective. It may be applied as an operation on propositions, truth values, or semantic values more generally. In classical logic, negation is normally identified with the truth function that takes truth to falsity and vice versa. In intuitionistic logic, according to the Brouwer–Heyting–Kolmogorov interpretation, the negation of a proposition p is the proposition whose proofs are the refutations of p.

## Definition

No agreement exists as to the possibility of defining negation, as to its logical status, function, and meaning, as to its field of applicability..., and as to the interpretation of the negative judgment, (F.H. Heinemann 1944).[1]

Classical negation is an operation on one logical value, typically the value of a proposition, that produces a value of true when its operand is false and a value of false when its operand is true. So, if statement A is true, then ¬A (pronounced "not A") would therefore be false; and conversely, if ¬A is true, then A would be false.

The truth table of ¬p is as follows:

Truth table of ¬p
p ¬p
True False
False True

Classical negation can be defined in terms of other logical operations. For example, ¬p can be defined as pF, where "→" is logical consequence and F is absolute falsehood. Conversely, one can define F as p & ¬p for any proposition p, where "&" is logical conjunction. The idea here is that any contradiction is false. While these ideas work in both classical and intuitionistic logic, they do not work in Brazilian logic, where contradictions are not necessarily false. But in classical logic, we get a further identity: pq can be defined as ¬pq, where "∨" is logical disjunction: "not p, or q".

Algebraically, classical negation corresponds to complementation in a Boolean algebra, and intuitionistic negation to pseudocomplementation in a Heyting algebra. These algebras provide a semantics for classical and intuitionistic logic respectively.

## Notation

The negation of a proposition p is notated in different ways in various contexts of discussion and fields of application. Among these variants are the following:

Notation Vocalization
~p not p
p not p
Np en p
¬p not p
${\displaystyle p'\!}$ p prime,
p complement
${\displaystyle {\bar {p}}}$ p bar,
bar p
${\displaystyle !p\!}$ bang p
not p

In Set Theory \ is also used to indicate 'not member of': U \ A is the set of all members of U that are not members of A.

No matter how it is notated or symbolized, the negation ¬p / −p can be read as "it is not the case that p", "not that p", or usually more simply (though not grammatically) as "not p".

## Properties

### Double negation

Within a system of classical logic, double negation, that is, the negation of the negation of a proposition p, is logically equivalent to p. Expressed in symbolic terms, ¬¬pp. In intuitionistic logic, a proposition implies its double negation but not conversely. This marks one important difference between classical and intuitionistic negation. Algebraically, classical negation is called an involution of period two.

However, in intuitionistic logic we do have the equivalence of ¬¬¬p and ¬p. Moreover, in the propositional case, a sentence is classically provable if its double negation is intuitionistically provable. This result is known as Glivenko's theorem.

### Distributivity

De Morgan's laws provide a way of distributing negation over disjunction and conjunction :

${\displaystyle \neg (a\vee b)\equiv (\neg a\wedge \neg b)}$,  and
${\displaystyle \neg (a\wedge b)\equiv (\neg a\vee \neg b)}$.

### Linearity

In Boolean algebra, a linear function is one such that:

If there exists a0, a1, ..., an ${\displaystyle \in }$ {0,1} such that f(b1, ..., bn) = a0 ⊕ (a1 ${\displaystyle \land }$ b1) ⊕ ... ⊕ (an ${\displaystyle \land }$ bn), for all b1, ..., bn ${\displaystyle \in }$ {0,1}.

Another way to express this is that each variable always makes a difference in the truth-value of the operation or it never makes a difference. Negation is a linear logical operator.

### Self dual

In Boolean algebra a self dual function is one such that:

f(a1, ..., an) = ~f(~a1, ..., ~an) for all a1, ..., an ${\displaystyle \in }$ {0,1}. Negation is a self dual logical operator.

## Rules of inference

There are a number of equivalent ways to formulate rules for negation. One usual way to formulate classical negation in a natural deduction setting is to take as primitive rules of inference negation introduction (from a derivation of p to both q and ¬q, infer ¬p; this rule also being called reductio ad absurdum), negation elimination (from p and ¬p infer q; this rule also being called ex falso quodlibet), and double negation elimination (from ¬¬p infer p). One obtains the rules for intuitionistic negation the same way but by excluding double negation elimination.

Negation introduction states that if an absurdity can be drawn as conclusion from p then p must not be the case (i.e. p is false (classically) or refutable (intuitionistically) or etc.). Negation elimination states that anything follows from an absurdity. Sometimes negation elimination is formulated using a primitive absurdity sign ⊥. In this case the rule says that from p and ¬p follows an absurdity. Together with double negation elimination one may infer our originally formulated rule, namely that anything follows from an absurdity.

Typically the intuitionistic negation ¬p of p is defined as p→⊥. Then negation introduction and elimination are just special cases of implication introduction (conditional proof) and elimination (modus ponens). In this case one must also add as a primitive rule ex falso quodlibet.

## Programming

As in mathematics, negation is used in computer science to construct logical statements.

    if (!(r == t))
{
/*...statements executed when r does NOT equal t...*/
}

The "!" signifies logical NOT in B, C, and languages with a C-inspired syntax such as C++, Java, JavaScript, Perl, and PHP. "NOT" is the operator used in ALGOL 60, BASIC, and languages with an ALGOL- or BASIC-inspired syntax such as Pascal, Ada, Eiffel and Seed7. Some languages (C++, Perl, etc.) provide more than one operator for negation. A few languages like PL/I and Ratfor use ¬ for negation. Some modern computers and operating systems will display ¬ as ! on files encoded in ASCII. Most modern languages allow the above statement to be shortened from if (!(r == t)) to if (r != t), which allows sometimes, when the compiler/interpreter is not able to optimize it, faster programs.

In computer science there is also bitwise negation. This takes the value given and switches all the binary 1s to 0s and 0s to 1s. See bitwise operation. This is often used to create ones' complement or "~" in C or C++ and two's complement (just simplified to "-" or the negative sign since this is equivalent to taking the arithmetic negative value of the number) as it basically creates the opposite (negative value equivalent) or mathematical complement of the value (where both values are added together they create a whole).

To get the absolute (positive equivalent) value of a given integer the following would work as the "-" changes it from negative to positive (it is negative because "x < 0" yields true)

    unsigned int abs(int x)
{
if (x < 0)
return -x;
else
return x;
}

To demonstrate logical negation:

    unsigned int abs(int x)
{
if (!(x < 0))
return x;
else
return -x;
}

Inverting the condition and reversing the outcomes produces code that is logically equivalent to the original code, i.e. will have identical results for any input (note that depending on the compiler used, the actual instructions performed by the computer may differ).

This convention occasionally surfaces in written speech, as computer-related slang for not. The phrase !voting, for example, means "not voting".

## Kripke semantics

In Kripke semantics where the semantic values of formulae are sets of possible worlds, negation can be taken to mean set-theoretic complementation.{{ safesubst:#invoke:Unsubst||date=__DATE__ |\$B= {{#invoke:Category handler|main}}{{#invoke:Category handler|main}}[citation needed] }} (See also possible world semantics.)


text:
## PREP 2014 Question Authoring - Archived

### Re: Does \{$a->ans_rule()\} associate$a with the answer blank?

by Davide Cervone -
Number of replies: 0
Your $a[$m] = [$m,$m] uses the array @a, so you still have to make that into an array reference. You are almost there, but you want
    $X->{test_points} = [@a];  using @ not $a. The difference is that @a and $a is a scalar (and generally are two different variables, even though they have the same letter). So why is $a[$m] rather than @a[$m]? Because the entry in the array is a scalar, so you need to use a dollar sign, indicating a scalar value, rather than an at sign (which would indicate an array).

Another reason is that you get a slice of an array using the @ form: @a[1,3,5] would be a new array made from the first, third, and fifth element of @a. So technically @a[$m] should be an array with one element, but because many people get this wrong (and I think it used to be the correct way to do it in very early versions of Perl), Perl handles @a[$m] as a scalar anyway.

Alternatively, you could use

    $P = []; for ($m=0; $m <$N; $m++) {$P->[$m] = [$m,$m]; }$X->{test_points} = $P;  to make $P a reference to an array, and $P->[$m] to access the entries in the array.

Another approach would be to assign to the test points directly:

    $X->{tet_points} = []; for ($m=0; $m <$N; $m++) {$X->{test_points}[$m] = [$m,$m]; }  Here, you could also do $X->{test_points}->[$m], but once you de-reference the first time (using ->), Perl assumes the remaining de-references when you use braces or brackets. Finally, a very compact form: $X->{test_points} = [map { [$_,$_] } (0..$N-1)];  This uses the array of integers from 0 to $N-1 and maps them through code that returns an array reference with two elements, both equal to the integer from the original array. The resulting array of references is put into [...] so produce a reference to the array.


text:
# SETS

Chapter-1

Sets

In mathematics set is defined as the collection of well defined object which can be separated distinctly.

For instance,

S = {2, 4, 6, 8} is collection of the even integers.

A set can be explained in different ways:

Listing method: A = {a, b, c, .z}

Descriptive method: N = {the natural numbers from 1 to 50}

Set builder method: A – B= A -(A∩ B )

Venn – diagram

Universal sets

A universal set is the collection of all objects in a particular context or theory. All other sets in that framework constitute subsets of the universal set, which is denoted as letter U. The objects themselves are known as elements or members of U.

Subsets

The set made by elements of the universal sets is called subsets of the universal sets

For example

U = {1, 2, 3, 4, …………..50}

A = {even integers from 1 to 50}

B= {odd numbers from 1 to 50}

Here, A and B are the subsets of U

Overlapping sets

Two sets are said to be overlapped if they have same element in common.

A∩ B = {6}

A and B are overlapping sets.

Disjoint sets

Two sets are said to be disjoint sets if there is no element in common.

Cardinality of the sets

The number of the elements in the given sets is known as cardinality of sets.

A = {1, 2, 5,}

B = {5, 3, 4}

AUB = {1, 2, 3, 4, 5}

n(A) = 3

n(B) = 3

n(AUB) = 5

Cardinality of the three sets

LetA and B and Crepresent three sets as a shown in the figure s

n(AUBUC) =n(A) + n(B) + n(C) - n(A∩ B) -- n(B∩ C) - n(C∩ A) +n(A∩ B∩ C)

Finite set

A set which contains finite number of elements is called a finite set.

Eg. A = {a,b,c,d}.

Infinite set

A set which contains infinite number of elements is called an infinite set.

EgB = {x:xis a point on a line}

Singleton set

A set which contains only one element is a singleton set.

A :{ x: x set of even prime numbers}

i.eA = {2}.

Null set

A set which does not contain any element is called empty set or null set.

S = {x: x ∈ Z, x = 1/n, n ∈ N}

N is natural number and Z is integer.

Equivalent sets

Two sets which have the same number of elements, i.e. same cardinality are equivalent sets.

P = {p. q. r, s, t} and Q = {a, e, i, o, u}

Since the two sets P and Q contain the same number of elements 5, therefore they are equivalent sets.

Equal sets

Two sets that contain the same elements are called equal sets.

A = {1, 2, 3, 4, 5, 6, 7, 8, 9} and B = {1, 2, 3, 4, 5, 6, 7, 8, 9}

Operation of sets

Union of sets

The set which includes elements of A and B is called union of the sets.

A = {1, 2, 5,}

B = {5, 3, 4}

AUB = {1, 2, 3, 4, 5}

Or, AUB = {x: xϵ A or xϵ B}

n(A) = 3

n(B) = 3

n(AUB) = n(A) + n(B) - n(A∩ B)

= 3 +3 -1 = 5

Intersections of sets

If the elements of set belongs to both Sets A and B, it is called intersection of A and B.

A = {1, 2, 5}

B = {5, 3, 4}

A∩ B = {5}

n(A∩ B) = n(A) – n0 (A) = 3 -2 = 1

Or, A∩ B = {x: xϵ A and x ϵ B}

Complement of sets

The set that contains all the elements of universal sets except the given set A is called complement of the set A . It is denoted byA̅

Difference of sets

If A and B are the two sets , the difference of the dsets is the elements of the set thst includes only in one set .

A – B= A -(A∩ B )

B- A= B-(A∩ B )

Example

Examples1

In a group of 200 students who like game, 120 like cricket game an 105 like football game. By drawing Venn diagram find

i. how many students like both the games ?

ii. How many students like only cricket?

Soln

n(U) = 200

C and F denote the students who study Cricket and football respectively.

n(C) =120

n(F) = 105

n( C ∩ F)=?

We have

n (CUF)=n(C) + n(F) -n(C∩ F)

200 = 120 + 105 -n(C∩ F)

n(C∩ F)= 25

n0(C) = n(C) -n( C ∩ F)= 120 – 25 = 95

Examples 2

In the certain examination, 50% students passed in account, 30% passed in English, 30% failed in both and 25 student passes in both subjects. By drawing Venn – diagram, find the number of the students who passes in account only.

Let total number be x A and E denotes the students who study account and English respectively

n(A) =50%

n(E) = 30%

= 30 %

n( A U E) = 25

We have

n(U)= n(A)+ n(E)+${\rm{\: n\: }}\overline {\left( {{\rm{AUE}}} \right)}$ - n( A ∩E)

100%= 50 % + 30% + 30 % - n( A ∩E)

n( A ∩E) = 10%

According to the question,

10% of x = 25

x= 250

The number of the students who passed in accounts only = 40% of the 250 = 100

Examples 3

In a survey it was found that 8.%people like oranges ,85% like mangoes and 75% like both But 45 people like none of themDrawing Venn –diagram , find the number of the people whowere in the survey.

Soln:

Let O and M be the number of people who like oranges and mangoes respectively.

n (U) =n(OUM) + $\overline {{\rm{n}}\left( {{\rm{OUM}}} \right)}$

100%=n (O) + n (M) - n(O∩M) + $\overline {{\rm{n}}\left( {{\rm{OUM}}} \right)}$

100% =80% + 85% - 75% + $\overline {{\rm{n}}\left( {{\rm{OUM}}} \right)}$

$\overline {{\rm{n}}\left( {{\rm{OUM}}} \right)} {\rm{\: }}$= 10%

According to the question,

10%of total number(say x)= 45

Or,x=$\frac{{4500}}{{10}}$ = 450

Go Top


text:
WIKISKY.ORG
 Home Getting Started To Survive in the Universe News@Sky Astro Photo The Collection Forum Blog New! FAQ Press Login

# NGC 7046

Contents

### Images

DSS Images   Other Images

### Related articles

 New Reference Galaxy Standards for H I Emission ObservationsWe have taken advantage of the improved baselines and higher sensitivityavailable with the upgraded Arecibo 305 m telescope to create a new H Ispectral line catalog of disk galaxies that can be used as a referencecatalog for anyone interested in 21 cm spectral line work. In all 108galaxies were observed, covering 24 hr of the sky at declinationsbetween 0° and 36° and velocities between 0 and 25,000 kms-1. The majority of the galaxies were observed at least twotimes on different nights to avoid problems with radio frequencyinterference, baseline fluctuations, etc. Comparing our measured valueswith all those available in the literature shows that although largeindividual variations may exist, the average difference between themeasurements is zero. In all we have considerable confidence in ourmeasurements, and the resulting catalog should be extremely useful as awell-defined reference catalog for anyone interested in 21 cm spectralline work. Mass-to-light ratios from the fundamental plane of spiral galaxy discsThe best-fitting two-dimensional plane within the three-dimensionalspace of spiral galaxy disc observables (rotational velocityvrot, central disc surface brightnessμ0=-2.5logI0 and disc scalelength h) has beenconstructed. Applying the three-dimensional bisector method ofregression analysis to a sample of ~100 spiral galaxy discs that spanmore than 4magarcsec-2 in central disc surface brightnessyields vrot\proptoI0.50\pm0.050\,h0.77\pm 0.07 (B band)and vrot\proptoI0.43\pm0.040\,h0.69\pm 0.07 (R band).Contrary to popular belief, these results suggest that in the B band,the dynamical mass-to-light ratio (within four disc scalelengths) islargely independent of the surface brightness, varying as I0.00\pm0.100\,h0.54\pm 0.14. Consistentresults were obtained when the range of the analysis was truncated byexcluding the low-surface-brightness galaxies. Previous claims thatM/LBvaries withI-1/20,Bareshown to be misleading and/or caused by galaxy selection effects - notall low-surface-brightness disc galaxies are dark matter dominated. Thesituation is, however, different in the near-infrared whereLK'~v4 and M/LK' is shown to vary asI-1/20,K\prime. Theoretical studies ofspiral galaxy discs should therefore not assume a constant M/L ratiowithin any given passband. The B-band dynamical mass-to-light ratio(within four disc scalelengths) has no obvious correlation with (B-R)disc colour, while in the K' band it varies as -1.25+/-0.28(B-R).Combining the present observational data with recent galaxy modelpredictions implies that the logarithm of the stellar-to-dynamical massratio is not a constant value, but increases as discs become redder,varying as 1.70+/-0.28(B-R). The UZC-SSRS2 Group CatalogWe apply a friends-of-friends algorithm to the combined Updated ZwickyCatalog and Southern Sky Redshift Survey to construct a catalog of 1168groups of galaxies; 411 of these groups have five or more members withinthe redshift survey. The group catalog covers 4.69 sr, and all groupsexceed the number density contrast threshold, δρ/ρ=80. Wedemonstrate that the groups catalog is homogeneous across the twounderlying redshift surveys; the catalog of groups and their membersthus provides a basis for other statistical studies of the large-scaledistribution of groups and their physical properties. The medianphysical properties of the groups are similar to those for groupsderived from independent surveys, including the ESO Key Programme andthe Las Campanas Redshift Survey. We include tables of groups and theirmembers. An Investigation into the Prominence of Spiral Galaxy BulgesFrom a diameter-limited sample of 86 low-inclination (face-on) spiralgalaxies, the bulge-to-disk size and luminosity ratios and otherquantitative measurements for the prominence of the bulge are derived.The bulge and disk parameters have been estimated using aseeing-convolved Sérsic r1/n bulge and aseeing-convolved exponential disk that were fitted to the optical (B, R,and I) and near-infrared (K) galaxy light profiles. In general,early-type spiral galaxy bulges have Sérsic values of n>1, andlate-type spiral galaxy bulges have values of n<1. In the B band,only eight galaxies have a bulge shape parameter n consistent with theexponential value 1, and only five galaxies do in the K band. Use of theexponential bulge model is shown to restrict the range ofre/h and B/D values by more than a factor of 2. Applicationof the r1/n bulge models, unlike exponential bulge models,results in a larger mean re/h ratio for the early-type spiralgalaxies than for the late-type spiral galaxies, although this result isshown not to be statistically significant. The mean B/D luminosity ratiois, however, significantly larger (>3 σ) for the early-typespirals than for the late-type spirals. Two new parameters areintroduced to measure the prominence of the bulge. The first is thedifference between the central surface brightness of the galaxy and thesurface brightness level at which the bulge and disk contribute equally.The other test uses the radius at which the contribution from the diskand bulge light are equal, normalized for the effect of intrinsicallydifferent galaxy sizes. Both of these parameters reveal that theearly-type spiral galaxies appear'' to have significantly (more than 2σ in all passbands) bigger and brighter bulges than late-typespiral galaxies. This apparent contradiction with the re/hvalues can be explained with an iceberg-like scenario, in which thebulges in late-type spiral galaxies are relatively submerged in theirdisk. This can be achieved by varying the relative stellar density whilemaintaining the same effective bulge-to-disk ratio. The B/D luminosityratio and the concentration index C31, in agreement with paststudies, are positively correlated and decrease as one moves along thespiral Hubble sequence toward later spiral galaxy types, although forgalaxies with large extended bulges the concentration index no longertraces the B/D luminosity ratio in a one-to-one fashion. A strong(Spearman's rank-order correlation coefficient, rs=0.80) andhighly significant positive correlation exists between the shape, n, ofthe bulge light profile and the bulge-to-disk luminosity ratio. Theabsolute bulge magnitude-logn diagram is used as a diagnostic tool forcomparative studies with dwarf elliptical and ordinary ellipticalgalaxies. At least in the B band these objects occupy distinctlydifferent regions of this parameter space. While the dwarf ellipticalgalaxies appear to be the faint extension to the brighter ellipticalgalaxies, the bulges of spiral galaxies do not; for a given luminositythey have a noticeably smaller shape parameter and hence a more dramaticdecline of stellar density at large radii. Nearby Optical Galaxies: Selection of the Sample and Identification of GroupsIn this paper we describe the Nearby Optical Galaxy (NOG) sample, whichis a complete, distance-limited (cz<=6000 km s-1) andmagnitude-limited (B<=14) sample of ~7000 optical galaxies. Thesample covers 2/3 (8.27 sr) of the sky (|b|>20deg) andappears to have a good completeness in redshift (97%). We select thesample on the basis of homogenized corrected total blue magnitudes inorder to minimize systematic effects in galaxy sampling. We identify thegroups in this sample by means of both the hierarchical and thepercolation friends-of-friends'' methods. The resulting catalogs ofloose groups appear to be similar and are among the largest catalogs ofgroups currently available. Most of the NOG galaxies (~60%) are found tobe members of galaxy pairs (~580 pairs for a total of ~15% of objects)or groups with at least three members (~500 groups for a total of ~45%of objects). About 40% of galaxies are left ungrouped (field galaxies).We illustrate the main features of the NOG galaxy distribution. Comparedto previous optical and IRAS galaxy samples, the NOG provides a densersampling of the galaxy distribution in the nearby universe. Given itslarge sky coverage, the identification of groups, and its high-densitysampling, the NOG is suited to the analysis of the galaxy density fieldof the nearby universe, especially on small scales. Optical Long-Slit Spectroscopy of a Sample of Spiral GalaxiesWe have analyzed long-slit spectra of a sample of 11 spiral galaxies. Weidentify several disk H II regions in each galaxy and provideclassifications for the nuclear spectra. We find seven nuclear H IIregion galaxies, including four starburst nucleus galaxies, and fourLINERs. Arcsecond Positions of UGC GalaxiesWe present accurate B1950 and J2000 positions for all confirmed galaxiesin the Uppsala General Catalog (UGC). The positions were measuredvisually from Digitized Sky Survey images with rms uncertaintiesσ<=[(1.2")2+(θ/100)2]1/2,where θ is the major-axis diameter. We compared each galaxymeasured with the original UGC description to ensure high reliability.The full position list is available in the electronic version only. A strong correlation between bar strength and global star forming activity in isolated barred galaxiesI have studied the relation between the global star formation activityand the bar structure in a sample of isolated barred galaxies. The starformation activity was quantified via the ratio between the IRAS fluxesat 25 mu m and 100 mu m. Two parameters were chosen to define the barstructure: the strength of the bar and the relative projected barlength. The strength of the bar was defined by epsilon_ {b}=10(1-b/a),where a and b are the projected semi-major and semi-minor bar axis. Therelative bar length was defined as: 2Lb/D25, whereL_ {b} is one half of the projected total bar length and D25is the diameter of the 25 mag arcsec-2 magnitude isophote inthe B band. We found a strong correlation between the star formationactivity and epsilon_ {b}. The regression line is given bylog(I25/I100)=-1.81+0.093 epsilon_ {b}, with acorrelation coefficient of 0.9. The link is not so evident between therelative projected bar length and the star formation activity. But, itis noted that there is enhanced star formation activity in galaxies withstrong bars and small relative bar lengths,0.1<2Lb/D25<0.22. Total magnitude, radius, colour indices, colour gradients and photometric type of galaxiesWe present a catalogue of aperture photometry of galaxies, in UBVRI,assembled from three different origins: (i) an update of the catalogueof Buta et al. (1995) (ii) published photometric profiles and (iii)aperture photometry performed on CCD images. We explored different setsof growth curves to fit these data: (i) The Sersic law, (ii) The net ofgrowth curves used for the preparation of the RC3 and (iii) A linearinterpolation between the de Vaucouleurs (r(1/4) ) and exponential laws.Finally we adopted the latter solution. Fitting these growth curves, wederive (1) the total magnitude, (2) the effective radius, (3) the colourindices and (4) gradients and (5) the photometric type of 5169 galaxies.The photometric type is defined to statistically match the revisedmorphologic type and parametrizes the shape of the growth curve. It iscoded from -9, for very concentrated galaxies, to +10, for diffusegalaxies. Based in part on observations collected at the Haute-ProvenceObservatory. Gas Mass Fractions and the Evolution of Spiral GalaxiesWe show that the gas mass fraction of spiral galaxies is stronglycorrelated with luminosity and surface brightness. It is not correlatedwith linear size. Gas fraction varies with luminosity and surfacebrightness at the same rate, indicating evolution at fixed size. Dimgalaxies are clearly less evolved than bright ones, having consumed only~ \frac {1}{2} of their gas. This resolves the gas consumption paradox,since there exist many galaxies with large gas reservoirs. Thesegas-rich galaxies must have formed the bulk of their stellar populationsin the last half of a Hubble time. The existence of such immaturegalaxies at z = 0 indicates that either galaxy formation is a lengthy oreven ongoing process, or the onset of significant star formation can bedelayed for arbitrary periods in tenuous gas disks. Near-infrared and optical broadband surface photometry of 86 face-on disk dominated galaxies. II. A two-dimensional method to determine bulge and disk parameters.In this Paper I present a new two-dimensional decomposition technique,which models the surface photometry of a galaxy with an exponentiallight profile for both bulge and disk and, when necessary, with aFreeman bar. The new technique was tested for systematic errors on bothartificial and real data and compared with widely used one-dimensionaldecomposition techniques, where the luminosity profile of the galaxy isused. The comparisons indicate that a decomposition of thetwo-dimensional image of the galaxy with an exponential light profilefor both bulge and disk yields the most reproducible and representativebulge and disk parameters. An extensive error analysis was made todetermine the reliability of the model parameters. If the model with anexponential bulge profile is a reasonable description of a galaxy, themaximum errors in the derived model parameters are of order 20%. Theuncertainties in the model parameters will increase, if the exponentialbulge function is replaced by other often used bulge functions as the deVaucouleurs law. All decomposition methods were applied to the opticaland near-infrared data set presented by de Jong & van der Kruit(1994), which comprises 86 galaxies in six passbands. An image database. II. Catalogue between δ=-30deg and δ=70deg.A preliminary list of 68.040 galaxies was built from extraction of35.841 digitized images of the Palomar Sky Survey (Paper I). For eachgalaxy, the basic parameters are obtained: coordinates, diameter, axisratio, total magnitude, position angle. On this preliminary list, weapply severe selection rules to get a catalog of 28.000 galaxies, wellidentified and well documented. For each parameter, a comparison is madewith standard measurements. The accuracy of the raw photometricparameters is quite good despite of the simplicity of the method.Without any local correction, the standard error on the total magnitudeis about 0.5 magnitude up to a total magnitude of B_T_=17. Significantsecondary effects are detected concerning the magnitudes: distance toplate center effect and air-mass effect. Near-infrared and optical broadband surface photometry of 86 face-on disk dominated galaxies. I. Selection, observations and data reduction.We present accurate surface photometry in the B, V, R, I, H and Kpassbands of 86 spiral galaxies. The galaxies in this statisticallycomplete sample of undisturbed spirals were selected from the UGC tohave minimum diameters of 2' and minor over major axis ratios largerthan 0.625. This sample has been selected in such a way that it can beused to represent a volume limited sample. The observation and reductiontechniques are described in detail, especially the not often useddriftscan technique for CCDs and the relatively new techniques usingnear-infrared (near-IR) arrays. For each galaxy we present radialprofiles of surface brightness. Using these profiles we calculated theintegrated magnitudes of the galaxies in the different passbands. Weperformed internal and external consistency checks for the magnitudes aswell as the luminosity profiles. The internal consistency is well withinthe estimated errors. Comparisons with other authors indicate thatmeasurements from photographic plates can show large deviations in thezero-point magnitude. Our surface brightness profiles agree within theerrors with other CCD measurements. The comparison of integratedmagnitudes shows a large scatter, but a consistent zero-point. Thesemeasurements will be used in a series of forthcoming papers to discusscentral surface brightnesses, scalelengths, colors and color gradientsof disks of spiral galaxies. High signal-to-noise ratio observations of H I in 243 galaxiesThe 21 cm spectral-line system of the Arecibo Observatory was used tomeasure neutral hydrogen emission from 243 faint galaxies. Most lie nearthe plane of the Local Supercluster. All observations reach anunsmoothed signal-to-noise ratio of at least 7.0; the average for theset is 23. The resulting data are used to estimate H I masses, systemicvelocities, and accurate profile widths at 20 percent, 25 percent, 50percent, and 80 percent of peak intensity levels. The widths are used tocalibrate directly the bias introduced by popular data-smoothingoperation. The data include observations of 65 objects with previouslyunknown redshifts. Morphology of spiral galaxies. I - General propertiesRed Palomar Sky Survey plates are scanned to characterize a completesample of 605 spiral galaxies north of declination -33 deg havinginclination angle less than 56 deg and blue diameter 2-15 arcmin. Theselection of the data and the reduction and parameter-extractionprocedures are explained, and the data and the results of statisticalanalysis are presented in tables and graphs. Findings reported include alow frequency of occurrence for small inclination angles (suggestingdistortion of outer structures), similar distributions of central diskbrightness for types Sa-Sc but not for types Sd-Sm (where mean valuesare smaller), fewer late-type galaxies with large exponential-disk scalelengths, no galaxies with both high central brightness and large scalelength (indicating a limit on angular momentum in galaxy formation), anda correlation between mean surface brightness and absolute magnitude forlater-type galaxies but not for types Sa-Scd. Velocity calibration of the Las Campanas redshift surveyThe Center for Astrophysics redshift survey is being extended bySchectman et al. (1983) to the south galactic cap. Their initial resultsprovide independent estimates of both emission Ve velocities and theabsorption line Vc velocities, such that (Ve-Vc) = 54 + or - 13 km/s. HI line observations of 40 of the sample are presented here, to provide asecure velocity scale calibration. The Vc velocities are found to have a32 + or - 9 km/s zero-point error. Redshifts for 115 galaxies near the equatorNew redshifts for 115 bright galaxies located near the celestial equatorare reported. The spectra were observed with a blue-sensitivephoton-counting Reticon on the 100-in. DuPont telescope, and theredshifts were derived using the data-analysis system developed for theCfA Redshift Survey. Comparisons with other measured redshifts suggestthat these data are similar in quality to the redshifts measured at Mt.Hopkins for the CfA Redshift Survey; the velocity zero point is good to10 or 15 km/s, with a typical error of 35 km/s for the individualmeasurements.
Submit a new article