text:
# Stone-age air-force

Story-based background (not essential for question)

The Helawi live at the top of a small plateau with steep cliffs all around. There is a carved stairway from top to bottom that allows only one person to pass at a time. This is ideal for defence but dreadful for attack.

The Fikawi are camped at the bottom of the stairway and have been ambushing members of the Helawi when they emerge.

The Helawi have discovered this and want to attack but if they send warriors in single file, they will be killed by the Fikawi.

The cliffs contain large sheets of high quality mica. The Helawi who see buzzards flying from and to the cliffs, decide to make fixed wings of mica. They will glide down at night and attack the Fikawi from behind.

Notes

There is an overhang that prevents a simple bombardment from above. They can't use ropes because this will disturb the birds roosting on the cliffs and the clamour will spoil the element of surprise.

Non-story-based Question

In theory, could a stone age tribe make an air-force of fixed wing hang-gliders and safely glide from top to bottom of a cliff if the air currents were favourable?

In particular, to keep the stone-age feel, could the wings be made of mica or other mineral-based material?

Assumptions

They have access to leather, wood, animal bones and sinews, flint knives, and large sheets of mica.

Sadly, there is no bamboo in this area - just softwoods such as pine.

Mica

"... micas except glauconite exhibit easily observable perfect cleavage into flexible sheets ..."

"... Micas occuring as large crystals are often called books; these may measure up to several metres across..."

https://www.britannica.com/science/mica

• Mica's Specific strength would be terrible for flying. They would have the best luck with leather wings (which still going to be terrible). In this particular case, Helawi should just rope down from their cliffs in a location where Fikawi don't expect them. – Alexander Feb 14 '19 at 21:03
• "I particularly want to find out about gliders" Sure, but you're asking how to make usable man-carrying gliders out of stone, mica is both far too brittle & far too heavy for what you want to use it for, you might as well ask for suggestions on how to build a hang-glider with wings made from slate or glass. – Pelinore Feb 14 '19 at 21:51
• How big is this tribe? If it's only a few family units, the deaths of several able-bodied young men during the development of such a glider could be devastating. They aren't going to get this right on the first try. – Nuclear Wang Feb 14 '19 at 22:02
• @chaslyfromUK Maybe but that becomes a structural nightmare. It would be hard to build that with a good airfoil shape. The bottom of the wing needs to be as smooth as possible. Might be better to invent plywood and build the whole thing out of wood. – ShadoCat Feb 14 '19 at 22:46
• how bout Unaided Aerial Vehicle(UAV)? I can only think of stone wraps with banana leaves and launch via tree bunch acting like a level system... you complaint about accuracy and precision but mind u this is stone age ;D – user6760 Feb 15 '19 at 1:00

As @Alexander pointed out in his comment, mica would be terrible. To get it thick enough to be strong enough, it would be too heavy.

Wood and canvas work. Just look at the WWII gliders (wiki). Those started out being towed by propeller driven aircraft to get to altitude but you don't need that here.

Here is a list of gliders used by different countries to give you an idea of different design types.

You could also go with simple parachutes.

However, I am concerned that whatever is preventing a dropping rock from hitting the Fikawi on their heads may prevent the gliders from reaching them as well.

• Unfortunately they haven't discovered weaving, especially the fine weaving and varnish needed for a glider. – chasly from UK Feb 14 '19 at 21:59
• @chaslyfromUK, the gliders don't have to be good, they just have to get people down. I'd be tempted to build a high ridge that goes off to the side and make lots of rope. You send a bunch of people repelling down the final length. – ShadoCat Feb 14 '19 at 22:16
• It would not have to be canvas thinly stretch animal skins, or possibly stomach lining or intestines used today to make haggis and sausage casings could be sown together using sinew and bone needles to make the surface of a glider. Similar to the kayaks made in the Northern polar regions. – Sarriesfan Feb 15 '19 at 0:47

In theory, could a stone age tribe make an air-force of fixed wing hang-gliders and safely glide from top to bottom of a cliff if the air currents were favourable?

Well, maybe, but not your stone-age tribe.

The problem is, not neccessarily using mica. If you like, you can wave your hands a lot and postulate that the mica available is found in improbably large perfect sheets. There have been very large mica crystals found in places like Canada and Russia with the desired size, but they are riddled with imperfections, and this will make any large-scale construction extremely difficult. With some practice, the natives might learn to peel off very large, thin perfect sheets and use them for skins. This has problems, since sheets thick enough to be self-supporting will be waaaay too heavy to use, and wrapping thin skins around a wooden wing framework which just happens to have a useful airfoil shape is pretty outrageous. What sort of mushrooms are your people smoking in order to get revelations of the needed geometry?

Once you get past that, I suspect sufficiently thin mica would actually work, since animal glue ought to adhere satisfactorily, and very thin sheets ought to bend well.

So, if you want to stretch credulity to the breaking point, you might, maybe, if the reader has been doing 'ludes or maybe X, and is feeling very mellow, get away with it.

No, the problem is that of first flight. The tribe lives on top of a small plateau. The only way to learn how to control a glider is to practice, and this is usually done on low slopes with just enough slope that the novice doesn't get too high and get badly injured in the inevitable crash. In your case, the only way to learn is to strap a glider on and run over the edge. Y'know, earn while you learn.

And this is not going to end well unless you invoke authorial privilege in ways which will cause most readers to throw the book across the room.

EDIT - there was actually a related incident (almost) during WWII. Problem Allied officers were held in Colditz Castle, and, as much out of boredom as anything else, worked on the Colditz Cock, which was not finished before the end of the war.

This was a two-seat, overwing glider which was built in an attic and intended to be hauled up on the roof of the castle for launch. It might, just possibly, have worked, but that is mainly because it was designed and built by officers who had some experience in operational aircraft. I certainly would not have wanted to be part of the maiden flight.

• "this is not going to end well unless you invoke authorial privilege in ways which will cause most readers to throw the book across the room" a [+] for that line alone, honestly, if I found the OP's idea in a book I was reading it'd be enough to get an author on my "don't buy anything he's written ever again" list – Pelinore Feb 14 '19 at 23:31

All the ideas about "let's port an idea to an earlier age" ride on the wave of thought inertia. "How could they not have thought about it earlier?!" Such things include steampunk (Victorian era information technology), Ancient World steam engines, your Stone Age flying, etc.

The problem with this approach is less that people did not come up with proper ideas. While this is true to a some degree, a diligent study shows that most ideas were suggested multiple times. If an approach or a device does not take off (sometimes, literally), the reason is some times the lack of demand (people don't know what to do), but in the most cases the lack of materials to implement the idea properly or the missing economic sustainability (it's too expensive to operate). Or everything together.

To give some examples: The lack of civilian supersonic travel is a prime example of missing sustainability. All those almost full-titanium prototype bombers that never went into production scratch at the line of missing or too expensive materials.

# Materials are the key

Gliders were mentioned.

Yes, you probably could build a somewhat working glider from your local wood and local fabric. It would be not good enough in most cases.

The balsa wood hat its fame in the early aviation days not without a reason. The duramold and delta-wood (quite complicated, mind you, that's finest mid-20th century tech!) were invented not without a reason. (Funnily enough, some secrets on fabricating these are now lost, because we have better materials now.) And don't get me started on lightweight and durable fabrics, nylon, aviation varnishes and resins.

Technology is hard. Material science is hard. The reason no one basically built a proper glider before 20th century has something to do with missing knowledge of aerodynamics, yes. But also with lacking materials.

A classic old wives tale is about a local idiot, who builds wings 'cause he wants to fly as a bird, climbs the local bell tower and crashes down. The problem is that the wings would be in most cases designed as wearable items (thus having too little wingspan) and that the materials available to the local madman around 17th century are not really balsa and nylon and silk.

Frankly, I fail to see how your Stone Age tribe has access to such materials in such a variety. You can put them where balsa grows, but they'd be like half an Earth away from where the silk worm lives.

And don't even get me started on engines. Basically, anything less than an internal combustion engine has too little power/weight ratio to move an aircraft. A heaver that air aircraft that is.

# Zeppelins? No.

But proper dirigibles are another, quite tearful story. You'd need proper varnish and material for the insulation. You'd want a hard hull. You need a carcass from a quite good steel or aluminum that is. You'd still need engines. You need a source of a lighter-than-air gas. Hydrogen is highly flammable, hello Hindenburg! You'd still need some natural source of it (or of helium, even harder) or an industrial way to produce it.

Basically, except hot-air balloons for reconnaissance (used in wars in 19th century, if I recall correctly), anything lighter-than-air is too high-tech for Stone Age. And I doubt hot-air balloons too.

# What can we do?

All my text above describes why do materials matter, why logistic chains are important, and why we did not have Stone Age aircraft in our history on our Earth.

You could change exactly this. In your alternate reality, balsa trees and silk-producing bugs are neighbours. Or your Stoge Age tribes domesticates damn huge spiders and learns to milk them for web.

(Damn huge spiders need a yet another change of the reality, say, it's damn hot in the Stone Age and damn huge is not really very large. Either that or damn huge spiders have lungs. This, however, needs a further explanation, why do we not have a civilisation of damn huge spiders long before human Stone Age, but I digress.)

Or your Stone Age guys found some alien technology. And could reproduce some of it. Or at least they learned aerodynamics. Throw also in thermodynamics and quantum theory, because why not? (You'd have then Iulius Caesar killed with a laser, like in one very short Sci-Fi story, but that's another point and I digress again.)

Or the same alien ship would have transported tons of natural silk for whatever intergalactic fashion reason. Or, even better, liquid synthesised components of spider web in industrial quantity. That'd be a non-renewable source, of course, but your tribal shamans could (miraculously) learn to produce spider web and spider silk cloth from it. And we already agreed that balsa trees just grow around where the tribe lives. Or they were great hunters making composite bows routinely and hence they have some technology resembling delta-wood using carefully collected wood, antlers, bee wax, goat intestines and what not.

Oh, and as already mentioned, being locked out on a plateau does not help.

• I'd object to your glider analysis. Light weight is only important if you need large glide ratios or soaring. WWII troop gliders like the Waco used standard plywood and metal fasteners for the frames and wings. The gliders posited in the OP only need a high-enough glide ratio to land without seriously injuring the pilot. – WhatRoughBeast Feb 15 '19 at 0:21
• If you look at what Octave Chanute and Otto Lilienthal were playing with, you could build gliders like that clear back to the time of ancient Egypt or before -- if you can somehow get away from the whole "flapping = flight" mindset. I don't think leather wings are light enough to work, but the Egyptians were certainly known for high-quality, lightweight textiles. – Mark Feb 15 '19 at 2:38
• WhatRoughBeast: At WW2 the humanity was pretty good at aerodynamics. If you have to discover these laws first (and especially if your flight is down from a plateau and it's essential to have enough lift), you'd want better materials. Mark: Yeah, I wrote "basically" because of Lilienthal and Co. I'd say it can be surely said that aviation before 20th century was in its infancy. – Oleg Lobachev Feb 15 '19 at 22:27

In theory, could a stone age tribe make an air-force of fixed wing hang-gliders and safely glide from top to bottom of a cliff if the air currents were favourable?

Yes, it can be done with mica in light thin sheets, but only if your Helawi take a lesson from the insects.

• Dragonfly's wings are corrugated on a fine scale such that they are superbley strong, and flexible in ways that enable superb manouverability - they are bendy when acted on by forces from above but rigid when bearing the thrust of a downstroke or a tight turn. In the 2010 study the thickness of the wing in some places proved too small for the scanning electron microscope to resolve. The wings are arranged into veins and nodes connecting them - all serving to distribute strain for maximum utility.

• A thin and flexible pine frame reinforcing thin sheets of mica with plant fibre veins, all fixed together with a refined animal protein glue (collagen in meat boiled down to gelatin) - all you need is a stone with a concave surface and some meat, water and fire. (I wouldn't try to sew mica - it doesn't possess the tensile strength to cope with being threaded).

None of this could be invented in twenty five minutes, over time expertise would need to be developed by trial and error and occasional inspiration of the Lithogeniuses of the tribe, they would need time to develope tactical defence.

As to Tactics.

I recommend that you send an assault force down silently, as you said, to wait behind the Fikawi, then a second wave slowly and very noisily glide down with flaming torches and whissles/cries, maybe throwing rocks/flaming balls of fat to attract the attention of and disorient the enemy, the first wave taking this as a signal to attack from below. They don't like it up 'em.

I think we can come up with a scenario where your stone-age glider would work better by looking at the lift equation, $$F_\mathrm{lift} = \frac{1}{2}CA \rho v^2$$, where $$F_\mathrm{lift}$$ is the lift force provided by the wing, $$C$$ is the lift coefficient (usually of order 1), $$A$$ is the wing area, $$\rho$$ is the density of the fluid, and $$v$$ is the speed of the wing relative to the fluid. For flight, the lift force must counteract the gravitational force, $$F = -mg$$, where $$m$$ is the mass of the wing and pilot and $$g$$ is the local gravitation acceleration. We have a few options:

Increase $$v$$: Your plateau might have very high winds. Doubling the wind speed will lead to four times the lift! Unfortunately, steering the glider would be difficult. Hopefully the Fikawi are camped downwind.

Decrease $$g$$: The Helawi glider would work a lot better if your stone-age tribe lived on a planet with less surface gravity and a similar atmospheric pressure as Earth. At $$g = \frac{1}{2} g_\mathrm{Earth} \approx 5~\mathrm{m/s}^2$$, the glider would generate double the lift of the same glider on Earth.

Increase $$\rho$$: One way to increase $$\rho$$ is to increase the total pressure. As long as you keep the partial pressure of oxygen near its value on Earth, people can survive with a fairly wide range of pressure. Nitrogen narcosis causes symptoms similar to alcohol consumption at pressures greater 4 times Earth's normal atmospheric pressure. That would give the glider 4 times the lift! With some mild evolutionary adaptations, your people might be able to withstand such total pressures with no ill effects or maybe up to 10 times as much pressure. I think a planet with 10 times Earth's atmospheric pressure might be the best way to fly with a stone glider.

Another option for increased $$\rho$$ would be to keep the pressure of the gas the same, but make the gas heavier. This seems a little far-fetched from an elemental abundance perspective, but maybe your atmosphere is 20% oxygen and 80% xenon by volume. At 1 atm of pressure, the glider would produce (0.2*16+0.8*131)/(0.2*16+0.8*14) = 7.5 times as much lift! Some other heavy non-toxic gas might also work. However, xenon and many other heavy inert gases have anesthetic effects, so some biological adaptation from normal humans would probably be required.

Decrease $$m$$: As mentioned in the other answers, mica isn't a great material for gliders. But if your locale had native aluminum metal, maybe they could pound it into wings. Despite aluminum's high reactivity for oxygen, native aluminum metal apparently exists in some places, although it seems to be mixed with other, more dense metals. However, aluminum isn't very stone age and you can only get so far by reducing the weight of the glider. The weight of the pilot would eventually be the limiting factor. Could you make the pilot smaller? I could imagine a hummingbird-sized person flying around on a thin sheet of mica.

Increase $$A$$: This would be difficult without making the mica break. The mica might be reinforced by wood and leather, but the available materials are really going to limit the size that the wing can be without collapsing.

In conclusion, if the story must take place on Earth with a history similar to ours, I suppose that high winds (high $$v$$) and small, possibly pygmy-sized, people (low $$m$$) would might be your best bet. Without doing some experiments, it's unclear how well a glider constructed from mica, leather, and wood would perform under current conditions on Earth. As suggested in the other answers, looking at early twentieth century methods of airplane construction would help, although these relied on cotton fabric and doping substances that would probably not be available to stone-age culture. Could the fabrics be replaced with pitch-coated animal skins? I don't know. However, the above points show that if you are flexible with the conditions of the planet in your story, you can get much better gliding performance with stone-age construction.

• So basically a "not really plausible" then? maybe the answer could benefit from a short summation / conclusion? – Pelinore Feb 15 '19 at 1:28
• Aluminum isn't malleable enough to cold-work, unlike copper or gold. – Mark Feb 15 '19 at 2:43
• @Mark That's a good point. I'm not sure if a stone-age culture would be able to do anything with relatively pure aluminum metal, even if they had it. How hot would they have to get it to be able to work it? Would it start to burn first? – WaterMolecule Feb 15 '19 at 17:23

Unless you can successfully build and test hot air balloons being airborne is not the answer here.

Make long ropes and scale down the backside of the mountain. When you have enough hiding in the back then you come out and attack.

Throw down,catapult, or etc boiling water, rocks,acid, flaming pitch, or poison (or etc) from above to land on your enemies.

Depending on height archers might be a great way to attack them.

All this without leaving your camp.

Team 1 maintains a constant barrage on the folks below.

Team 2 charges down the mountain as fast as safely possible in great numbers.

If the cliffs are not sheer drop offs you might be able to sled down them, as in straight down the side.

If you planned in advance you could have made a path all the way down free from rocks and debris.

Then you get in steerable wagons, and go shooting down the mountain at great speed. Who knows, you might be able to reach 60mph, if your carts hold together.

Think of it this way.

A perfect single lane road just wide enough for your carts plus a safety margin. Its important to bank the sides as much as possible and as steep as possible so you can roll giant rocks down at enemies without them flying off the side of the mountain prematurely. By the time the reach the bottom there momentum should be crazy. A solid stone, round boulder at 100+mph, it bowling time. Strike!!!

Think Indiana Jones, and the giant round boulder rolling down the narrow corridor behind him. Except this time you have 50 ready to go to smash your enemies at the bottom. Maybe you can even add spikes(flaming even) to them.

You can send carts careening down the road from the top building up great speed, and knock down people coming up the road to attack you.

Think human bowling.


text:
## 1.

The Correct Answer is (C) — We know that $\sqrt{-64}&space;=\sqrt{64}i&space;=&space;8i$, so the correct answer choice is (C).

## 2.

The Correct Answer is (C) — As with most “ NOT” or “ EXCEPT” questions, we have to test every answer. We know that $\sqrt{3136}i&space;=&space;\sqrt{64&space;\times&space;49}i=&space;8\sqrt{-49}$ so A is okay. $7\sqrt{64}i&space;=\sqrt{49&space;\times&space;64}i&space;=&space;8\sqrt{-49}$ so we know choice B is okay, too. $\sqrt{56}i&space;=\sqrt{7\times&space;8}i$ and we know this is not equal to $8\sqrt{-49}$so we know C is the only one that is not true.

## 3.

The Correct Answer is (B) — We can solve this problem by adding like terms, which means adding the integers and imaginary numbers separately: (8+2i) + (2+8i) = 8 +2 +2i +8i = 10 + 10i. The correct answer choice is (B).

## 4.

The Correct Answer is (B) — In order to solve this problem, we need to first simplify the numerator by turning it into imaginary number form: $5\sqrt{-4}&space;=&space;10i$. Divide this number by 2i, and recall from the question that 5= 3w Divide both sides by 3 to get, and we have our answer: w= 5/3. The correct answer choice is B.

## 5.

The Correct Answer is (D) — We can solve this problem by simply plugging in the provided values into corresponding variables: $Z&space;=&space;2+&space;5i^{3}=&space;2-5i.$ The correct answer choice is D.

## 6.

The Correct Answer is (A) — Use the values given in the question to solve the equation for Z:

$Z&space;=&space;0&space;+&space;(1)i^{10}=&space;-1.$ The only answer choice that is not equal to -1 is A because $i&space;=&space;\sqrt{-1}.$

## 8.

The Correct Answer is (4) — In order to solve this problem, we need to first simplify the left side of the equation: (49 - 2i) - (48 - i) = 1 - i. Now, we can solve for x: 1 - i = (x -4i)/4, therefore 4 - 4i = x - 4i, therefore 4 = x.

## 9.

The Correct Answer is (1) — We can solve this problem by foiling the left side of the equation and then solving for x: (1 + i)(1- i) = 2 = 2x, therefore x = 1.

format: plain


text:
# Derive Sum of Two Angles Identities (Complex Plane)

This example derives the sum of two angles identities using the properties of complex numbers and Euler’s formula.

## Steps

1. The sum of two angles (alpha) and (beta) form a complex number on the unit circle in the complex plane. From Euler’s formula we know this complex number can be expressed using cosine and sine.

This complex number can be visualized as a point in the complex plane, where the horizontal coordinate is equal to and the vertical coordinate is equal to .

2. Distribute the complex constant for both angles.

Apply the addition property of the exponential function to expand the right-hand side.

3. Apply Euler’s formula to both sides of the equation.

Multiply the right-hand side of the equation.

Substitute for on the right-hand side.

The geometry of the expressions on the right-hand can side can be visualized by drawing the trigonometry of the two angles on the unit circle.

These lengths could be solved for, as shown in this example, but here they are the natural result of the multiplication of two complex numbers.

4. Equate the real part and complex parts together.

Divide both sides of the second expression by to get the two summation identities.


text:
# Get name of a primitive passed as parameter to C++

This topic is 2205 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

## Recommended Posts

Hi,

like this, in script
 Load(int_variable);
in c++
 void Load(void *ref, int typeId) { // find name of ref, not type name }

script copies and passes a temp value to c++
i cant use @int_variable to pass the actual pointer.

i currently pass a name as a string then iterate over properties and find value.
but that is slow. ( Load(const string &in) )

is there a way to get address of primitives?

thanks.

##### Share on other sites
I'm afraid I don't understand what you're trying to accomplish.

What is the Load() function supposed to do? Return an integer value?

If it is then you should register it as &out, i.e. an output reference.

 // script void func() { int variable; Load(variable); assert( variable == 42 ); } // C++ // Registered with signature "void Load( ? &out )" void Load(void *ref, int typeId) { if( typeId == asTYPEID_INT32 ) { *(int*)ref = 42; } } // or with signature "void Load(int &out)" void Load(int &var) { var = 42; }

##### Share on other sites
Is this intended to be some lightweight way for (limited) saving of the script's state? For that, you can check out the Serializer addon: http://www.angelcode.com/angelscript/sdk/docs/manual/doc_addon_serializer.html

##### Share on other sites

Is this intended to be some lightweight way for (limited) saving of the script's state? For that, you can check out the Serializer addon: http://www.angelcode...serializer.html

you are really insightful.
i wish i understood what code does just by looking 4 lines of it

i want same syntax as boost::serialization library.

here is a better explanation of what i want to do:

i just want to learn name of that integer, i dont want change or return it.

pointer i get is not same as it is in script. so i cant find its name

here is how it works
 class Test { int a; float b; Test2 child; // this has its own Serialize() function Serialization @Serialize() { Serialization @ser; @ser = CreateSerialization(@this); ser << a; // << operator is Load(?&out) ser << b; ser << @child; return @ser; } }

##### Share on other sites
Perhaps this can be of use: http://pastebin.com/bQ0j8YMV
It has some stuff specific to the game it is from, and requires some extra engine functions to be able to serialize floats. It does not know the name of the resource it tries to serialize though, so it relies on the order of << and >> calls.

##### Share on other sites

Perhaps this can be of use: http://pastebin.com/bQ0j8YMV
It has some stuff specific to the game it is from, and requires some extra engine functions to be able to serialize floats. It does not know the name of the resource it tries to serialize though, so it relies on the order of << and >> calls.

thanks, i will use some parts of this in binary output portion.
i had some goals starting this,
- order of saved variable do not matter
- adding new variable does not corrupt old saves
- removing variables does not corrupt saved files
- no need to modify c++ code

to be used in:
- debugger, readable text dump of objects
- transfer state over tcp

but i just cant find a way to learn primitives' name when they are passed as references.
i am stuck with
ser << "int_var";
but i want
ser << int_var;

##### Share on other sites
I'm afraid it simply doesn't work that way. In order to guarantee that the reference sent to a function AngelScript will sometime have to send a reference to a temporary variable rather than to the real one, when there may be a change the real one is destroyed during the function call.

You can turn on unsafe references, which will let AngelScript send the reference to the real variable as an &inout reference. However, I cannot guarantee that this will allow you to find the name of the real variable in all instances.

To turn on unsafe referecences, the application should call:

 engine->SetEngineProperty(asEP_ALLOW_UNSAFE_REFERENCSE, true);

Remember, a badly written script can crash the application if you turn this on.

##### Share on other sites

I'm afraid it simply doesn't work that way. In order to guarantee that the reference sent to a function AngelScript will sometime have to send a reference to a temporary variable rather than to the real one, when there may be a change the real one is destroyed during the function call.

You can turn on unsafe references, which will let AngelScript send the reference to the real variable as an &inout reference. However, I cannot guarantee that this will allow you to find the name of the real variable in all instances.

To turn on unsafe referecences, the application should call:

 engine->SetEngineProperty(asEP_ALLOW_UNSAFE_REFERENCSE, true);

Remember, a badly written script can crash the application if you turn this on.

came this far without using asEP_ALLOW_UNSAFE_REFERENCE, i am scared of it
passing as string is ok
thanks.

##### Share on other sites
You said the issue with the original technique was the need to iterate through all your member variables -- is making a hashmap acceptable? It still involves processing a string, but operates in ~O(1) time.

##### Share on other sites

came this far without using asEP_ALLOW_UNSAFE_REFERENCE, i am scared of it

Don't be. My team has been using it since close to 3 years already and the only time we had a crash related to it turned out to be an obscure bug somewhere in AS which was fixed very quickly afterwards by Andreas. The setting does make life easier.

1. 1
Rutin
25
2. 2
3. 3
4. 4
JoeJ
18
5. 5

• 14
• 14
• 11
• 11
• 9
• ### Forum Statistics

• Total Topics
631757
• Total Posts
3002141
×


text:
# 6.9. Properties of Continuously Extendable Functions

It is quite natural that continuously extendable functions inherit a lot of their properties from the continuous ones. But there are also some results from sequences - the nesting theorem and the limit theorems to name a few - that have mirror theorems within our current subject.

As with continuity itself continuous extendability proves to be a local property. The initial propositions work out the details.

Proposition:  Let a be an accumulation point of $A\subset B$. If  $f:B\to ℝ$ is continuously extendable at a then  $f|A$ is continuously extendable at a and has the same limit:

 $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f|A\left(x\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)$ [6.9.1]

In general the reverse does not hold.

Proof:  From [6.2.8] we see that if $g:B\cup \left\{a\right\}\to ℝ$ is a continuous extension of  f at a then $g|A\cup \left\{a\right\}$ continuously extends  $f|A$ at a. And from this the identity of the limits is obvious.

The Heaviside step function H
 i
is not continuously extendable at 0 in contrast to its restriction $\mathrm{H}|{ℝ}^{>0}$.

The local character is also stressed by the fact that two functions that coincide locally don't differ in their limit behaviour (cf. [6.2.11]).

Proposition:  Let a be an accumulation point of $A\cap B$. If  $f:A\to ℝ$ and $g:B\to ℝ$ coincide locally at a the following equivalence holds:

 f continuously extendable at a$\text{ }⇔\text{ }$g continuously extendable at a [6.9.2]

If the limits exist they coincide:  $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(x\right)$

Proof:  Due to the premise there are relative $\epsilon$-neighbourhoods ${A}_{a,\epsilon }$
 i ${A}_{a,\epsilon }=A\cap \right]a-\epsilon ,a+\epsilon \left[$
and ${B}_{a,\epsilon }$ such that

${A}_{a,\epsilon }={B}_{a,\epsilon }$  and  [0]

We only prove one direction, for instance "$⇒$", using the sequence criterion [6.8.4].

Let  f be continuously extendable at a. If $\left({a}_{n}\right)$ is a sequence in B with ${a}_{n}\to a$ we find a number ${n}_{0}\in {ℕ}^{\ast }$ such that ${a}_{n}\in {B}_{a,\epsilon }$ for all $n\ge {n}_{0}$. According to [0] these n now satisfy

$g\left({a}_{n}\right)=f\left({a}_{n}\right)\to \underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)$

which in fact is the assertion.

Consider:

• As in [6.2.11] we get for an accumulation point a of A by specialisation

f  is continuously extendable at a$\text{ }⇔\text{ }f|{A}_{a,\epsilon }$  is continuously extendable at a for one $\epsilon >0$

in which case their limits coincide: $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f|{A}_{a,\epsilon }\left(x\right)$.

Similar to [6.4.1] and [6.4.9] we can notice the typical interaction between fixed value of  f and its neighbouring values. Again we only note the result for $.

Proposition: Let  $f:A\to ℝ$ be continuously extendable at an accumulation point a of $A\subset ℝ$. Then for each $c\in ℝ$ and for every relative $\epsilon$-neighbourhood  ${A}_{a,\epsilon }$  the following holds:

 If $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)then there is a $\delta >0$ such that $f\left(x\right) for all $x\in {A}_{a,\delta }\\left\{a\right\}$. [6.9.3] If  $f\left(x\right)\le c$ for all $x\in {A}_{a,\epsilon }\phantom{\rule{0.1em}{0ex}}$ then $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)\le c$. [6.9.4]

Proof:  Let g be the continuous extension of  f at a.

1.  From $g\left(a\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right) the assertion follows directly with [6.4.1].

2.  We may employ [6.4.9] as $g\left(x\right)=f\left(x\right)\le c$ for all $x\in {A}_{a,\epsilon }\\left\{a\right\}$.

When studying limits of sequences the limit theorems proved to be a valuable tool. Fortunately they are still at hand for limits of functions.

Proposition (limit theorems):  Let  $f:A\to ℝ$ and $g:B\to ℝ$ be arbirary functions, a an accumulation point of $A\cap B$ (consequently also of A resp. B). If  f and g are continuously extendable at a the same is true for

 $f+g$  and  $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f+g\left(x\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)+\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(x\right)$ [6.9.5] $f-g$  and  $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f-g\left(x\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)-\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(x\right)$ [6.9.6] $f\cdot g$  and  $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\cdot g\left(x\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)\cdot \underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(x\right)$ [6.9.7] $\frac{f}{g}$  and  $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}\frac{f}{g}\left(x\right)=\frac{\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)}{\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(x\right)}$  if $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(x\right)\ne 0$ [6.9.8]

Proof:  From the premises we have continuous extensions at a for  f and for g, let's say

$r:A\cup \left\{a\right\}\to ℝ\text{ }\text{and}\text{ }s:B\cup \left\{a\right\}\to ℝ$

1.  Now $r+s:\left(A\cap B\right)\cup \left\{a\right\}\to ℝ$ continuously extends  $f+g$ at a and the limit calculates to

$\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f+g\left(x\right)=r+s\left(a\right)=r\left(a\right)+s\left(a\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)+\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(x\right)$

2./3.  The proof is just a copy of the above.

4.  The formula results as before again. In this case however we need to check if a is also an accumulation point of  $\left\{x\in A\cap B|g\left(x\right)\ne 0\right\}$:

As a is an accumulation point of $A\cap B$ we find a sequence $\left({a}_{n}\right)$ in $\left(A\cap B\right)\\left\{a\right\}$ converging to a, and as $s\left(a\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(x\right)\ne 0$ the continuity of g (see [6.4.2]) provides a relative $\epsilon$-neighbourhood ${B}_{a,\epsilon }$ of a such that

From a certain ${n}_{0}$ onwards all sequence members are within ${B}_{a,\epsilon }$ so that $\left({a}_{n+{n}_{0}}\right)$ is a sequence in $\left\{x\in A\cap B|g\left(x\right)\ne 0\right\}$ converging to a.

And we have a fifth limit theorem as the composition of functions is also compatible with the continuous extendability.

Proposition:  Let $g:A\to ℝ$ and  $f:B\to ℝ$ be any two functions and a an accumulation point of $\left\{x\in A|g\left(x\right)\in B\right\}$. If g is continuously extendable at a and if $\underset{y\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(y\right)$ is an accumulation point of B at which  f is continuously extendable then  $f\circ g$ is continuously extendable at a as well with the limit

 $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\circ g\left(x\right)=\underset{x\to \underset{y\to a}{\mathrm{lim}}\phantom{\rule{0.1em}{0ex}}g\left(y\right)}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)$ [6.9.9]

Proof:  We employ the sequence criterion [6.8.4]: If $\left({a}_{n}\right)$ is a sequence in $\left\{x\in A|g\left(x\right)\in B\right\}\subset A$ such that ${a}_{n}\to a$ we have in turn:

• $g\left({a}_{n}\right)\to \underset{y\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(y\right)$  because g is continuously extendable at a

• $f\circ g\left({a}_{n}\right)=f\left(g\left({a}_{n}\right)\right)\to \underset{x\to \underset{y\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(y\right)}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)$  because  f is continuously extendable at $\underset{y\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(y\right)$

Alongside with tools for calculating limits we need methods for estimating limits.

Proposition (nesting theorem):  Let a be an accumulation point of A and  $f,g,h:A\to ℝ$ be three functions such that

.

If  f and h are continuously extendable at a and if $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}h\left(x\right)$ then g is continuously extendable at a by

 $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}g\left(x\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)=\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}h\left(x\right)$ [6.9.10]

Proof:  Again we use the sequence criterion [6.8.4] and take a sequence $\left({a}_{n}\right)$ in A converging to a. From the premises we have

so that the assertion immediately results from the original nesting theorem [5.5.8].

The nesting theorem is often used after succeeding in estimating a difference by absolute value. The following proposition guarantees that this practice leads to limits.

Proposition:  Let a be an accumulation point of $A\subset ℝ$ and $b\in ℝ$. Then for any function  $f:A\to ℝ$ the following equivalence holds:

 f is continuously extendable at a with $\underset{x\to a}{\mathrm{lim}}\phantom{\rule{0.3em}{0ex}}f\left(x\right)=b$ [6.9.11] $\text{ }⇔\text{ }$ $|f-b|$ is continuously extendable at a with $\underset{x\to a}{\mathrm{lim}}|f\left(x\right)-b|=0$

Proof:  The first direction "$⇒$" is done immediately with the calculation rules [6.9.6] and [6.9.9]. For the second one "$⇐$" we employ the sequence criterion:

$\begin{array}{ll}A\ni {a}_{n}\to a\hfill & \text{ }⇒\text{ }|f\left({a}_{n}\right)-b|\to 0\hfill \\ \hfill & \text{ }⇒\text{ }f\left({a}_{n}\right)-b\to 0\hfill \\ \hfill & \text{ }⇒\text{ }f\left({a}_{n}\right)\to b\hfill \end{array}$

 6.8. 6.10.


text:
# Aptitude Papers Numerical Aptitude Questions 3iInfotech Aptitude Questions

Examrace Placement Series prepares you for the toughest placement exams to top companies.

If 2x-y = 4 then 6x − 3y =?

If x = y = 2z and xyz = 256 then what is the value of x?

Solve: (⅒) 18- (⅒) 20 =?

Pipe A can fill in 20 minutes and Pipe B in 30 mins and Pipe C can empty the same in 40 mins. If all of them work together, find the time taken to fill the tank

Thirty men take 20 days to complete a job working 9 hours a day. How many hour a day should 40 men work to complete the job?

Find the smallest number in a GP whose sum is 38 and product 1728

A boat travels 20 kms upstream in 6 hrs and 18 kms downstream in 4 hrs. Find the speed of the boat in still water and the speed of the water current?

A goat is tied to one corner of a square plot of side 12m by a rope 7m long. Find the area it can graze?

Mr. Shah decided to walk down the escalator of a tube station. He found that if he walks down 26 steps, he requires 30 seconds to reach the bottom. However, if he steps down 34 stairs he would only require 18 seconds to get to the bottom. If the time is measured from the moment the top step begins to descend to the time he steps off the last step at the bottom, find out the height of the stair way in steps?

The average age of 10 members of a committee is the same as it was 4 years ago, because an old member has been replaced by a young member. Find how much younger is the new member?

Three containers A, B and C have volumes a, b, and c respectively; and container A is full of water while the other two are empty. If from container A water is poured into container B which becomes ⅓ full, and into container C which becomes ½ full, how much water is left in container A?

ABCE is an isosceles trapezoid and ACDE is a rectangle. AB = 10 and EC = 20. What is the length of AE?

In the given figure, PA and PB are tangents to the circle at A and B respectively and the chord BC is parallel to tangent PA. If AC = 6 cm, and length of the tangent AP is 9 cm, then what is the length of the chord BC?

Three cards are drawn at random from an ordinary pack of cards. Find the probability that they will consist of a king, a queen and an ace.

A number of cats got together and decided to kill between them 999919 mice. Every cat killed an equal number of mice. Each cat killed more mice than there were cats. How many cats do you think there were?

If Log2 x − 5 Log x + 6 = 0, then what would the value/values of x be?

Answer: x = e2 or e3.

In june a baseball team that played 60 games had won 30% of its game played. After a phenomenal winning streak this team raised its average to 50%. How many games must the team have won in a row to attain this average?

Can you tender a one rupee note in such a manner that there shall be total 50 coins but none of them would be 2 paise coins. Answer: 45 one paisa coins, 2 five paise coins, 2 ten paise coins, and 1 twenty-five paise coins.

A monkey starts climbing up a tree 20ft. Tall. Each hour, it hops 3ft. And slips back 2ft. How much time would it take the monkey to reach the top?

What is the missing number in this series? 8 2 14 6 11? 14 6 18 12

A certain type of mixture is prepared by mixing brand A at Rs. 9 a kg. With brand B at Rs. 4 a kg. If the mixture is worth Rs. 7 a kg. how many kgs. Of brand A are needed to make 40kgs. Of the mixture?

Answer: Brand A needed is 24kgs.

A wizard named Nepo says “I am only three times my son's age. My father is 40 years more than twice my age. Together the three of us are a mere 1240 years old.” How old is Nepo?

One dog tells the other that there are two dogs in front of me. The other one also shouts that he too had two behind him. How many are they? Answer: Three

A man ate 100 bananas in five days, each day eating 6 more than the previous day. How many bananas did he eat on the first day?

If it takes five minutes to boil one egg, how long will it take to boil four eggs?

The minute hand of a clock overtakes the hour hand at intervals of 64 minutes of correct time. How much a day does the clock gain or lose?

Solve for x and y: 1/x − 1/y = ⅓ 1/x2 + 1/y2 = 5/9.

Answer: x = 3/2 or-3 and y = 3 or-3/2.

Daal is now being sold at Rs. 20 a kg. During last month its rate was Rs. 16 per kg. By how much percent should a family reduce its consumption so as to keep the expenditure fixed?

Find the least value of 3x + 4y if x2y3 = 6.

Can you find out what day of the week was January 12, 1979?

A garrison of 3300 men has provisions for 32 days, when given at a rate of 850 grams per head. At the end of 7 days a reinforcement arrives and it was found that now the provisions will last 8 days less, when given at the rate of 825 grams per head. How, many more men can it feed? Answer: 1700 men.

From 5 different green balls, four different blue balls and three different red balls, how many combinations of balls can be chosen taking at least one green and one blue ball?

Three pipes, A, B, & C are attached to a tank. A & B can fill it in 20 & 30 minutes respectively while C can empty it in 15 minutes. If A, B & C are kept open successively for 1 minute each, how soon will the tank be filled? Answer: 167 minutes.

A person walking ⅚ of his usual rate is 40 minutes late. What is his usual time? Answer: 3 hours 20 minutes.

For a motorist there are three ways going from City A to City C. By way of bridge the distance is 20 miles and toll is $0.75. A tunnel between the two cities is a distance of 10 miles and toll is$1.00 for the vehicle and driver and $0.10 for each passenger. A two-lane highway without toll goes east for 30 miles to city B and then 20 miles in a northwest direction to City C. Which is the shortest route from B to C The most economical way of going from City A to City B, in terms of toll and distance is to use the Jim usually drives alone from City C to City A every working day. His firm deducts a percentage of employee pay for lateness. Which factor would most influence his choice of the bridge or the tunnel? In choosing between the use of the bridge and the tunnel the chief factor (s) would be: Traffic and road conditions Number of passengers in the car Location of one's homes in the center or outskirts of one of the cities Desire to save$0.25

Which is correct?

The letters A, B, C, D, E, F and G, not necessarily in that order, stand for seven consecutive integers from 1 to 10, D is 3 less than A, B is the middle term

F is as much less than B as C is greater than D, G is greater than F.

The fifth integer is

A is as much greater than F as which integer is less than G

If A = 7, the sum of E and G is

A-F =?

An integer T is as much greater than C as C is greater than E. T can be written as A + E. What is D?

The greatest possible value of C is how much greater than the smallest possible value of D?

All G's are H's

All G's are J's or K's

All J's and K's are G's

All L's are K's

All N's are M's

No M's are G's

If no P's are K's, which of the following must be true?

Which of the following can be logically deduced from the conditions stated?

Which of the following is inconsistent with one or more of the conditions?

The statement “No L's are J's” is

Logically deducible from the conditions stated

Consistent with but not deducible from the conditions stated

Deducible from the stated conditions together with the additional statement “No J's are K's”

Which is correct?

In country X, democratic, conservative and justice parties have fought three civil wars in twenty years. TO restore stability an agreement is reached to rotate the top offices President, Prime Minister and Army Chief among the parties so that each party controls one and only one office at all times. The three top office holders must each have two deputies, one from each of the other parties. Each deputy must choose a staff composed of equally members of his or her chiefs party and member of the third party.

When Justice party holds one of the top offices, which of the following cannot be true

When the democratic party holds presidency, the staff of the prime minister's deputies are composed

One-fourth of democratic party members

One-half of justice party members and one-fourth of conservative party members

One-half of conservative party members and one-fourth of justice party members.

Which is correct?

Which of the following is allowable under the rules as stated:

The office of the Army Chief passes from Conservative to Justice party. Which of the following must be fired.

In recommendations to the board of trustees a tuition increase of $500 per year, the president of the university said “There were no student demonstrations over the previous increases of$300 last year and \$200 the year before” If the president's statement is accurate then which of the following can be validly inferred from the information given:

Most students in previous years felt that the increases were justified because of increased operating costs.

Student apathy was responsible for the failure of students to protest the previous tuition increases.

Students are not likely to demonstrate over new tuition increases.

Which is correct?

The office staff of XYZ corporation presently consists of three bookeepers--A, B, C and 5 secretaries D, E, F, G, H. The management is planning to open a new office in another city using 2 bookeepers and 3 secretaries of the present staff. To do so they plan to seperate certain individuals who don't function well together. The following guidelines were established to set up the new office

Bookeepers A and C are constantly finding fault with one another and should not be sent together to the new office as a team

C and E function well alone but not as a team, they should be seperated

D and G have not been on speaking terms and shouldn't go together

Since D and F have been competing for promotion they shouldn't be a team

Which is correct? If A is to be moved as one of the bookeepers, which of the following cannot be a possible working unit.

If C and F are moved to the new office, how many combinations are possible

If C is sent to the new office, which member of the staff cannot go with C

Under the guidelines developed, which of the following must go to the new office

If D goes to the new office, which of the following is/are true

C cannot go

A cannot go

H must also go

Which is correct?

After months of talent searching for an administrative assistant to the president of the college the field of applicants has been narrowed down to 5--A, B, C, D, E and It was announced that the finalist would be chosen after a series of all-day group personal interviews were held. The examining committee agreed upon the following procedure

The interviews will be held once a week

3 candidates will appear at any all-day interview session

Each candidate will appear at least once

If it becomes necessary to call applicants for additonal interviews, no more 1 such applicant should be asked to appear the next week

Because of a detail in the written applications, it was agreed that whenever candidate B appears, A should also be present.

Because of travel difficulties it was agreed that C will appear for only 1 interview.

At the first interview the following candidates appear A, B, D. Which of the follwing combinations can be called for the interview to be held next week.

Which of the following is a possible sequence of combinations for interviews in 2 successive weeks

If A, B and D appear for the interview and D is called for additional interview the following week, which 2 candidates may be asked to appear with D?

A

B

C

E

Which is correct?

Which of the following correctly state (s) the procedure followed by the search committee

After the second interview all applicants have appeared at least once

The committee sees each applicant a second time

If a third session, it is possible for all applicants to appear at least twice

Which is correct?

A certain city is served by subway lines A, B and C and numbers 1 2 and 3

When it snows, morning service on B is delayedWhen it rains or snows, service on A, 2 and 3 are delayed both in the morning and afternoon When temp. Falls below 30 degrees farenheit afternoon service is cancelled in either the A line or the 3 line.

but not both When the temperature rises over 90 degrees farenheit, the afternoon service is cancelled in either the line C or the 3 line but not both. When the service on the A line is delayed or cancelled, service on the C line which connects the A line, is delayed When service on the 3 line is cancelled, service on the B line which connects the 3 line is delayed.

On Jan 10th, with the temperature at 15 degree farenheit, it snows all day. On how many lines will service be affected, including both morning and afternoon.

On Aug 15th with the temperature at 97 degrees farenheit it begins to rain at 1 PM. What is the minimum number of lines on which service will be affected?

On which of the following occasions would service be on the greatest number of lines disrupted.

In a certain society, there are two marriage groups, red and brown. No marriage is permitted within a group. On marriage, males become part of their wives groups; women remain in their own group. Children belong to the same group as their parents. Widowers and divorced males revert to the group of their birth. Marriage to more than one person at the same time and marriage to a direct descendant are forbidden

A brown female could have had

A grandfather born Red

A grandmother born Red

Two grandfathers born Brown

Which is correct?

A male born into the brown group may have

Which of the following is not permitted under the rules as stated.

If widowers and divorced males retained their group they had upon marrying which of the following would be permissible (Assume that no previous marriage occurred)

All G's are H's

All G's are J's or K's

All J's and K's are G's

All L's are K's

All N's are M's

No M's are G's

There are six steps that lead from the first to the second floor. No two people can be on the same step

Mr. A is two steps below Mr. C

Mr. B is a step next to Mr. D

Only one step is vacant (No one standing on that step)

Denote the first step by step 1 and second step by step 2 etc.

If Mr. A is on the first step, Which of the following is true?

If Mr. E was on the third step & Mr. B was on a higher step than Mr. E which step must be vacant

If Mr. B was on step 1, which step could A be on?

If there were two steps between the step that A was standing and the step that B was standing on, and A was on a higher step than D, A must be on step

Which of the following is false

B&D can be both on odd-numbered steps in one configuration

In a particular configuration A and C must either both an odd numbered steps or both an even-numbered steps

A person E can be on a step next to the vacant step.

Which is correct?

Six swimmers A, B, C, D, E, F compete in a race. The outcome is as follows.

B does not win.

Only two swimmers separate E & D

A is behind D & E

B is ahead of E, with one swimmer intervening

F is a head of D

Who stood fifth in the race?

How many swimmers seperate A and F?

The swimmer between C & E is

If the end of the race, swimmer D is disqualified by the Judges then swimmer B finishes in which place

Five houses lettered A, B, C, D, & E are built in a row next to each other. The houses are lined up in the order A, B, C, D, & E. Each of the five houses has a colored chimney. The roof and chimney of each housemust be painted as follows.

The roof must be painted either green, red, or yellow.

The chimney must be painted either white, black, or red.

No house may have the same color chimney as the color of roof.

No house may use any of the same colors that the every next house uses.

House E has a green roof.

House B has a red roof and a black chimney

If house C has a yellow roof. Which must be true.

Which possible combinations of roof & chimney can house

A red roof 7 a black chimney

A yellow roof & a red chimney

A yellow roof & a black chimney

Which is correct?


text:
# LaTeX - Highlight Author of Text in Epilogue

I am currently writing a scientific paper in LaTeX with a fellow student. We use Overleaf and are still a bit inexperienced with LaTeX. Our professor wants us to create an epilogue that shows who is responsible for which chapter or section.

It would be great if you could write the name of the editor directly behind a \chapter{mychapter} or \section{mysection} and automatically create an epilogue at the end.

Now my question: Is there any library specifically for such a case? And if so, how can I use it?

• Hello and welcome ! This may help tex.stackexchange.com/questions/156862/… – BambOo Apr 10 '20 at 14:09
• This is definitely going in the right direction... But I wouldn't like to have a name after every chapter or section in the document... I'd rather have an automatic listing of all chapters or sections for the respective author at the very end of the document – CrazyEight Apr 10 '20 at 15:11

After tweaking a bit this answer by user using the tocloft package, here is what comes.

You can create two lists \listchaptersbyA and \listchapterbyB which will hold all the chapters authored by authors A and B. Call \chapterbyA or \chapterbyB after a \chapter to state that this chapter was authored by the specific author. List these chapters by calling \listofchapterbyA or \listofchaptersbyB

\documentclass{book}
\usepackage{lipsum}
\usepackage{tocloft}
\usepackage{hyperref}

\usepackage[english]{babel}

\newcommand{\listchaptersbyA}{Authored by A}
\newlistof{chaptersbyA}{cbA}{\listchaptersbyA}

\newcommand{\chapterbyA}[0]
{%
\refstepcounter{chaptersbyA}
{\protect\numberline{\thechaptersbyA}\chaptername~\thechapter}\par
}

\newcommand{\listchaptersbyB}{Authored by B}
\newlistof{chaptersbyB}{cbB}{\listchaptersbyB}

\newcommand{\chapterbyB}[0]
{%
\refstepcounter{chaptersbyB}
{\protect\numberline{\thechaptersbyB}\chaptername~\thechapter}\par
}

\begin{document}

\chapter{1st chapter}
\chapterbyA{}
\lipsum[1]

\section{A section}
\lipsum[1]

\chapter{2nd chapter}
\chapterbyA{}
\chapterbyB{}
\lipsum[1]

\section{A section}
\lipsum[1]

\chapter{3rd chapter}
\chapterbyA{}
\lipsum[1]

\newpage
\listofchaptersbyA
\listofchaptersbyB
\end{document}

• Exactly what i am looking for... but is there also a way on how to also make this possible for sections? If i add \chapterbyA to a section then also only the chapter is displayed in the toc. And maybe also possible to add the names behind chapter number? – CrazyEight Apr 10 '20 at 16:34
• @CrazyEight It is really much depending on how much effort you want to put into this, how many chapters and sections or subsections ... If you know since the beginning who will do what, you can also put everything into a table. – BambOo Apr 10 '20 at 19:02


text:
# sulfuric acid reacts wuth calcium metal in nigria

#### How to Make Sulfuric Acid at Home - ThoughtCo

3/6/2020· Sulfuric acid reacts with metal. Also, it will attack some types of plastic. Glass is a good choice. Sulfuric acid reacts with water in an exothermic reaction, but dilution with water is the best way to deal with an acid spill. Have copious amounts of water available, just in case something goes wrong.

#### Hg Removal - Sulphuric Acid

The Outokumpu process is based on converting the elemental mercury in the gas into a sulfate according to the reaction: Hg + H 2 SO 4 --> 1/2 O 2 + HgSO 4 + H 2 O. The smelter gas is scrubbed with 80-90% H 2 SO 4 at a temperature of 150-180°C.

#### What happens when zinc metal reacts with Sulphuric acid?

6/4/2020· When an acid reacts with metal, a salt and hydrogen are produced: acid + metal → salt + hydrogen An example: nitric acid + calcium → calcium nitrate + hydrogen The salt that is produced depends upon which acid and which metal react.

#### Chemical Reactions Problem Set - Widener University

For the following reactions: Name the reactants and products, Balance the equation, and calculate the molecular weight of the reactants and products. Starting with 2.0 grams of each reactant, identify the limiting reagent and determine the mass of the first product. Fe2O3(s) + CO (g) -> FeO (s) + CO2(g)

#### Stoichiometry: 3.55 - Back titration - IB Chem

Therefore moles of sulfuric acid in volumetric flask = 10 x 7.05 x 10-4 = 7.05 x 10-3 moles Initial moles of sulfuric acid = 0.05 x 1 = 0.05 moles Therefore moles of sulfuric acid that reacted with the alloy = 0.05 - 7.05 x 10-3 = 0.04295 moles sulfuric acid reacts

#### What Do I Get If I Add Sulfuric Acid to Calcium Nitrate?

19/4/2020· When sulfuric acid is added to calcium nitrate, nitric acid and calcium sulphate are produced. This is illustrated by the equation Ca(NO3)2(aq) + H2SO4(aq) = CaSO4(s) + 2 HNO3(aq). In the above chemical reaction, a molecule of calcium nitrate coines with a molecule of sulfuric acid to produce a molecule of calcium sulphate plus 2 of nitric acid.

#### 3.8 Gas Evolution Reactions - Chemistry LibreTexts

11/7/2019· Sulfuric acid reacts with calcium carbonate to form calcium sulfate, carbon dioxide, and water:$\ce{H2SO4(aq) + CaCO3(aq) → CaSO4(aq) + CO2(g)+H2O(l)}$ Hydrochloric acid reacts with calcium carbonate to form calcium chloride, carbon dioxide, and water

#### Sulfuric acid and reactions with it - MEL Chemistry

Di lut ed sul fu ric acid re acts with met als which are to the left of hy dro gen in the row of ac tiv i ty, ac cord ing to the gen er al scheme: Ме + H₂SO₄(diluted) → salt + H₂↑ Reaction of sulfuric acid and barium

#### Reactions of metals with acids producing salts | …

Measure 50 cm 3 of dilute sulfuric acid using a measuring cylinder and pour it into the beaker. Warm this acid gently over a low, non-smokey, Bunsen flame. Turn off the Bunsen burner before the solution boils. Carefully remove the beaker of acid from the tripod

#### A; ao;ieu ;’aksdn’adm ‘akdjlnvczv’ - University of Waterloo

hydrochloric acid. The reaction of sulfuric acid with calcium metal produces a coating of calcium sulfate (CaSO4) on the metal. Since the calcium sulfate is insoluble in water, the coating acts as a protective layer thus preventing further attack on the metal by

#### Sulfuric acid – the contact process - Ammonia and …

9/5/2021· Stage 3 - making sulfuric acid. In the final stage, sulfur trioxide reacts with water to make sulfuric acid: \ [H_ {2}O (l) + SO_ {3} (g) \rightarrow H_ {2}SO_ {4} (aq)\] This is not a reversible

#### Sulfuric acid – the contact process - Ammonia and …

9/5/2021· Stage 3 - making sulfuric acid. In the final stage, sulfur trioxide reacts with water to make sulfuric acid: \ [H_ {2}O (l) + SO_ {3} (g) \rightarrow H_ {2}SO_ {4} (aq)\] This is not a reversible

#### 3.8 Gas Evolution Reactions - Chemistry LibreTexts

11/7/2019· Sulfuric acid reacts with calcium carbonate to form calcium sulfate, carbon dioxide, and water:$\ce{H2SO4(aq) + CaCO3(aq) → CaSO4(aq) + CO2(g)+H2O(l)}$ Hydrochloric acid reacts with calcium carbonate to form calcium chloride, carbon dioxide, and water

#### 7.8: Acid–Base and Gas Evolution Reactions - Chemistry …

1/7/2019· Sulfuric acid reacts with calcium carbonate to form calcium sulfate, carbon dioxide, and water: $\ce{H2SO4(aq) + CaCO3(aq) → CaSO4(aq) + CO2(g)+H2O(l)}$ Hydrochloric acid reacts with calcium carbonate to form calcium chloride, carbon dioxide, and water:

#### Are there metals that react with sulfuric acid but not …

6/9/2016· So for sulfuric acid and hydrochloric acid, $\ce{SrSO4}$ will form, but $\ce{SrCl2}$ will stay in solution. Therefore, sulfuric acid will react with strontium ion, while hydrochloric acid will not. ( Note : strontium metal will react with both.)

#### Hg Removal - Sulphuric Acid

The Outokumpu process is based on converting the elemental mercury in the gas into a sulfate according to the reaction: Hg + H 2 SO 4 --> 1/2 O 2 + HgSO 4 + H 2 O. The smelter gas is scrubbed with 80-90% H 2 SO 4 at a temperature of 150-180°C.

#### Acid Attack - an overview | ScienceDirect Topics

Sulfuric acid reacts with calcium hydroxide as well and produces calcium sulfate (CaSO 4). When sulfuric acid reacts with calcium silie hydrate, silie oxide in aqueous state is formed. Due to sulfuric acid attack, the concrete micro-structure becomes weak, cement paste is lost, and size of specimen reduces thereby resulting in reduction in compressive strength of concrete.

#### SOLVED:Sulfuric acid reacts with sodium hydroxide…

So let''s use that Mueller Mass and get we have one mole of sulfuric acid is the equivalent of 98.8 grams. And now we multiply all this out to get 0.75 times 98.8 divided by two. And we get 38 6.78 grams of sulfuric acid.

#### What is the reaction between calcium and hydrochloric …

A (quite vigorous) metal-acid reaction takes place, producing CaCl2 and hydrogen gas. Such a reaction is best carried out in the lab under a fume hood and using small pieces of calcium metal & dilute acid, as large pieces can produced sufficient heat to ignite the …

#### Chemical Reactions Problem Set - Widener University

Calcium metal reacts with phosphorus to produce calcium phosphide. Copper metal reacts with sulfuric acid and water to produce copper sulfate pentahydrate and sulfur dioxide. The coustion of decane. The coustion of pamoic acid (C 23 H 16 O 4).

#### Reactions of hydrochloric sulfuric nitric acids with metals …

calcium hydroxide + sulfuric acid ==> calcium sulfate + water Ca(OH) 2 + H 2 SO 4 ==> CaSO 4 + 2H 2 O Ca(OH) 2 (s) + H 2 SO 4 (aq) ==> CaSO 4 (aq/s) + 2H 2 O(l) This reaction soon slows down because calcium sulfate isn''t very soluble

#### sulfuric acid reacts wuth calcium metal

Calcium Metal Series Calcium metal can be used in steelmaking to produce high quality and special Type steel. The calcium treatment can solve the problem of clogging Zhengzhou FengYuan Metallurgical Materials Co., Ltd. is a technology-oriented enterprise

#### Calcium reacts with sulfuric acid - Stock Image - …

What happens when calcium carbonate reacts with Sulphuric

#### Chemical Reactions Problem Set - Widener University

For the following reactions: Name the reactants and products, Balance the equation, and calculate the molecular weight of the reactants and products. Starting with 2.0 grams of each reactant, identify the limiting reagent and determine the mass of the first product. Fe2O3(s) + CO (g) -> FeO (s) + CO2(g)

#### What Are the Effects of Sulfuric Acid on Metal?

18/2/2021· The effects of sulfuric acid on metal depend on a nuer of factors, including the type of metal, the concentration of the acid, and the temperature. Dilute sulfuric acid will, in theory, react with any metal that lies above hydrogen in the reactivity series by displacing hydrogen from the acid, releasing it as a gas and forming the sulfate salt of the metal.

#### WebElements Periodic Table » Cobalt » reactions of …

Reaction of cobalt with acids. Cobalt metal dissolves slowly in dilute sulphuric acid to form solutions containing the aquated Co (II) ion together with hydrogen gas, H 2. In practice, the Co (II) is present as the complex ion [Co (OH 2) 6] 2+. Co (s) + H 2 SO 4 (aq) → Co 2+ (aq) + SO 42- (aq) + H 2 (g)

#### What Happens When Metals React With Acids?

4/4/2020· While exploring what happens when metals come in contact with acids, it is apparent that most, but not all, have some sort of reaction, usually forming hydrogen gas. The result is the production of salts. Hydrochloric Acid. Some metals dissolve in this acid and this results in the formation of hydrogen gas and oxidized metal chlorides.


text:
# Dependency of operations of languages

I've struggled in the closure properties of the general class of languages because I couldn't use any automata concept and grammars.

In specific, I'm interested in dependency of operations.

(The operation $A$ is dependent to other operations $\Sigma$ when every class of languages is closed under some operations $\Sigma$, then it must be closed under an operation $A$.)


text:
xarray integrates with Dask to support parallel computations and streaming computation on datasets that don’t fit into memory.

Currently, Dask is an entirely optional feature for xarray. However, the benefits of using Dask are sufficiently strong that Dask may become a required dependency in a future version of xarray.

For a full example of how to use xarray’s Dask integration, read the blog post introducing xarray and Dask.

## What is a Dask array?¶

Dask divides arrays into many small pieces, called chunks, each of which is presumed to be small enough to fit into memory.

Unlike NumPy, which has eager evaluation, operations on Dask arrays are lazy. Operations queue up a series of tasks mapped over blocks, and no computation is performed until you actually ask values to be computed (e.g., to print results to your screen or write to disk). At that point, data is loaded into memory and computation proceeds in a streaming fashion, block-by-block.

The actual computation is controlled by a multi-processing or thread pool, which allows Dask to take full advantage of multiple processors available on most modern computers.

The usual way to create a dataset filled with Dask arrays is to load the data from a netCDF file or files. You can do this by supplying a chunks argument to open_dataset() or using the open_mfdataset() function.

In [1]: ds = xr.open_dataset('example-data.nc', chunks={'time': 10})

In [2]: ds
Out[2]:
<xarray.Dataset>
Dimensions:      (latitude: 180, longitude: 360, time: 365)
Coordinates:
* time         (time) datetime64[ns] 2015-01-01 2015-01-02 ... 2015-12-31
* longitude    (longitude) int64 0 1 2 3 4 5 6 ... 353 354 355 356 357 358 359
* latitude     (latitude) float64 89.5 88.5 87.5 86.5 ... -87.5 -88.5 -89.5
Data variables:
temperature  (time, latitude, longitude) float64 dask.array<shape=(365, 180, 360), chunksize=(10, 180, 360)>

In this example latitude and longitude do not appear in the chunks dict, so only one chunk will be used along those dimensions. It is also entirely equivalent to opening a dataset using open_dataset and then chunking the data using the chunk method, e.g., xr.open_dataset('example-data.nc').chunk({'time': 10}).

To open multiple files simultaneously, use open_mfdataset():

xr.open_mfdataset('my/files/*.nc')

This function will automatically concatenate and merge dataset into one in the simple cases that it understands (see auto_combine() for the full disclaimer). By default, open_mfdataset will chunk each netCDF file into a single Dask array; again, supply the chunks argument to control the size of the resulting Dask arrays. In more complex cases, you can open each file individually using open_dataset and merge the result, as described in Combining data.

You’ll notice that printing a dataset still shows a preview of array values, even if they are actually Dask arrays. We can do this quickly with Dask because we only need to compute the first few values (typically from the first block). To reveal the true nature of an array, print a DataArray:

In [3]: ds.temperature
Out[3]:
<xarray.DataArray 'temperature' (time: 365, latitude: 180, longitude: 360)>
dask.array<shape=(365, 180, 360), dtype=float64, chunksize=(10, 180, 360)>
Coordinates:
* time       (time) datetime64[ns] 2015-01-01 2015-01-02 ... 2015-12-31
* longitude  (longitude) int64 0 1 2 3 4 5 6 7 ... 353 354 355 356 357 358 359
* latitude   (latitude) float64 89.5 88.5 87.5 86.5 ... -87.5 -88.5 -89.5

Once you’ve manipulated a Dask array, you can still write a dataset too big to fit into memory back to disk by using to_netcdf() in the usual way.

In [4]: ds.to_netcdf('manipulated-example-data.nc')

By setting the compute argument to False, to_netcdf() will return a Dask delayed object that can be computed later.

In [5]: from dask.diagnostics import ProgressBar

# or distributed.progress when using the distributed scheduler
In [6]: delayed_obj = ds.to_netcdf('manipulated-example-data.nc', compute=False)

In [7]: with ProgressBar():
...:     results = delayed_obj.compute()
...:

[                                        ] | 0% Completed |  0.0s
[##                                      ] | 5% Completed |  0.2s
[################                        ] | 42% Completed |  0.3s
[################################        ] | 81% Completed |  0.4s
[####################################### ] | 98% Completed |  0.8s
[########################################] | 100% Completed |  0.9s

Note

When using Dask’s distributed scheduler to write NETCDF4 files, it may be necessary to set the environment variable HDF5_USE_FILE_LOCKING=FALSE to avoid competing locks within the HDF5 SWMR file locking scheme. Note that writing netCDF files with Dask’s distributed scheduler is only supported for the netcdf4 backend.

A dataset can also be converted to a Dask DataFrame using to_dask_dataframe().

In [8]: df = ds.to_dask_dataframe()

In [9]: df
Out[9]:
latitude longitude            time temperature
npartitions=44
0               float64     int64  datetime64[ns]     float64
525600              ...       ...             ...         ...
...                 ...       ...             ...         ...
22600800            ...       ...             ...         ...
23651999            ...       ...             ...         ...

Dask DataFrames do not support multi-indexes so the coordinate variables from the dataset are included as columns in the Dask DataFrame.

Nearly all existing xarray methods (including those for indexing, computation, concatenating and grouped operations) have been extended to work automatically with Dask arrays. When you load data as a Dask array in an xarray data structure, almost all xarray operations will keep it as a Dask array; when this is not possible, they will raise an exception rather than unexpectedly loading data into memory. Converting a Dask array into memory generally requires an explicit conversion step. One notable exception is indexing operations: to enable label based indexing, xarray will automatically load coordinate labels into memory.

The easiest way to convert an xarray data structure from lazy Dask arrays into eager, in-memory NumPy arrays is to use the load() method:

In [10]: ds.load()
Out[10]:
<xarray.Dataset>
Dimensions:      (latitude: 180, longitude: 360, time: 365)
Coordinates:
* time         (time) datetime64[ns] 2015-01-01 2015-01-02 ... 2015-12-31
* longitude    (longitude) int64 0 1 2 3 4 5 6 ... 353 354 355 356 357 358 359
* latitude     (latitude) float64 89.5 88.5 87.5 86.5 ... -87.5 -88.5 -89.5
Data variables:
temperature  (time, latitude, longitude) float64 0.4691 -0.2829 ... 0.005886

You can also access values, which will always be a NumPy array:

In [11]: ds.temperature.values
Out[11]:
array([[[  4.691e-01,  -2.829e-01, ...,  -5.577e-01,   3.814e-01],
[  1.337e+00,  -1.531e+00, ...,   8.726e-01,  -1.538e+00],
...
# truncated for brevity

Explicit conversion by wrapping a DataArray with np.asarray also works:

In [12]: np.asarray(ds.temperature)
Out[12]:
array([[[  4.691e-01,  -2.829e-01, ...,  -5.577e-01,   3.814e-01],
[  1.337e+00,  -1.531e+00, ...,   8.726e-01,  -1.538e+00],
...

Alternatively you can load the data into memory but keep the arrays as Dask arrays using the persist() method:

In [13]: ds = ds.persist()

This is particularly useful when using a distributed cluster because the data will be loaded into distributed memory across your machines and be much faster to use than reading repeatedly from disk. Warning that on a single machine this operation will try to load all of your data into memory. You should make sure that your dataset is not larger than available memory.

For performance you may wish to consider chunk sizes. The correct choice of chunk size depends both on your data and on the operations you want to perform. With xarray, both converting data to a Dask arrays and converting the chunk sizes of Dask arrays is done with the chunk() method:

In [14]: rechunked = ds.chunk({'latitude': 100, 'longitude': 100})

You can view the size of existing chunks on an array by viewing the chunks attribute:

In [15]: rechunked.chunks
Out[15]: Frozen(SortedKeysDict({'time': (10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 10, 5), 'latitude': (100, 80), 'longitude': (100, 100, 100, 60)}))

If there are not consistent chunksizes between all the arrays in a dataset along a particular dimension, an exception is raised when you try to access .chunks.

Note

In the future, we would like to enable automatic alignment of Dask chunksizes (but not the other way around). We might also require that all arrays in a dataset share the same chunking alignment. Neither of these are currently done.

NumPy ufuncs like np.sin currently only work on eagerly evaluated arrays (this will change with the next major NumPy release). We have provided replacements that also work on all xarray objects, including those that store lazy Dask arrays, in the xarray.ufuncs module:

In [16]: import xarray.ufuncs as xu

In [17]: xu.sin(rechunked)
Out[17]:
<xarray.Dataset>
Dimensions:      (latitude: 180, longitude: 360, time: 365)
Coordinates:
* time         (time) datetime64[ns] 2015-01-01 2015-01-02 ... 2015-12-31
* longitude    (longitude) int64 0 1 2 3 4 5 6 ... 353 354 355 356 357 358 359
* latitude     (latitude) float64 89.5 88.5 87.5 86.5 ... -87.5 -88.5 -89.5
Data variables:
temperature  (time, latitude, longitude) float64 dask.array<shape=(365, 180, 360), chunksize=(10, 100, 100)>

To access Dask arrays directly, use the new DataArray.data attribute. This attribute exposes array data either as a Dask array or as a NumPy array, depending on whether it has been loaded into Dask or not:

In [18]: ds.temperature.data
Out[18]: dask.array<xarray-temperature, shape=(365, 180, 360), dtype=float64, chunksize=(10, 180, 360)>

Note

In the future, we may extend .data to support other “computable” array backends beyond Dask and NumPy (e.g., to support sparse arrays).

## Automatic parallelization¶

Almost all of xarray’s built-in operations work on Dask arrays. If you want to use a function that isn’t wrapped by xarray, one option is to extract Dask arrays from xarray objects (.data) and use Dask directly.

Another option is to use xarray’s apply_ufunc(), which can automate embarrassingly parallel “map” type operations where a function written for processing NumPy arrays should be repeatedly applied to xarray objects containing Dask arrays. It works similarly to dask.array.map_blocks() and dask.array.atop(), but without requiring an intermediate layer of abstraction.

For the best performance when using Dask’s multi-threaded scheduler, wrap a function that already releases the global interpreter lock, which fortunately already includes most NumPy and Scipy functions. Here we show an example using NumPy operations and a fast function from bottleneck, which we use to calculate Spearman’s rank-correlation coefficient:

import numpy as np
import xarray as xr
import bottleneck

def covariance_gufunc(x, y):
return ((x - x.mean(axis=-1, keepdims=True))
* (y - y.mean(axis=-1, keepdims=True))).mean(axis=-1)

def pearson_correlation_gufunc(x, y):
return covariance_gufunc(x, y) / (x.std(axis=-1) * y.std(axis=-1))

def spearman_correlation_gufunc(x, y):
x_ranks = bottleneck.rankdata(x, axis=-1)
y_ranks = bottleneck.rankdata(y, axis=-1)
return pearson_correlation_gufunc(x_ranks, y_ranks)

def spearman_correlation(x, y, dim):
return xr.apply_ufunc(
spearman_correlation_gufunc, x, y,
input_core_dims=[[dim], [dim]],
output_dtypes=[float])

The only aspect of this example that is different from standard usage of apply_ufunc() is that we needed to supply the output_dtypes arguments. (Read up on Wrapping custom computation for an explanation of the “core dimensions” listed in input_core_dims.)

Our new spearman_correlation() function achieves near linear speedup when run on large arrays across the four cores on my laptop. It would also work as a streaming operation, when run on arrays loaded from disk:

In [19]: rs = np.random.RandomState(0)

In [20]: array1 = xr.DataArray(rs.randn(1000, 100000), dims=['place', 'time'])  # 800MB

In [21]: array2 = array1 + 0.5 * rs.randn(1000, 100000)

# using one core, on NumPy arrays
In [22]: %time _ = spearman_correlation(array1, array2, 'time')
CPU times: user 21.6 s, sys: 2.84 s, total: 24.5 s
Wall time: 24.9 s

In [23]: chunked1 = array1.chunk({'place': 10})

In [24]: chunked2 = array2.chunk({'place': 10})

# using all my laptop's cores, with Dask
In [25]: r = spearman_correlation(chunked1, chunked2, 'time').compute()

In [26]: %time _ = r.compute()
CPU times: user 30.9 s, sys: 1.74 s, total: 32.6 s
Wall time: 4.59 s

One limitation of apply_ufunc() is that it cannot be applied to arrays with multiple chunks along a core dimension:

In [27]: spearman_correlation(chunked1, chunked2, 'place')
ValueError: dimension 'place' on 0th function argument to apply_ufunc with
dask='parallelized' consists of multiple chunks, but is also a core
dimension. To fix, rechunk into a single Dask array chunk along this
dimension, i.e., .rechunk({'place': -1}), but beware that this may
significantly increase memory usage.

This reflects the nature of core dimensions, in contrast to broadcast (non-core) dimensions that allow operations to be split into arbitrary chunks for application.

Tip

For the majority of NumPy functions that are already wrapped by Dask, it’s usually a better idea to use the pre-existing dask.array function, by using either a pre-existing xarray methods or apply_ufunc() with dask='allowed'. Dask can often have a more efficient implementation that makes use of the specialized structure of a problem, unlike the generic speedups offered by dask='parallelized'.

## Chunking and performance¶

The chunks parameter has critical performance implications when using Dask arrays. If your chunks are too small, queueing up operations will be extremely slow, because Dask will translate each operation into a huge number of operations mapped across chunks. Computation on Dask arrays with small chunks can also be slow, because each operation on a chunk has some fixed overhead from the Python interpreter and the Dask task executor.

Conversely, if your chunks are too big, some of your computation may be wasted, because Dask only computes results one chunk at a time.

A good rule of thumb is to create arrays with a minimum chunksize of at least one million elements (e.g., a 1000x1000 matrix). With large arrays (10+ GB), the cost of queueing up Dask operations can be noticeable, and you may need even larger chunksizes.

## Optimization Tips¶

With analysis pipelines involving both spatial subsetting and temporal resampling, Dask performance can become very slow in certain cases. Here are some optimization tips we have found through experience:

1. Do your spatial and temporal indexing (e.g. .sel() or .isel()) early in the pipeline, especially before calling resample() or groupby(). Grouping and resampling triggers some computation on all the blocks, which in theory should commute with indexing, but this optimization hasn’t been implemented in Dask yet. (See Dask issue #746).

2. Save intermediate results to disk as a netCDF files (using to_netcdf()) and then load them again with open_dataset() for further computations. For example, if subtracting temporal mean from a dataset, save the temporal mean to disk before subtracting. Again, in theory, Dask should be able to do the computation in a streaming fashion, but in practice this is a fail case for the Dask scheduler, because it tries to keep every chunk of an array that it computes in memory. (See Dask issue #874)

3. Specify smaller chunks across space when using open_mfdataset() (e.g., chunks={'latitude': 10, 'longitude': 10}). This makes spatial subsetting easier, because there’s no risk you will load chunks of data referring to different chunks (probably not necessary if you follow suggestion 1).


text:
# Revision history [back]

### Multiplicative order of elements in a finite field defined by QuotientRing

I've defined the AES's $\operatorname{GF}(2^8)$ field as follows;

R.<x> = PolynomialRing(GF(2), 'x')
S.<y> = QuotientRing(R, R.ideal(x^8+x^4+x^3+x+1))
S.is_field()

When I added the below and run it

print("y+1 = ",(y+1).multiplicative_order())

I've got this error;

   2671         if not self.is_unit():
-> 2672             raise ArithmeticError("self (=%s) must be a unit to have a multiplicative order.")

• How one can easily find the multiplicative order?

I've seen this question How to find the multiplicative order of an element in a quotient ring over finite field ? but that is too complex to build. Is there an easy method?


text:
Homework Help: Prove ||w + z|| <= ||w|| + ||z|| for complex vectors

1. Nov 28, 2009

s_j_sawyer

1. The problem statement, all variables and given/known data

Let z, w be complex vectors of C^n.

Prove ||w + z|| <= ||w|| + ||z||

(using the standard inner product for C^n)
(i.e. <w,z> = w*z', where * is the dot product and ' denotes the complex conjugate)

3. The attempt at a solution

Well, I found that

||w + z||
= sqrt( w*w' + z*z' + z*w' + w*z')
= sqrt( w*w' + z*z' + <w,z> + <w,z>' )

and

||w|| + ||z||
= sqrt(w*w' + z*z')

So by showing that <w,z> + <w,z>' <= 0 then I guess that will finish the proof but I am unsure of how to do this.

Any help?

2. Nov 28, 2009

Staff: Mentor

The equation above isn't true. ||w|| = sqrt(w*w') and ||z|| = sqrt(z*z'), but the two square roots don't add to sqrt(w*w' + z*z'). This is like saying that the lengths of two sides of a right triangle add up to the length of the hypotenuse.

3. Nov 28, 2009

s_j_sawyer

Oooohhh deeaarr how embarrassing. Thank you for that insightful information. I should be able to get it now.

4. Nov 28, 2009

s_j_sawyer

Sorry to double post but I didn't think simply editing would bump this up.

Alright so I played around with this some more but still could not get it to work.

I tried to prove this using the method of squaring both sides for the regular 'scalar triangle inequality' proof like so:

||w + z||^2 = (sqrt<w + z,w + z>)^2
= <w + z, w + z>
= <w,w> + <w,z> + <z,w> + <z,z>
= ||w||^2 + <w,z> + <w,z>' + ||z||^2

and so if I can show that

<w,z> + <w,z>' <= 2*||w||*||z||

then I would have

||w + z||^2 <= (||w|| + ||z||)^2

but I have been unable to do so. Any assistance would be greatly appreciated!

5. Nov 28, 2009

lanedance

have you tried assuming a complex form, say w = aj + b and expanding the inner products?

6. Nov 28, 2009

xeno_gear

$$\|w + z\|^2$$ is not equal to $$\langle w + z, w + z \rangle$$ unless you're in a real vector space. But since these are complex, then

$$\|w + z\|^2 = \langle w + z, \overline{w + z} \rangle$$

Some hints:
If $$w$$ is a complex number (or vector, or whatever), then $$w = a + bi$$, where $$a$$ and $$b$$ are real numbers (or vectors), and

$$w + \overline{w} = a + bi + a - bi = 2a = 2\operatorname{Re}(w).$$

Also, $$\operatorname{Re}(w) \le \|w\|$$

These should hopefully get you on the right track.


text:
# knapsack problem with non-linear constraint

I have a basic knapsack problem where I need to fit the most weight possible in a bin:

import pyomo.environ as pyo

w = {'hammer': 5, 'wrench': 7, 'screwdriver': 4, 'towel': 3}

limit = 14

M = pyo.ConcreteModel()

M.ITEMS = pyo.Set(initialize=w.keys())

M.x = pyo.Var(M.ITEMS, within=pyo.Binary)

M.value = pyo.Objective(expr=sum(M.x[i] for i in M.ITEMS), sense=pyo.maximize)

M.weight = pyo.Constraint(expr=sum(w[i] * M.x[i] for i in M.ITEMS) <= limit)

solver = pyo.SolverFactory("cbc")
solver.solve(M)
M.x.display()

Which works fine:

    Key         : Lower : Value : Upper : Fixed : Stale : Domain
hammer :     0 :   1.0 :     1 : False : False : Binary
screwdriver :     0 :   1.0 :     1 : False : False : Binary
towel :     0 :   1.0 :     1 : False : False : Binary
wrench :     0 :   0.0 :     1 : False : False : Binary

My problem is that I need to include a value component and I must ensure that the average value of all selected items is above a certain fixed threshold. I implemented it like this:

v = {'hammer': 1, 'wrench': 3, 'screwdriver': 1, 'towel': 2}
w = {'hammer': 5, 'wrench': 7, 'screwdriver': 4, 'towel': 3}

limit = 14

M = pyo.ConcreteModel()

M.ITEMS = pyo.Set(initialize=w.keys())

M.x = pyo.Var(M.ITEMS, within=pyo.Binary)

M.value = pyo.Objective(expr=sum(M.x[i] for i in M.ITEMS), sense=pyo.maximize)

M.weight = pyo.Constraint(expr=sum(w[i] * M.x[i] for i in M.ITEMS) <= limit)

M.above_average = pyo.Constraint(
expr=sum(M.x[i] * v[i] for i in M.ITEMS) / sum(M.x[i] for i in M.ITEMS) >= 2
)

solver = pyo.SolverFactory("cbc")
solver.solve(M)
M.x.display()

But that caused the following error:

ValueError: Cannot write legal LP file.  Constraint 'above_average' has a body with nonlinear terms.

I understand that the constraint that I added is non-linear, therefore the error message is correct. My question is how I could solve that with pyomo (or equivalent) or workaround this problem.

Hold the phone...

You can keep this linear. Just sum the selection variables and multiply by the min average requirement. No division required.

import pyomo.environ as pyo

v = {'hammer': 1, 'wrench': 3, 'screwdriver': 1, 'towel': 2}
w = {'hammer': 5, 'wrench': 7, 'screwdriver': 4, 'towel': 3}

limit = 14

M = pyo.ConcreteModel()

M.ITEMS = pyo.Set(initialize=w.keys())

M.x = pyo.Var(M.ITEMS, within=pyo.Binary)

M.value = pyo.Objective(expr=sum(M.x[i] for i in M.ITEMS), sense=pyo.maximize)

M.weight = pyo.Constraint(expr=sum(w[i] * M.x[i] for i in M.ITEMS) <= limit)

# M.above_average = pyo.Constraint(
#     expr=sum(M.x[i] * v[i] for i in M.ITEMS) / sum(M.x[i] for i in M.ITEMS) >= 2
# )

min_avg_val = 2

M.above_average = pyo.Constraint(
expr=sum(M.x[i] * v[i] for i in M.ITEMS) >= sum(M.x[i] * min_avg_val for i in M.ITEMS) )

solver = pyo.SolverFactory("cbc")
solver.solve(M)
M.x.display()

### Yields:

x : Size=4, Index=ITEMS
Key         : Lower : Value : Upper : Fixed : Stale : Domain
hammer :     0 :   0.0 :     1 : False : False : Binary
screwdriver :     0 :   1.0 :     1 : False : False : Binary
towel :     0 :   1.0 :     1 : False : False : Binary
wrench :     0 :   1.0 :     1 : False : False : Binary

• +1 Yes, this is what I meant by clearing the denominator. Jul 26 '20 at 3:24
• woot woot. On the same page Jul 26 '20 at 3:30
• @AirSquid that's a great answer! thanks! Jul 26 '20 at 10:27

Here is a workaround for your nonlinear problem:

solver_manager = SolverManagerFactory('neos')
#solver = pyo.SolverFactory("BARON")
solution = solver_manager.solve(M, solver = 'couenne')
#solver.solve(M)
for i in M.ITEMS:
print(i,':',pyo.value(M.x[i]))

You can either use a local nonlinear solver like BARON, or some solvers in NEOS server. I comment out the local solver option in the code, but you can easily use NEOS server to solve it. Please note that you need to add the following line to the beginning of your code:

from pyomo.opt.parallel import SolverManagerFactory

solution of the model is(using cuenne in NEOS):

hammer : 3.502043595574344e-08
wrench : 1.0
screwdriver : 1.0
towel : 1.0

and with BARON:

hammer 0.0
wrench 1.0
screwdriver 1.0
towel 1.0

• Thanks! couenne did the trick for me! I needed it locally but it wasn't very hard to install with coinbrew Jul 26 '20 at 0:41
• Or just linearize by clearing the denominator. Jul 26 '20 at 2:54