text:
## Describing Motion

Michael Fowler

University of Virginia

### Uniform motion in a straight line

Let us consider first the simple case of a car moving at a steady speed down a straight road. Once we've agreed on the units we are using to measure speed---such as miles per hour or meters per second, or whatever---a simple number, such as 55 (mph), tells us all there is to say in describing steady speed motion. Well, actually, this is not quite all---it doesn't tell us which way (east or west, say) the car is moving. For some purposes, such as figuring gas consumption, this is irrelevant, but if the aim of the trip is to get somewhere, as opposed to just driving around, it is useful to know the direction as well as the speed.

To convey the direction as well as the speed, physicists make a distinction between two words that mean the same thing in everyday life: speed and velocity.

Speed, in physics jargon, keeps its ordinary meaning---it is simply a measure of how fast something's moving, and gives no clue about which direction it's moving in.

Velocity, on the other hand, in physics jargon includes direction. For motion along a straight line, velocity can be positive or negative. For a given situation, such as Charlottesville to Richmond, we have to agree beforehand that one particular direction, such as away from Charlottesville, counts as positive, so motion towards Charlottesville would then always be at a negative velocity (but, of course, a positive speed, since speed is always positive, or zero).

### Uniform motion in a plane

Now think about how you would describe quantitatively the motion of a smooth ball rolling steadily on a flat smooth tabletop (so frictional effects are negligible, and we can take the speed to be constant). Obviously, the first thing to specify is the speed---how fast is it moving, say in meters per second? But next, we have to tackle how to give its direction of motion, and just positive or negative won't do, since it could be moving at any angle to the table edge.

One approach to describing uniform motion in the plane is a sort of simplified version of Galileo's "compound motion" analysis of projectiles. One can think of the motion of the ball rolling steadily across the table as being compounded of two motions, one a steady rolling parallel to the length of the table, the other a steady rolling parallel to the width of the table. For example, one could say that in its steady motion the ball is proceeding at a steady four meters per second along the length of the table, and, at the same time, it is proceeding at a speed of three meters per second parallel to the width of the table (this is a big table!). To visualize what this means, think about where the ball is at some instant, then where it is one second later. It will have moved four meters along the length of the table, and also three meters along the width. How far did it actually move? And in what direction?

We can see that if the ball's uniform motion is compounded of a steady velocity of 4 meters per second parallel to the length of the table and a steady velocity of 3 meters per second parallel to the width, as shown above, the actual distance the ball moves in one second is 5 meters (remembering Pythagoras' theorem, and in particular that a right angled triangle with the two shorter sides 3 and 4 has the longest side 5---we chose these numbers to make it easy). That is to say, the speed of the ball is 5 meters per second.

What, exactly, is its velocity? As stated above, the velocity includes both speed and direction of motion. The simplest and most natural way to represent direction is with an arrow. So, we represent velocity by drawing an arrow in the plane indicating the direction the ball is rolling in. We can see on the above representation of a table that this is the direction of the slanting line arrow, which showed from where to where the ball moved in one second, obviously in the direction of its velocity. Hence, we represent the direction of the velocity by drawing an arrow pointing in that direction.

We can make the arrow represent the speed, as well, by agreeing on a rule for its length, such as an arrow 1 cm long corresponds to a speed of 1 meter per second, one 2 cm long represents 2 meters per second, etc. These arrows are usually called vectors.

Let us agree that we represent velocities for the moment by arrows pointing in the direction of motion, and an arrow 2 cm long corresponds to a speed of 1 meter per second. Then the velocity of the ball, which is 5 meters per second in the direction of the slanting arrow above, is in fact represented quantitatively by that arrow, since it has the right length---10 cms. Recalling that we began by saying the ball had a velocity 4 meters per second parallel to the length of the table, and 3 meters per second parallel to the width, we notice from the figure that these individual velocities, which have to be added together to give the total velocity, can themselves be represented by arrows (or vectors), and, in fact, are represented by the horizontal and vertical arrows in the figure. All we are saying here is that the arrows showing how far the ball moves in a given direction in one second also represent its velocity in that direction, because for uniform motion velocity just means how far something moves in one second.

The total velocity of 5 meters per second in the direction of the dashed arrow can then be thought of as the sum of the two velocities of 4 meters per second parallel to the length and 3 meters per second parallel to the width. Of course, the speeds don't add.

Staring at the figure, we see the way to add these vectors is to place the tail of one of them at the head of the other, then the sum is given by the vector from the other tail to the other head. In other words, putting the two vectors together to form two sides of a triangle with the arrows pointing around the triangle the same way, the sum of them is represented by the third side of the triangle, but with the arrow pointing the other way.

### Relative Velocities

As we shall see, relative velocities play an important role in relativity, so it is important to have a clear understanding of this concept. As an example, consider a child running at 3 meters per second (about 6 mph) in a train. The child is running parallel to the length of the train, towards the front, and the train is moving down the track at 30 meters per second. What is the child's velocity relative to the ground? It is 33 meters per second in the direction the train is moving along the track (notice we always specify direction for a velocity). To really nail this down, you should think through just how far the child moves relative to the ground in one second---three meters closer to the front of the train, and the train has covered 30 meters of ground.

A trickier point arises if the child is running across the train, from one side to the other. (This run will only last about one second!) Again, the way to find the child's velocity relative to the ground is to visualize how much ground the child covers in one second---three meters in the direction across the track, from one side to the other, plus thirty meters in the direction along the track. To find the total velocity, we now have to add two velocities at right angles, using the "head to tail" rule for adding vectors. This is just the same problem as the ball rolling across the table at an angle discussed above, and we need to use Pythagoras' theorem to find the child's speed relative to the ground.

Here is another example of vector addition, this time the two vectors to be added are not perpendicular to each other, but the same rules apply:

So in the diagram above, the two vectors on the left add to give the vector on the right. (We are just using a dashed line for one of them so you can see what's going on in the middle, usually all vectors are represented by solid lines.) To get a bit less abstract, this could represent relative velocity in the following way: the big arrow on the left might be the speed at which a person is swimming relative to water in a river, the little arrow is the velocity at which the river water is moving over the river bed. then the vector sum of these two represents the velocity of our swimmer relative to the river bed, which is what counts for actually getting somewhere!

### Aristotle's Law of Horizontal Motion

We restrict our considerations here to an object, such as an oxcart, moving in a horizontal plane. Aristotle would say (with some justification) that it moves in the direction it's being pushed (or pulled), and with a speed proportional to the force being applied. Let us think about that in terms of vectors. He is saying that the magnitude of the velocity of the object is proportional to the applied force, and the direction of the velocity is the direction of the applied force. We see right away that not only is the velocity a vector, but so is the applied force! Of course, this is obvious really---the applied force certainly has magnitude (how hard are we pushing?) and direction, and can be represented by an arrow (we would have to figure out some units of force if we want the length to represent force quantitatively---we will come back to this later).

So Aristotle's rule for horizontal motion is: velocity is proportional to applied force, where both are vectors.

This rule seems to work well for oxcarts, but doesn't make much sense for our ball rolling across a smooth table, where, after the initial shove, there is no applied force in the direction of motion.

### Galileo's Law of Horizontal Motion

Galileo's Law of Horizontal Motion can be deduced from his statement near the beginning of Fourth day in Two New Sciences,

Imagine any particle projected along a horizontal plane without friction; then we know ... that this particle will move along this same plane with a motion which is uniform and perpetual, provided the plane has no limits.

So Galileo's rule for horizontal motion is: velocity = constant, provided no force, including friction, acts on the body.

The big advance from Aristotle here is Galileo's realization that friction is an important part of what's going on. He knows that if there were no friction, the ball would keep at a steady velocity. The reason Aristotle thought it was necessary to apply a force to maintain constant velocity was that he failed to identify the role of friction, and to realize that the force applied to maintain constant velocity was just balancing the frictional loss. In contrast, Galileo realized the friction acted as a drag force on the ball, and the external force necessary to maintain constant motion just balanced this frictional drag force, so there was no total horizontal force on the ball.

### Galileo's Law of Vertical Motion

As we have already discussed at length, Galileo's Law of Vertical Motion is:

For vertical motion: acceleration = constant (neglecting air resistance, etc.)

### Describing Projectile Motion with Vectors

As an exercise in using vectors to represent velocities, consider the velocity of a cannonball shot horizontally at 100 meters per second from the top of a cliff: what is the velocity after 1, 2, 3 seconds? As usual, neglect air resistance.

The initial velocity is represented by a horizontal arrow, which we take to be 10 cms long, for convenience:

------------------------------------------------------------------->

After one second, the downward velocity will have increased from zero to 10 meters per second, as usual for a falling body. Thus, to find the total velocity after one second, we need to add to the initial velocity, the vector above, a vertically downward vector of length 1 cm, to give the right scale:

It is worth noting that although the velocity has visibly changed in this first second, the speed has hardly changed at all---remember the speed is represented by the length of the slanting vector, which from Pythagoras' theorem is the square root of 101 cms long, or about 10.05 cms, a very tiny change. The velocity after two seconds would be given by adding two of the dashed downward arrows head-to-tail to the initial horizontal arrow, and so on, so that after ten seconds, if the cliff were high enough, the velocity would be pointing downwards at an angle of 45 degrees, and the speed by this point would have increased substantially.

### Acceleration

Galileo defined naturally accelerated motion as downward motion in which speed increased at a steady rate, giving rise to units for acceleration that look like a misprint, such as 10 meters per second per second.

In everyday life, this is just what acceleration means---how fast something's picking up speed.

However, in physics jargon, acceleration (like velocity) has a more subtle meaning: the acceleration of an object is its rate of change of velocity. From now on, this is what we mean when we say acceleration.

At first this might seem to you a nitpicking change of definition---but it isn't. Remember velocity is a vector. It can change without its length changing---it could just swing around and point in a different direction. This means a body can accelerate without changing speed!

Why would we want to define acceleration in such a nonintuitive way? It almost seems as if we are trying to make things difficult! It turns out that our new definition is what Galileo might call the natural definition of acceleration. In the true laws of motion that describe things that happen in the universe, as we shall discuss below, if a body has a net force acting on it, it accelerates. But it doesn't necessarily change speed---it might just swing its velocity around, in other words veer off in a different direction. Therefore, as we shall see, this new definition of acceleration is what we need to describe the real world.

For motion in a straight line, our definition is the same as Galileo's---we agree, for example, that the acceleration of a falling body is 10 meters per second per second downwards.


text:
# SyncTeX jumps to pgflibraryfadings in TeXstudio with todonotes

If I ctrl + mouse click on the output text in TeXstudio with the code below then it takes me to pgflibraryfadings.code.tex which is not what I would expect/like. What can I do to fix this? (LuaTeX engine)

EDIT The problem appears to be related to how LuaTeX generates the SyncTeX files.

\documentclass[12pt]{letter}

\usepackage{todonotes}
\usepackage{lipsum}

\begin{document}

\lipsum

\end{document}

• This looks like a TeXstudio issue and should probably be reported to TeXstudio bug tracking on Github. – gernot Nov 13 '19 at 12:40
• see: tex.stackexchange.com/q/300079/100482 for possible answer – naphaneal Nov 13 '19 at 17:48
• Thanks @naphaneal That doesn't do it though. I went so far as to replace all \immediate commands, but nope. – JPi Nov 13 '19 at 18:22
• Incidentally, it appears to be a synctex problem more than a texstudio problem. – JPi Nov 13 '19 at 21:57

format: plain


text:
# Three Recent Directions in Neural Machine Translation

20 Aug 2018 |

Kyunghyun Cho (FAIR and NYU), South England Natural Language Processing Meetup

Slides are here. This was a good talk! So good that we ran overtime with no flagging in audience interest and had about 6 minutes to get out of the British Library before it closed.

## 1. Non-Autoregressive Sequence Modeling

• primary paper
• decoding for sequence modeling
• exact is intractable
• even approximate is inherently sequential
• hence non-autoregressive - assume conditional independence among outputs
• decoding is tractable and parallelizable, yay!
• but there are dependencies, boo
• use latent variables to model dependencies
• however, we can’t marginalize over our latent variables generally
• => need to impose some interpretation on those latent variables to make it tractable
• example for translation (Gu et al. 2018)
• repetition as latent variable (this word in source language translates to how many in target?)
• use fast_align for supervision (Dyer et al. 2013)
• what else can we do?
• let latent variables share output semantics (vocab)
• allows us to do iterative refinement of translation
• a picture is worth a thousand words here…
• model in the box can be just about anything, they used transformer because why the hell not
• loss is true translation (with some corruption) for each iteration
• iterative refinement behaves like conditional denoising autoencoder - learns gradient field that points to data manifold
• almost as good as SOTA, but 4x faster (especially on low-resource languages)
• (from an audience question) maybe could do beam search on the iterations… but, maybe that’s what the refinement is learning to do already!
• takeaways:
• latent variables can capture output dependences more efficiently (than autoregressive decoding)
• different interpretations => different learning/decoding algorithms
• “2 rabbits with 1 stone”, as the Korean version of the proverb apparently goes

## 2. Meta-Learning for Low Resource Languages

• primary paper (anonymous but the figures are the same )
• how to do multilingual MT?
• multitask - N-to-N via shared representation space
• can use 1 encoder/decoder with e.g. Universal Lexical Representation (Gu again, natch)
• BUT
• tends to overfit to low-resource and underfit to high-resource languages
• or just ignore low-resource completely
• results are good but reality involves lots of tricksy tuning
• “it’s more of an art than a science - and a pretty horrible art!”
• we really want transfer learning
• enter model-agnostive meta-learning (Finn et al. 2017)
• very roughly: simulate gradient update & loss on a validation set
• kind of like hyperparameter search… but on the parameters themselves
• similarity between source and target languages still matters for performance
• awaits fully universal bit-level SOTA MT results from OpenAI in a few years
• takeways:
• growing importance of higher-order learning - learning to learn
• I should try to actually understand meta-learning someday

## 3. Real-time Machine Translation

• primary paper
• simultaneous translation - a vaguely ridiculous task
• want to minimise delay while maximising quality of translation
• Neural Networks as Forgetting Machines
• hidden layers contain more info than is needed for the task
• (editor’s note: echoes of InferSent kicking ass, maybe information bottleneck?)
• train a “software hack” to look inside NN - using RL
• basically fix a NMT model & just train a policy on top
• decides when to have the NMT model output a target symbol or wait
• when it decides to translate? roughly follows attention (!)

• takeaways:
• learning, inference, model - the three axes of ML, which must be considered jointly
• find the hidden info in model layers before just trying new ones, you may be surprised
• (editor’s note: this is exactly the takeaway of a certain excellent ICLR workshop paper)

We spent approximately 30 seconds on this entire section but it blew my fucking mind. I mean just look at this slide, how can you not love this shit:


text:
Subscribe
Issue No.01 - January (1992 vol.18)
pp: 33-43
ABSTRACT

Formulas for estimating the probability of failure when testing reveals no errors are introduced. These formulas incorporate random testing results, information about the input distribution; and prior assumptions about the probability of failure of the software. The formulas are not restricted to equally likely input distributions, and the probability of failure estimate can be adjusted when assumptions about the input distribution change. The formulas are based on a discrete sample space statistical model of software and include Bayesian prior assumptions. Reusable software and software in life-critical applications are particularly appropriate candidates for this type of analysis.

INDEX TERMS
failure probability estimation; formulas; random testing results; input distribution; prior assumptions; failure estimate; discrete sample space statistical model; Bayesian prior assumptions; life-critical applications; Bayes methods; probability; program testing
CITATION
K.W. Miller, L.J. Morell, R.E. Noonan, S.K. Park, D.M. Nicol, B.W. Murrill, M. Voas, "Estimating the Probability of Failure When Testing Reveals No Failures", IEEE Transactions on Software Engineering, vol.18, no. 1, pp. 33-43, January 1992, doi:10.1109/32.120314


text:
# Dependency inversion principle

Home Forums Programming Software engineering Object-oriented programming Dependency inversion principle

This topic contains 0 replies, has 1 voice, and was last updated by  Васильев Владимир Сергеевич 3 months, 1 week ago.

• Author
Posts
• #4090

This is an article on one of the five SOLID design principles, dependency inversion principle, based on low cohesion of types.

The formulation of the dependency inversion principle consists of two rules that can have an extremely positive impact on the structure of your code:

• top-level modules should not depend on low-level modules. Both should depend on abstractions.
• abstractions should not depend on the details. Details should depend on abstractions.

Initially it does not sound too appealing, and the reader probably already prepared for a tedious article with a bunch of terms, figures of speech and complex examples which still do not help much to understand the point of the topic. But this is far from the truth, because, in general, the point of the dependency inversion principle, reduces to the proper use of abstraction and polymorphism in the context of the basic idea – the reuse of code.

Another concept that is important here – is the loose coupling of types, that means reducing or eliminating their dependency on each other, which in fact is achieved by means of abstraction, and polymorphism. That is the essence of the dependency inversion principle .

And now let’s look at an example that will demonstrate what loose coupling looks like in action.

Let’s assume, we decided to buy a birthday cake. In order to do this, we went to a wonderful bakery on the corner of the street. After we asked if they can make a cake under the high-sounding title “Luxury” for us and got a positive response, we ordered it. That’s all.

Now, we shall decide on what abstractions it is necessary to provide in this code. To do this, we just ask ourselves a few questions:

• Why cake? We can order muffins or a pie as well as the cake.
• Why a birthday cake? And what if it was a wedding or a prom?
• Why “Luxury”, what if I suddenly like the “Anthill” or “Prague”?
• Why in this bakery, and not for example in a confectionery shop in the city center or anywhere else?

And each of these “why” and “what if” is the point at which your code might require extensibility, and accordingly – the use of loose coupling of types through abstraction.

Now let’s come closer to the constructing of types.

We are defining the interface for any confectionary masterpiece that we could order.

interface IPastry
{
string Name { get; set; }
}

And here is the specific implementation, according to our case – a birthday cake. As you can see, traditionally a birthday cake requires some candles )))

class BirthdayCake: IPastry
{
public int NumberOfCandles { get; set; }
public string Name { get; set; }
public override string ToString()
{
return String.Format("{0} with {1} nice candles", Name, NumberOfCandles) ;
}
}

Now, if we need a cake for a wedding or just for a tea, or if we want some muffins or profiteroles, we have a base interface for any of them.

Now the next question is -what is the difference between all the confectionery (except for the name, of course). And the answer follows – the recipe!

The concept of any recipe includes a list of ingredients and a description of the preparation process. Therefore, for any kind of ingredient we will have a common interface:

interface IIngredient
{
string IngredientName { get;set;}
double Quantity { get; set; }
string Units { get; set; }
}

And here are the ingredients for out cake: flour, butter, sugar and creme:

class Flour:IIngredient
{
public string IngredientName { get; set; }
public double Quantity { get; set; }
public string Units { get; set; }
public string Quality { get; set; }
}
class Butter : IIngredient
{
public string IngredientName { get; set; }
public double Quantity { get; set; }
public string Units { get; set; }
}
class Sugar : IIngredient
{
public string IngredientName { get; set; }
public double Quantity { get; set; }
public string Units { get; set; }
public string Kind { get; set; }
}
class Creme: IIngredient
{
public string IngredientName { get; set; }
public double Quantity { get; set; }
public string Units { get; set; }
public double Fat { get; set; }
}

The list of ingredients may vary in different recipes and confections, but this list is enough for our recipe.

And now it’s time to move on to the concept of a recipe. Whatever we cook, we know what it’s called, what it is, what ingredients are included in the dish and how to cook it.

interface IRecipe
{
Type PastryType { get; set; }
string Name { get;set;}
IList<IIngredient> Ingredients { get;set;}
string Description { get;set;}
}

A specific class representing a birthday cake recipe looks like this:

class BirthdayCakeRecipe : IRecipe
{
public Type PastryType { get; set; }
public string Name { get;set;}
public IList<IIngredient> Ingredients { get; set; }
public string Description { get; set; }

public BirthdayCakeReipe()
{
Ingredients = new List<IIngredient>();
}
}

Now we get back to our wonderful bakery on the corner of the street.

Of course, we could apply to many other bakeries, so we define the basic interface for any of them. And what is most important for a bakery? The ability to bake of course ;)

interface IBakery
{
IPastry Bake(IRecipe recipe);
}

And here is the class for our bakery:

class NiceBakeryOnTheCornerOFMyStreet
{
Dictionary<string, IRecipe> menu = new Dictionary<string, IRecipe>();

{
{
}
else
{
}
}

{
{
}
Console.WriteLine("Sorry...currently we don't have " + name);
return null;
}
public IPastry Bake(IRecipe recipe)
{
if (recipe != null)
{
IPastry pastry = Activator.CreateInstance(recipe.PastryType) as IPastry;
if (pastry != null)
{
pastry.Name = recipe.Name;
return pastry as IPastry;
}
}
return null;
}
}

All we need to do now is to test our code:

class Program
{
static void Main()
{
//creating an inctance of the bakery class
var bakery = new NiceBakeryOnTheCornerOFMyStreet();

//preparing ingredients for the recipe
var flour = new Flour() { IngredientName = "Flour",
Quantity = 1.5, Units = "kg" };
var butter = new Butter() { IngredientName =
"Butter", Quantity = 0.5, Units = "kg" };
var sugar = new Sugar() { IngredientName = "Sugar",
Quantity = 0.7, Units = "kg" };
var creme = new Creme() { IngredientName= "Creme",
Quantity = 1.0, Units = "liters" };

//and this is the recipe itself
var weddingCakeRecipe = new BirthdayCakeRecipe() {
PastryType = typeof( BirthdayCake), Name = "Birthday Cake Luxury",
Description = "description on how to make a beautiful birthday cake" };

//now let's order it!!
BirthdayCake cake =

cake.NumberOfCandles = 10;

//and here we are!!!
Console.WriteLine(cake);
}
}

Now let’s look at all the code above once again and make a conclusion. A simple code structure, clearly delineated types, use of abstraction encapsulation data and functionality, the code provides extensibility and reusability. Each segment can safely be replaced, and it does not ruin the rest of the code.

It is possible to add as many new types of ingredients, recipes for confectioneries, create other classes describing bakeries, pastry shops and other similar shops.

We got a good result. And all thanks to the fact that we implemented the low cohesion between the types.

And now let’s see what consequences we will have in the case of breaking the dependency inversion principle:

1. First, stiffness (in it would be very difficuld to make some changes in code, because every change would affect many different parts of it).

2. Second, fragility (if you make any changes to one part of the system, other parts become unstable , and sometimes it’s not too obvious at first glance).

3. Third, immobility (the reuse of code in other systems becomes impossible, because the modules are tightly coupled).

Well, now make your own conclusion on how the use of dependency inversion principle can be useful for your code. I think it is pretty obvious.

You must be logged in to reply to this topic.


text:
Physics

Simplify and round to the appropriate number of significant digits$(a)$ $16.235 \times 0.217 \times 5$ $(b)$ $0.00435 \times 4.6$

SOLUTION
Ans a-
$16.235 \times 0.217 \times 5 = 17.614975$
Since the least no.of significant digit is one, so the final answer should be rounded off upto one significant digit.
Therefore, Ans is $20$

Ans b-
$0.00435 \times 4.6 = 0.02001$
Since the least no.of significant digit is two, so the final answer should be rounded off upto two significant digit.
Therefore, Ans is $0.02$

You're just one step away

Subjective Medium Published on 18th 08, 2020
Questions 244531
Subjects 8
Chapters 125
Enrolled Students 218

Realted Questions

Q1 Single Correct Medium
Which has least count of 0.001 cm. The number of division through which zero mass has crossed the refrence line is 2. The zero error is-
• A. 0.005
• B. -0.005 cm
• C. +0.02
• D. + 0.02 cm

Asked in: Physics - Units and Measurement

1 Verified Answer | Published on 18th 08, 2020

Q2 Single Correct Hard
If the velocity of light $C$, the universal gravitational constant $G$, and Planck's constant $h$ are chosen as fundamental units, the dimension of mass in this system are
• A. $h^{1/2}C^{1/2}G^{-1/2}$
• B. $h^{-1}C^{-1}G$
• C. $hCG^{-1}$
• D. $hCG$

Asked in: Physics - Units and Measurement

1 Verified Answer | Published on 18th 08, 2020

Q3 Single Correct Medium
Two resistances $r_1=(5.0\pm 0.2)\Omega$ and $r_2=(10.0\pm 0.1)\Omega$ are connected in parallel. Find the value of equivalent resistance with limits of percentage error.
• A. $r_p=4\Omega\pm$7%
• B. $r_p=3.3\Omega\pm$14%
• C. $r_p=3.3\Omega\pm$3.5%
• D. $r_p=3.3\Omega\pm$7%

Asked in: Physics - Units and Measurement

1 Verified Answer | Published on 18th 08, 2020

Q4 Multiple Correct Medium
Which of the following groups have the same dimensions ?
• A. velocity, speed
• B. pressure, stress
• C. force, impulse
• D. work, energy

Asked in: Physics - Units and Measurement

1 Verified Answer | Published on 18th 08, 2020

Q5 Subjective Medium
What is the unit of amount of a substance?

Asked in: Physics - Units and Measurement

1 Verified Answer | Published on 18th 08, 2020


text:
# Repositioning and resizing when i change the size of my window

I am trying to write a game.

When someone resizes the window of my game, I need all the graphics i have drawn on the screen to reposition correctly so that the ratio of the graphics' width and height remain correct and that the new position determined by x and y, have been adjusted for the new size screen.

In the following image, the top left corner is 0,0... all coordinates / widths / heights are measured from this point.

What do I need to do to x, y, width and height from the variable width and height of my screen in order to keep this aspect ratio correct?

SIDE NOTE: the aspect ratio of the screen will always be 16:9!

• math.stackexchange.com/questions/419838/… – Tetrad Jun 14 '13 at 15:32
• @Tetrad - I'm not sure this really needs to be referenced here. The answer comes out as the same. It really was for my benefit only. I was struggling because I was using Byte56 technique before I came here but was confused that it wasn't working... I posted on the math forum to make sure I wasn't be a complete noob. then posted here to see why my code was not working. I successfully got the answer to both questions and then could see that it was that I was not re-declaring the size of the backbuffer thus it was incorrectly scaling it rather than it being the technique. – Jimmyt1988 Jun 15 '13 at 0:25

## 1 Answer

You have two values to work with, the change in X (dx) and the change in Y (dy) (really the ratio between the two sizes). When changing from one size to another while maintaining the same aspect ratio, dx and dy will be very close to each other (slight differences due to the integer aspect of pixel counts).

So, in your example:

dx = 1376/1920 = .716
dy = 768/1080 = .711

This is a factor you'll apply to size and position values to scale them to the new screen. So again, in your example, your box would be changed in size:

100*.716 = 71.6
100*.711 = 71.1

And the position would likewise change:

1850*.716 = 1325.8
20*.711 = 14.2

The general formula being:

NewPosition.x = (NewScreenWidth/OldScreenWidth) * CurrentPosition.x;
NewPosition.y = (NewScreenYHeight/OldScreenHeight) * CurrentPosition.y;

NewSize.x = (NewScreenWidth/OldScreenWidth) * OldSize.x;
NewSize.y = (NewScreenHeight/OldScreenHeight) * OldSize.y;

• do you mean NewPosition.x = ( newScreenWidth / oldScreenWidth ) * currentPosition.x? – Jimmyt1988 Jun 14 '13 at 0:09
• Nice one thanks. Makes sense. Let me finish putting in the code into my game and i'll tick it off! – Jimmyt1988 Jun 14 '13 at 0:13
• Cheers for the code. I had some issues and then found out that I have to redeclare the back buffer size too.. And then wow does it work. Hurrahh – Jimmyt1988 Jun 15 '13 at 0:15
• Great! Glad it's working. Good luck with your game! Come by chat and tell us about it sometime. – MichaelHouse Jun 15 '13 at 0:35
• What happens if the aspect ratios of old width and new width and old height and new height differ? for example 1920 x 1200 down to 1920 x 1080. what do you normally do then? – Jimmyt1988 Jul 2 '13 at 23:01


text:
# Simulating image transfer over noisy channel with a repetition code

I need to write a software in JAVA which allows me to simulate the transfer of some images over a noisy channel while adding redundancy with a repetition code . Before going into code details and issues, here are some requirements:

• read files from a directory containing images
• for each file, apply a repetition code (with n repetitions, user input)
• for each file, send the result of the repetition code on a simulated channel with a given error probability. This means reading each bit and flipping it if we have an error
• for each file, decode the file received from the channel and save it back as image

The parameters for the simulation are:

• Files' folder
• Number of repetitions
• Error probability (as coefficient^exponent)
• Output folder

I ended up organizing the project with these classes:

• NoisyChannel - simulates the channel by reading a String of bits and applying the error based on some error model
• SingleError - implements the single error model, meaning that we have a bit error if exponent times we generate a random number which is <=0.1
• RepetitionCoder - applies the repetition code by taking the bit String, generating a char[stringLength*repetitions] array and filling it with the generated repetitions (010 with 3 repetitions will turn to 000111000)
• RepetitionDecoder - decodes the bit String by splitting it every repetitions characters and applying a majority vote to each substring. The majority vote returns the most frequent character from the substring (001 will have 0 as result of the mjority vote)
• Converter - utility class that contains methods to convert a byte[] to a bit String and the other way around

Now that you have a little bit of background, here's my problem: the simulation is really slow!

I've tried with 15 images with a size of 2.2MB each (so roughly 30MB of data) and 5 repetitions and it took around 8 minute to complete, which is way too high for me (running on an i5-4670 3.4GHz, 16GB 1333MHz dual-channel RAM, files stored on an USB3.0 external drive because I don't want to mess with my SSD)

This is why I need your help to try to speed things up.

TestLoop

for (int i = 0; i < 15; i++) {
String inputString = Converter.byteArrayToBitString(input);
int repetitions = 5, coefficient = 10, exponent = -3;
// Repetitions (encoding)
RepetitionCoder coder = RepetitionFactory.createRepetitionCoder(repetitions);
String repCoderOutput = coder.encode(inputString);
// Noisy channel
BaseError error = ErrorFactory.createError(coefficient, exponent);
NoisyChannel channel = new NoisyChannel(error);
String channelOutput = channel.transfer(repCoderOutput);
// Repetitions (decoding)
RepetitionDecoder decoder = RepetitionFactory.createRepetitionDecoder(repetitions);
String repDecoderOutput = decoder.decode(channelOutput);
byte[] output = Converter.bitStringToByteArray(repDecoderOutput);
Files.write(new File("D:\\testFrame_2.jpg").toPath(), output);
}

Converter.byteArrayToBitString

public static String byteArrayToBitString(byte[] source) {
StringBuilder sb = new StringBuilder(8 * source.length);
for (byte b : source) {
sb.append(byteToBitString(b));
}
return sb.toString();
}

RepetitionCoder.encode

public String encode(String bitString){
return repeat(bitString);
}

private String repeat(String bitString) {
StringBuilder sb = new StringBuilder(bitString.length() * repetitions);
for (char c : bitString.toCharArray()) {
char[] chars = new char[repetitions];
Arrays.fill(chars, c);
sb.append(chars);
}
return sb.toString();
}

NoisyChannel.transfer

public String transfer(String input) {
char[] bits = input.toCharArray();
for (int i = 0; i < bits.length; i++) {
}
return new String(bits);
}

protected char addError(char source) {
return (isError()) ? flipBit(source) : source;
}

protected boolean isError() {
for (int i = 0; i < Math.abs(exponent); i++) {
if (Math.random() >= 0.1) {
return false;
}
}
return !(coefficient > 0 && Math.random() >= coefficient / 10);
}

protected char flipBit(char bit) {
return (bit == '0') ? (char) 49 : (char) 48;
}

RepetitionDecoder.decode

public String decode(String bitString) {
String[] repetitionsString = splitStringEvery(bitString, repetitions);
StringBuilder sb = new StringBuilder(repetitionsString.length);
for (String rep : repetitionsString) {
sb.append(majorityVote(rep));
}
return sb.toString();
}

private String[] splitStringEvery(String s, int interval) {
int arrayLength = (int) Math.ceil(((s.length() / (double) interval)));
String[] result = new String[arrayLength];

int j = 0;
int lastIndex = result.length - 1;
for (int i = 0; i < lastIndex; i++) {
result[i] = s.substring(j, j + interval);
j += interval;
}
result[lastIndex] = s.substring(j);

return result;
}

private char majorityVote(String buffer) {
int zeroes = (int) buffer.chars().filter(b -> b == 48).count();
return (zeroes > repetitions / 2) ? '0' : '1';
}

Converter.bitStringToByteArray

public static byte[] bitStringToByteArray(String string) {
byte[] result = new byte[string.length() / 8];
for (int i = 0; i < string.length(); i += 8) {
String subString = string.substring(i, i + 8);
result[i / 8] = bitStringToByte(subString);
}
return result;
}

Any idea on how to speed things up while keeping a good readability? Considered that I need to work with 500+ images, wasting 8 minutes every 15 images leads to huge times.

EDIT:

Created the follow-up question as suggested.

• Hoy! You cannot edit your code in the question as this would invalidate existing answers. If you want us to review your new code, please post a follow up question! Thanks :) – IEatBagels Dec 16 '15 at 18:56
• I thought that revision history was enough if somebody wanted to see the old code. How am I supposed to post a follow up question? Is it just a new question with maybe a link back here? – StepTNT Dec 16 '15 at 19:31
• Exactly! And the edit history isn't there for this purpose. – IEatBagels Dec 16 '15 at 19:45

• Originally I used ByteArrayInputStream and ByteArrayOutputStream but I ended up having issues in the RepetitionCoder.decode method and I had to switch to String. Can you please expand your reply with some code? I've been working on this for the last 2 weeks and my head is hurting now :( – StepTNT Dec 15 '15 at 14:55
• I forgot to add that the error is on bit level so I need to call isError 8 times for each byte. – StepTNT Dec 16 '15 at 10:18


text:
LHC

2015-02-12
15:18
 Accelerator Quality HTS Dipole Magnet Demonstrator Designs for the EuCARD-2, 5 Tesla 40 mm Clear Aperture Magnet / Kirby, GA (CERN) ; van Nugteren, J (CERN) ; Ballarino, A (CERN) ; Bottura, L (CERN) ; Chouika, N (CERN) ; Clement, S (CERN) ; Datskov, V (CERN) ; Fajardo, L (CERN) ; Fleiter, J (CERN) ; Gauthier, R (CERN) et al. Future high-energy accelerators will need very high magnetic fields in the range of 20 T. [...] CERN-ACC-2015-0024. - 2015. - 6 p. Full text

2015-02-12
14:58
 Coil End Optimization of the Nb3Sn Quadrupole for the High Luminosity LHC / Izquierdo Bermudez, S ; Ambrosio, G ; Bossert, R ; Cheng, D ; Ferracin, P ; Krave, ST ; Perez, JC ; Schmalzle, J ; Yu, M As part of the Large Hadron Collider Luminosity upgrade (HiLumi-LHC) program, the US LARP collaboration and CERN are working together to design and build a 150 mm aperture quadrupole magnet that aims at providing a nominal gradient of 140 T/m. [...] CERN-ACC-2015-0023. - 2015. - 6 p. Full text

2015-02-10
17:41
 Elastic anisotropy in multifilament Nb3Sn superconducting wires / Scheuerlein, C ; Fedelich, B ; Alknes, P ; Arnau, G ; Bjoerstad, R ; Bordini, B The elastic anisotropy caused by the texture in the Nb3Sn filaments of PIT and RRP wires has been calculated by averaging the estimates of Voigt and Reuss, using published Nb3Sn single crystal elastic constants and the Nb3Sn grain orientation distribution determined in both wire types by Electron Backscatter Diffraction. At ambient temperature the calculated Nb3Sn E-moduli in axial direction in the PIT and the RRP wire are 130 GPa and 140 GPa, respectively. [...] CERN-ACC-2015-0022.- Geneva : CERN, 2015 - 5 p. Fulltext: PDF; In : Applied Superconductivity Conference 2014, Charlotte, NC, USA, 10 - 15 Aug 2014, pp.ASC 2014

2015-02-10
08:13
 Steady state heat transfer experimental studies of LHC superconducting cables operating in cryogenic environment of superfluid helium / Santandrea, Dario The heat management is a basic and fundamental aspect of the superconducting magnets used in the CERN Large Hadron Collider [...] CERN-THESIS-2014-248 - 101 p.

Fulltext
2015-02-09
16:39
 Transverse beams stability studies at the Large Hadron Collider / Buffat, Xavier A charged particle beam travelling at the speed of light produces large electromagnetic wake fields which, through interactions with its surroundings, act back on the particles in the beam [...] CERN-THESIS-2014-246 - Lausanne : Ecole Polytechnique, Lausanne, 2015-01-30. - 210 p.

Fulltext
2015-02-09
11:50
 Targets for R&D on Nb3Sn conductor for High Energy Physics / Ballarino, A (CERN) ; Bottura, L (CERN) High Energy Physics has been consistently pushing the performance of technical superconductors, for the benefit of high field magnet technology. So far the workhorse for particle accelerators has been Nb-Ti, but the practical performance limit has been attained with the LHC. [...] CERN-ACC-2015-0021.- Geneva : CERN, 2015 - 6 p. Fulltext: PDF; In : Applied Superconductivity Conference 2014, Charlotte, NC, USA, 10 - 15 Aug 2014, pp.ASC 2014

2015-02-09
11:03
 Coupling Current and Hysteresis Losses of Bi2212 Round Wires with Twisted Filaments / Yang, I (-) ; Pelegrin, J (-) ; Young, EA (-) ; Falorio, I (-) ; Ballarino, A (CERN) ; Bottura, L (CERN) ; Miao, H (-) ; Huang, Y (-) AC loss measurements have been carried out on Bi2212 round wires of different twist pitches. With systematical variation of sample temperature (5 K – 70 K) and ac field amplitude (≤0.2 T) as well as frequency (20 Hz – 2 kHz), this work shows (a) the full coupling of the non-twisted wire, (b) the uncoupling of sub-wires by twisting at moderate pitch up to 12 mm, (c) a relatively short time constant of milliseconds for the coupling current due to a high transverse resistivity, and (d) an effective (de)coupling diameter of 0.4mm about 1.6x of sub-wire bundles. [...] CERN-ACC-2015-0020.- Geneva : CERN, 2015 - 5 p. Fulltext: PDF; In : Applied Superconductivity Conference 2014, Charlotte, NC, USA, 10 - 15 Aug 2014, pp.ASC 2014

2015-02-04
11:32
 The High Luminosity Challenge: potential and limitations of High Intensity High Brightness in the LHC and its injectors / De Maria, R (CERN) ; Arduini, G (CERN) ; Banfi, D (CERN) ; Barranco, J (CERN) ; Bartosik, H (CERN) ; Benedetto, E (CERN) ; Bruce, R (CERN) ; Brüning, O (CERN) ; Calaga, R (CERN) ; Cerutti, F (CERN) et al. High-intensity and high-brightness beams are key ingredients to maximize the LHC integrated luminosity and to exploit its full potential. [...] CERN-ACC-2015-0018. - 2014. - 5 p. Full text

2015-01-27
15:23
 Ion Colliders / Fischer, W (Brookhaven National Laboratory, Upton, New York 11973, USA.) ; Jowett, J M (CERN, CH-1211 Geneva 23, Switzerland.) High-energy ion colliders are large research tools in nuclear physics to study the Quark-Gluon-Plasma (QGP). The range of collision energy and high luminosity are important design and operational considerations. [...] CERN-ACC-2015-0015.- Geneva : CERN, 2015 Fulltext: PDF;

2015-01-21
09:15
 Development of high $\beta^*$-optics for ALICE / Hermes, Pascal Dominik This thesis describes a feasibility study for a special optical configuration in Insertion Region 2 (IR2) of the Large Hadron Collider (LHC), which is host of the ALICE detector [...] CERN-THESIS-2013-370 - 114 p.

Fulltext


text:
# 【Acm】算法之美—Crashing Balloon

On every  June 1st, the Children's Day, there will be a game named "crashing balloon" on  TV.   The rule is very simple.  On the ground there are 100 labeled balloons,  with the numbers 1 to 100. After the referee shouts "Let's go!" the two  players, who each starts with a score of  "1", race to crash the balloons by  their feet and, at the same time, multiply their scores by the numbers written  on the balloons they crash.  After a minute, the little audiences are allowed to  take the remaining balloons away, and each contestant reports his\her score, the  product of the numbers on the balloons he\she's crashed.  The unofficial winner  is the player who announced the highest score.

Inevitably,  though, disputes arise, and so the official winner is not determined until the  disputes are resolved.  The player who claims the lower score is entitled to  challenge his\her opponent's score.  The player with the lower score is presumed  to have told the truth, because if he\she were to lie about his\her score,  he\she would surely come up with a bigger better lie.  The challenge is upheld  if the player with the higher score has a score that cannot be achieved with  balloons not crashed by the challenging player.  So, if the challenge is  successful, the player claiming the lower score wins.

So, for  example, if one player claims 343 points and the other claims 49, then clearly  the first player is lying; the only way to score 343 is by crashing balloons  labeled 7 and 49, and the only way to score 49 is by crashing a balloon labeled  49.  Since each of two scores requires crashing the balloon labeled 49, the one  claiming 343 points is presumed to be lying.

On the  other hand, if one player claims 162 points and the other claims 81, it is  possible for both to be telling the truth (e.g. one crashes balloons 2, 3 and  27, while the other crashes balloon 81), so the challenge would not be  upheld.

By the  way, if the challenger made a mistake on calculating his/her score, then the  challenge would not be upheld. For example, if one player claims 10001 points  and the other claims 10003, then clearly none of them are telling the truth. In  this case, the challenge would not be upheld.

Unfortunately,  anyone who is willing to referee a game of crashing balloon is likely to get  over-excited in the hot atmosphere that he\she could not reasonably be expected  to perform the intricate calculations that refereeing requires.  Hence the need  for you, sober programmer, to provide a software solution.

Pairs of  unequal, positive numbers, with each pair on a single line, that are claimed  scores from a game of crashing balloon.

Output

Numbers,  one to a line, that are the winning scores, assuming that the player with the  lower score always challenges the outcome.

Sample  Input

343 49

3599 610

62 36

Sample  Output

49

610

62

这也是一个很有意思的题,不认真读题,可能还不太明白.我来简单翻译一下

可是分数低的人不服气,想申诉.现在问题来了,怎么申诉呢?因为每个标号的球只有一个,所以加入B踩破的话,A就没办法踩了,申诉想要产生的矛盾就在这儿.现在假如分数是 343 49 ,343可以是踩了 7和49,49只能是踩49,他们两都同时必须要踩这个49,那么就产生矛盾了.所以49赢了.还有要是有人的分数,不能由1->100的数的成绩的出,算说假话,如果两个人都说假话,还是分高的赢.

有三种情况:

(1)A,B没有矛盾,那么A赢

(2)A,B怎么都会有矛盾,而且B说的是真话,那么B赢

(3)A,B怎么都会有矛盾,而且B说的是假话,那么A赢

下面的源代码中，我对主要的代码都作了详细的注释，如题

#include < stdio.h>
int flagA,flagB;
int result ;
void dfs(int m,int n,int kk)    //运用了深度优先 的搜索策略
{
int k =kk;
if(m==1 && n==1)    //在两个数的所有各不相同的因子中，有因子能重新乘出给出的两个数，则A说了真话
{
flagA=1; //A说了真话
return ;
}
if(n==1) //在两个数的所有各不相同的因子中，没有任何因子能重新乘出给出的两个数，则B说了真话
flagB =1;   //B说了真话
while( (k <  m || k <  n) && (k< 100) )
{
k++;
/*
*依次找出两个数所有各不相同的因子，如24和12的所有因子为 2，3，4，6，8，12 ，
再在这些因子中搜索，看是否能重新乘出给出的两个数
*/
if(m%k ==0)
{
dfs(m/k,n,k);
if(flagA)
return ;
}
if(n%k ==0 )
{
dfs(m,n/k,k);
if(flagA)
return ;
}
}
}
int main()
{
int A,B,t;
while(scanf("%d%d",&A,&B)!=EOF )
{
if(A <  B )  //保证A大B小
{
t=A;
A=B;
B=t;
}
flagA =0;   //先假定AB都说假话
flagB =0;
dfs(A,B,1); //判断AB矛盾
/*
*要求:
*较小者发起挑战，若较大者被证明说谎，较小者胜（较小者说真话，同时较大者说了假话）;
*若较大者可以成立，则较大者胜;
*若较小者对自己的结果计算错误，也就是较小者不能成立，如因子中包含一个大于100的质数，则挑战不会举行，较大者胜
*/
result =A;
if(flagA ==0 && flagB ==1)  //只有证明A说了假话，并且B说了真话，才算B赢
result =B;
printf("%d\n",result);
}
return 0;
}

QQ联系方式：lcw@v.gg

posted @ 2013-06-27 17:38  Leo.cheng  阅读(1354)  评论(0编辑  收藏  举报


text:
Home > Option Clash > Latex Error Option Clash For Package Graphicx

# Latex Error Option Clash For Package Graphicx

Name spelling on publications Take a ride on the Reading, If you pass Go, collect $200 How does a Spatial Reference System like WGS84 have an elipsoid and a geoid? Farming after the apocalypse: chickens or giant cockroaches? more hot questions lang-tex about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation Science Other Uncertainty principle How to deal with a coworker who is making fun of my work? http://jvmwriter.org/option-clash/latex-error-option-clash-for-package-graphicx-pdfpages.html more hot questions question feed lang-tex about us tour help blog chat data legal privacy policy work here advertising info mobile contact us feedback Technology Life / Arts Culture / Recreation You meant to say it is always "safe" right, besides using the word "save"? :) –night owl Aug 14 '11 at 6:52 @night owl: uuh, always the same problem: asked 5 years ago viewed 6105 times active 5 years ago Get the weekly newsletter! LaTeX Error: Option clash >>> for package graphicx**. >>> Obviously , graphicx has been loaded before \usepackage[dvips]{graphix}. >> >> Yes, looks like. >> >>> However , it compiles fine in Funtoo, ## Option Clash For Package Graphicx Pdftex Red balls and Rings What would happen if the light-speed was higher? To simplify the problem and still keep the situation I come across: files: test.tex and sequence.1(generated by metapost) 1.$ cat test.tex \documentclass[11pt]{article} \usepackage{fontspec} \usepackage{listings} \usepackage{color} %\usepackage[BoldFont,SlantFont,CJKchecksingle]{xeCJK} \usepackage{amsmath} \usepackage[dvips]{graphicx} \begin{document} foo\\ Why won't a series converge if the limit of the sequence is 0? Public huts to stay overnight around UK Why do people move their cameras in a square motion?

How should I deal with a difficult group and a DM that doesn't help? Is there a difference between u and c in mknod C++ delete a pointer (free memory) Is it correct to write "teoremo X statas, ke" in the sense of "theorem X Join them; it only takes a minute: Sign up Here's how it works: Anybody can ask a question Anybody can answer The best answers are voted up and rise to the If a package has been loaded, another \usepackage without any options will be safely ignored, but a \usepackage with some options will produce an option clash.

What to do with my out of control pre teen daughter more hot questions question feed lang-tex about us tour help blog chat data legal privacy policy work here advertising info Also avoid passing the option pdftex to the package graphicx. Sieve of Eratosthenes, Step by Step What are the legal consequences for a tourist who runs out of gas on the Autobahn? Can any >>> maintainer point something out for >>> me? >> >> I tried with this document: > [...] >> and got no error and this log: > > Rubbish, that

Linked 31 Option clash with xcolor and TikZ Related 31Option clash with xcolor and TikZ6Where to get help for the package options?8Loading package twice with \RequirePackage causes “option clash”2How to circumvent tikz package loads xcolor internally without any options. Is it possible to keep publishing under my professional (maiden) name, different from my married legal name? Farming after the apocalypse: chickens or giant cockroaches?

## Option Clash For Package Graphicx. \graphicspath

How exactly std::string_view is faster than const std::string&? http://tex.stackexchange.com/questions/25664/conflict-between-options-of-packages Browse other questions tagged incompatibility package-options option-clash or ask your own question. Option Clash For Package Graphicx Pdftex Why does Mal change his mind? Latex Error Cannot Determine Size Of Graphic In No Boundingbox Can an umlaut be written as a line in handwriting?

What is the difference (if any) between "not true" and "false"? http://jvmwriter.org/option-clash/latex-error-option-clash-for-package-xcolor.html This was some very enlightening info to know and explanation was on point. A tip: If you indent lines by 4 spaces, they'll be marked as a code sample. These options will be passed to any later packages if possible. Includegraphics Latex

more stack exchange communities company blog Stack Exchange Inbox Reputation and Badges sign up log in tour help Tour Start here for a quick overview of the site Help Center Detailed You can either set the option as an option to \documentclass, or use \PassOptionsToPackage{export}{adjustbox} in the preamble. Equation which has to be solved with logarithms Why is JK Rowling considered 'bad at math'? navigate here asked 1 year ago viewed 800 times active 1 year ago Get the weekly newsletter!

Referee did not fully understand accepted paper Why aren't there direct flights connecting Honolulu, Hawaii and London, UK? I have followed suggestions, but nothing seems to be working fine. Can I stop this homebrewed Lucky Coin ability from being exploited?

## I don’t understand an option clash15Package options and \RequirePackage: order of commands and option conflicts?35Option clash for package xcolor3How can I set the 'final' option for the graphicx package in XeTeX?17What

In it, you'll get: The week's top questions and answers Important community announcements Questions that need answers see an example newsletter By subscribing, you agree to the privacy policy and terms Why aren't there direct flights connecting Honolulu, Hawaii and London, UK? Previous company name is ISIS, how to list on CV? The problem is more tricky if your document class loads a package you want options for.

Is a food chain without plants plausible? How to know if a meal was cooked with or contains alcohol? You can get rid of the clashes by one of these methods: Use \PassOptionsToPackage{table}{xcolor} right before the \documentclass[11pt,a4paper]{article}. his comment is here How to deal with a coworker who is making fun of my work?


text:
mersenneforum.org Software for finding prime constellations
 Register FAQ Search Today's Posts Mark Forums Read

 2022-08-15, 21:03 #1 CRGreathouse     Aug 2006 10111011000112 Posts Software for finding prime constellations Suppose I have an admissible tuple (0, n_1, n_2, ..., n_{k-1}) and I am interested in finding instances of this constellation: numbers N such that N, N + n_1, ..., N + n_{k-1} are all prime. Is there software out there to do this search efficiently? In my immediate case, k = 19.
 2022-08-15, 21:05 #2 CRGreathouse     Aug 2006 5,987 Posts https://arxiv.org/abs/1807.08777 is relevant, but I don't know of any implementations.
 2022-08-15, 21:27 #3 a1call     "Rashid Naimi" Oct 2015 Remote to Here/There 2,287 Posts 1st SM and now Mr. Greathouse. Are the stars lining up somewhere? My 2 cents: PFGW it’s the most efficient primality tester and you can script it so that it checks the 1st then and if and only if Prime would test next and so on. It inserts a noticeable line in the output when all items match (are Prime). It lacks an advanced sieving feature but you can (I have successfully, so should be a piece of cake for you) combine Pari-gp script and initiate pfgw when a sieved candidate is found. Obvious not telling you anything new, why would you look for another software? Nice to have you posting again. The forum had deteriorated without your inputs. Last fiddled with by a1call on 2022-08-15 at 21:59
 2022-08-16, 09:41 #4 MattcAnderson     "Matthew Anderson" Dec 2010 Oregon, USA 3·17·23 Posts I don't know of a good software for searching for k-tuples I wrote some Maple code to find the smallest few k-tuples for k= 7,8,9,10,11,12,13. back in 2015 My Maple code and some prime k-tuples appear in OEIS.org Dana Jacobsen and Norman Luhn have extended these lists (and others) A link to this work is on my personal webpage https://mattanderson.fun/f/prime-constellations Also, Norman Luhn has a web page with lists of prime k-tuples, and the form that these numbers have. see - https://pzktupel.de/ktpatt_hl.php for example, form Norman's webpage, about 19-tuples, if the 19-tuple is {0 4 6 10 16 22 24 30 34 36 42 46 52 60 64 66 70 72 76} then the smallest prime in the constellation will have the form 37 (modulo 30030) I read this off the chart at pzktupel.de/ktpatt_hl.php There are 4 patterns for 19-tuples that are also prime constellations. They are shown on the chart. Currently, there is no known prime 19-tuple with pattern {0 4 6 10 12 16 24 30 34 40 42 46 52 54 60 66 70 72 76} Initial primes in this 19-tuple will have the form 29917 (modulo 30030) I pulled this information from this webpage https://pzktupel.de/SMArchiv/smadditions.html Maple code is slow, but easy for me to write code. I sped up the Maple isprime() function by first testing if a number has any factors less than 100, then, if all candidates of the k-tuple pass that test, run the full isprime() function on all 'k' of the possible primes. See my code for 10-tuples here http://oeis.org/A027569 Good luck on being the first to find this 19-tuple. I don't know of any downloadable software for finding admissable k-tuples. Norman Luhn has his software but it is not ready to be shared. Also, if someone can find a certain 447-tuple, they can show a counterexample to a conjecture of Hardy and Littlewood. see - http://www.opertech.com/primes/k-tuples.html Best of luck, and have a nice day.
2022-08-16, 11:56   #5
Dr Sardonicus

Feb 2017
Nowhere

2×29×103 Posts

Quote:
 Originally Posted by CRGreathouse Suppose I have an admissible tuple (0, n_1, n_2, ..., n_{k-1}) and I am interested in finding instances of this constellation: numbers N such that N, N + n_1, ..., N + n_{k-1} are all prime. Is there software out there to do this search efficiently? In my immediate case, k = 19.
If you go to cybertronic's pzktupel site, you'll find some 19-tuples (and some longer ones) listed, along with who found them and when. Perhaps he could point you in the right direction.

 2022-08-16, 19:11 #6 mart_r     Dec 2008 you know...around... 11001010002 Posts AFAIK, Norman Luhn, Jens Kruse Andersen and others all use highly customized code. My code for the 13-tuples some years ago also was highly customized, written in Basic, and too slow for 19-tuplets. I haven't yet seen any general-purpose efficient software specifically for large k-tuples, but if there is one, I would also be interested
 2022-08-17, 18:45 #7 mart_r     Dec 2008 you know...around... 23·101 Posts Houston, we've got a program. And a problem. I've written a Pari program that captures the gist of the most important steps in a k-tuple finding algorithm. Problem is, it is quite slow. Finding 12- or 13-tuples can take several minutes, so it's most likely not suitable for 19-tuples. Code: print("ktuple(pattern as vector): tries to find tuples of primes with given pattern"); ktuple(p)= { h=2048; \\ lower bound in number of pre-wheel-sieved values - can be changed manually if so desired z=2^16; \\ trial division limit; tuples larger than z^2 get TD'd up to z, after that, numbers are checked sequentially if prime - can also be changed if necessary p=vecsort(p); \\ just in case pattern is not strictly increasing \\ check if pattern is admissible (a=1:yes, a=0:no) a=1; forprime(q=2,#p, v=vector(q); for(i=1,#p, v[q-p[i]%q]=1 ); v=vecsort(v); if(v[1]==1, print("pattern is not admissible / all residues mod "q" are covered"); a=0; break() ) ); \\ find starting point s and difference pattern d; wheel of length q# for first q such that #d > h if(a, s=p[1]%2+1; d=[2]; q=1; m=2; while(#d1, print1("s") ); print(" in wheel of length "m) ); print(); \\ residue patterns in vectors w=p[#p]-p[1]; o=vector(w); for(i=1,#p-1, o[p[#p]-p[i]]=1 ); l=primepi(w)-primepi(q); q=nextprime(q+2); if(l>0, g=vector(w); n=vector(l); k=0; forprime(c=q,w, k++; g[c]=k; n[k]=vector(c); for(i=1,#p-1, j=(p[#p]-p[i])%c; if(j, n[k][j]=1 ) ) ) ); s+=p[#p]; f=0; print("searching for primes with {pattern} = "p); \\ main search while(s p=[0,2,6,12,20,30,42,56,72,90,110] %50 = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110] (19:55) gp > ktuple(p) 1 admissible pattern in wheel of length 6 2 admissible patterns in wheel of length 30 6 admissible patterns in wheel of length 210 30 admissible patterns in wheel of length 2310 180 admissible patterns in wheel of length 30030 1440 admissible patterns in wheel of length 510510 12960 admissible patterns in wheel of length 9699690 searching for primes with {pattern} = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110] 180078317 + {pattern} 1278189947 + {pattern} 1761702947 + {pattern} 1829187287 + {pattern} 5862143447 + {pattern} Last fiddled with by mart_r on 2022-08-17 at 18:57 Reason: removed a redundant semicolon
2022-08-18, 04:08   #8
LaurV
Romulan Interpreter

"name field"
Jun 2011
Thailand

10,093 Posts

Quote:
 Originally Posted by CRGreathouse Suppose I have ..
Welcome back!

2022-08-18, 14:57   #9
science_man_88

"Forget I exist"
Jul 2009
Dumbassville

24·3·52·7 Posts

Quote:
 Originally Posted by mart_r Code: print("ktuple(pattern as vector): tries to find tuples of primes with given pattern"); ktuple(p)= { h=2048; \\ lower bound in number of pre-wheel-sieved values - can be changed manually if so desired z=2^16; \\ trial division limit; tuples larger than z^2 get TD'd up to z, after that, numbers are checked sequentially if prime - can also be changed if necessary p=vecsort(p); \\ just in case pattern is not strictly increasing \\ check if pattern is admissible (a=1:yes, a=0:no) a=1; forprime(q=2,#p, v=vector(q); for(i=1,#p, v[q-p[i]%q]=1 ); v=vecsort(v); if(v[1]==1, print("pattern is not admissible / all residues mod "q" are covered"); a=0; break() ) ); \\ find starting point s and difference pattern d; wheel of length q# for first q such that #d > h if(a, s=p[1]%2+1; d=[2]; q=1; m=2; while(#d1, print1("s") ); print(" in wheel of length "m) ); print(); \\ residue patterns in vectors w=p[#p]-p[1]; o=vector(w); for(i=1,#p-1, o[p[#p]-p[i]]=1 ); l=primepi(w)-primepi(q); q=nextprime(q+2); if(l>0, g=vector(w); n=vector(l); k=0; forprime(c=q,w, k++; g[c]=k; n[k]=vector(c); for(i=1,#p-1, j=(p[#p]-p[i])%c; if(j, n[k][j]=1 ) ) ) ); s+=p[#p]; f=0; print("searching for primes with {pattern} = "p); \\ main search while(s p=[0,2,6,12,20,30,42,56,72,90,110] %50 = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110] (19:55) gp > ktuple(p) 1 admissible pattern in wheel of length 6 2 admissible patterns in wheel of length 30 6 admissible patterns in wheel of length 210 30 admissible patterns in wheel of length 2310 180 admissible patterns in wheel of length 30030 1440 admissible patterns in wheel of length 510510 12960 admissible patterns in wheel of length 9699690 searching for primes with {pattern} = [0, 2, 6, 12, 20, 30, 42, 56, 72, 90, 110] 180078317 + {pattern} 1278189947 + {pattern} 1761702947 + {pattern} 1829187287 + {pattern} 5862143447 + {pattern}
Looks like it should be highly paralleled.

2022-08-18, 17:14   #10
mart_r

Dec 2008
you know...around...

23·101 Posts

Quote:
 Originally Posted by science_man_88 Looks like it should be highly paralleled.
Thanks for the reply! You make me happy

Different patterns can be looked at in parallel, but manually setting a starting point would also be nice. Should be no problem for me to implement.
I have a couple more ideas for improvements. But I also have to earn some money, so give me a day or three...

 2022-08-21, 18:42 #11 mart_r     Dec 2008 you know...around... 23·101 Posts Just practicing my programming skills It would still take thousands of years to find a prime novemdecuplet with my program, but it might be useful for small searches and doublechecks. - Working with "concat" was slowing the wheel sieve down. Fixed that, it's now way faster. - The search itself is now also about 20% faster (for medium-sized tuples). And since the wheel can now be made larger, another significant speedup is possible for large tuples. - A starting point can be set. Example: "ktuple([1,3,7,9],10^49)" finds the first quadruplets with 50 digits. - (Did anyone notice that the first member of the input pattern need not be zero? You can also search for quintuplets with pattern [-4,0,2,6,8], for instance.) - Optional write to file and optional output tracking. I've finally learned how to use the input command properly. - There's a lot of room for optimisation by experimenting with different wheel sieve sizes and trial division depths. This is left as an exercise for the user ;) - Any errors or bugs? Feel free to report. Code: ktuple(p,x)= { h=8192; \\ lower bound in number of pre-wheel-sieved values - can be changed manually if so desired z=1024*#p; \\ trial division limit - can also be changed if necessary print1("Write output file "Strchr(34)"ktuple_output.txt"Strchr(34)"? 1:yes / 0:no ");l=input(); print1("Output search status every ___ seconds? (0/default: don't output search status, only tuples) ");j=input(); p=vecsort(p); \\ just in case pattern is not strictly increasing \\ check if pattern is admissible (a=1:yes, a=0:no) a=1; y=vector(#p); forprime(q=2,#p, v=vector(q); for(i=1,#p, y[q]+=1-v[q-p[i]%q]; v[q-p[i]%q]=1 ); v=vecsort(v); if(v[1]==1, print("pattern is not admissible / all residues mod "q" are covered"); a=0; break() ) ); \\ find admissible initial members s[f]; generate wheel of size q# := m for first q such that d := #s[f] >= h if(a, s=[p[1]%2+1]; d=1; q=1; m=2; while(d#p, c=0; v=vector(q); for(i=1,#p, c+=1-v[q-p[i]%q]; v[q-p[i]%q]=1 ) , c=y[q] ); d*=(q-c); t=vector(d); f=0; u=0; e=0; b=1; while(e#s, f=1; u+=m ); for(i=1,#p, b*=sign((u+s[f]+p[i])%q) ); if(b, e++; t[e]=u+s[f] , b=1 ) ); s=t; m*=q; print1(d" admissible pattern"); if(d>1, print1("s") ); print(" in wheel of size "m) ); print(); \\ residue patterns in vectors w=p[#p]-p[1]; o=vector(w); for(i=1,#p-1, o[p[#p]-p[i]]=1 ); f=primepi(w)-primepi(q); q=nextprime(q+2); if(f>0, g=vector(w); n=vector(f); k=0; forprime(c=q,w, k++; g[c]=k; n[k]=vector(c); for(i=1,#p-1, e=(p[#p]-p[i])%c; if(e, n[k][e]=1 ) ) ) ); u=(x\m)*m+p[#p]; if(u==p[#p], print("Patterns with initial member <= "precprime(q-2)" are not shown in the output!"); print(); if(l, write("ktuple_output.txt",Str("Patterns with initial member <= "precprime(q-2)" are not shown in the output!")) ) ); print("Searching for primes with {pattern} = "p); if(l, write("ktuple_output.txt",Str("Searching for primes with {pattern} = "p)) ); \\ main search (stage 1: complete trial division) j=(j*1000\256)*256; t=0; gettime(); while(uj, t=0; print("searching ... "u-p[#p]) ) ) ); \\ main search (stage 2: trial division up to z, then PRP test) while(1, for(f=1,d, x=u+s[f]; b=1; forprime(c=q,w, r=x%c; if(r==0, b=0; break() , if(n[g[c]][r], b=0; break() ) ) ); if(b, forprime(c=w+1,z, r=x%c; if(r==0, b=0; break() , if(r<=w, if(o[r], b=0; break() ) ) ) ); if(b, for(i=1,#p, if(!ispseudoprime(x-p[#p]+p[i]), b=0; break() ) ); if(b, print(x-p[#p]" + {pattern}"); if(l, write("ktuple_output.txt",Str(x-p[#p]" + {pattern}")) ) ) ) ) ); u+=m; if(j, t+=gettime(); if(t>j, t=0; print("searching ... "u-p[#p]) ) ) ) ) }; print("ktuple(pattern as vector [, starting point]): tries to find tuples of primes with given pattern [optionally start at x]")

 Similar Threads Thread Thread Starter Forum Replies Last Post MattcAnderson MattcAnderson 160 2022-07-18 08:34 robert44444uk Prime Gap Searches 45 2022-02-24 18:28 enzocreti enzocreti 3 2020-02-14 12:21 lukerichards Factoring 87 2019-03-28 13:31 CRGreathouse Software 10 2017-07-14 09:45

All times are UTC. The time now is 09:47.

Mon Sep 26 09:47:16 UTC 2022 up 39 days, 7:15, 0 users, load averages: 1.44, 1.49, 1.42


text:
1. Munkres' Topology

Hello,

I'm looking at Munkres' Topology (2nd edition), trying to refresh myself on some of the basics. I'm having an issue with an early Lemma of his (Lemma 13.1), which states:

Let X be a set, and let B be a basis for a topology T on X. Then T equals the collection of all unions of elements of B.

My issue with this is that any topology contains the empty set, but nothing about the definition* of a basis for a topology requires the empty set to be in B. Indeed, Munkres' proof of this Lemma ignores the empty set in T altogether. For this being such a well reputed book, I'm wondering if I'm missing something. Any thoughts?

*Definition of a basis in Munkres:
If X is a set, a basis for a topology on X is a collection B of subsets of X such that:
-For each x in X, there is at least one basis element U in B containing X.
-If x belongs to the intersection of two basis elements U and V, then there is a basis element W containing x such that W is contained in the intersection of U and V.

2. Re: Munkres' Topology

Originally Posted by Diamondlance
I'm looking at Munkres' Topology (2nd edition), trying to refresh myself on some of the basics. I'm having an issue with an early Lemma of his (Lemma 13.1), which states: Let X be a set, and let B be a basis for a topology T on X. Then T equals the collection of all unions of elements of B.
My issue with this is that any topology contains the empty set, but nothing about the definition* of a basis for a topology requires the empty set to be in B. Indeed, Munkres' proof of this Lemma ignores the empty set in T altogether. For this being such a well reputed book, I'm wondering if I'm missing something. Any thoughts?
I do not have a copy of that text. That said, there is a notion of an empty union using an empty indexing set.
That may be what the author has in mind. But that is a guess.

3. Re: Munkres' Topology

When I studied topology my professor gave the same explanation Plato just did for this.

4. Re: Munkres' Topology

Okay, I think that makes sense. So basically the Lemma is saying that $T=\bigcup_{A\subset B}\bigcup_{U\in A}U$, where A may well be empty, even though the empty set may not be in B.

5. Re: Munkres' Topology

don't get lost in the formalism. a base for a topology is just something we can recover the topology by "unioning arbitrary elements of". for example, a base for the standard topology on the real line is the set of all open intervals B = {(a,b): a,b in R}. note that this example includes the empty interval (a,a). you can think of a base as being sort of a generating set for a topology.

note that if we speak of "the topology generated by (a base) B", then whether or not B includes the empty set is largely irrelevant, as every topology includes the empty set.

if B is closed under (finite) intersections, it's clear we automatically get a topology. but B need not be closed under intersections. if not, we have, for any U1,U2 in B:

U1 ∩ U2 = U {Ux in B : Ux ⊂ U1 ∩ U2, x in U1 ∩ U2},

and the definition of a base guarantees the existence of such Ux, for every x in the intersection of U1 and U2, which shows that the intersection of any two elements of B is contained in the set of unions of elements of B.

if U1 and U2 are disjoint, then we indeed have an "empty union" as referred to in the previous posts (because we don't have any x's).