text:
## Notes to Pascal’s Wager

1. Hájek 2012 argues that in fact this is too quick. This article considers a series of increasingly strong senses of “superdominance” (the one considered here is “superdominance+”), and he argues that none of them is strong enough to confer such a requirement. This, in turn, casts doubt on the validity of the first of Pascal’s wagers. However, the details get somewhat intricate, and I have chosen not to get into them in this exposition.

2. Those interested in the reconstruction over the years of the text itself should consult Lafuma 1954.

3. Our demarcation of the arguments follows that of Hacking 1972, although we will differ on certain points of detail.

4. Unfortunately, he squanders this insight when he lapses back to the assumption that the probability is 1/2 shortly thereafter: “And so our proposition is of infinite force, when there is the finite to stake in a game where there are equal risks of gain and of loss, and the infinite to gain.”

5. Consider a gamble that pays you $$W$$ units (for ‘win’) if $$X$$, and nothing otherwise. We are seeking the fair price $$f$$, at which you should be indifferent between playing the gamble and not; you should be prepared to pay that much, but no more. Expected utility theory tells us that the fair price is the gamble’s expected utility:

$f = P(X)W$

where $$P(X)$$ is the chance of gain (and so $$1 - P(X)$$ is the chance of loss).

Let’s derive this from Pascal’s answer, quoted here again:

… the uncertainty of the gain is proportioned to the certainty of the stake according to the proportion of the chances of gain and loss …

You will pay $$f$$ with certainty: this is “the certainty of the stake”. It is uncertain whether you win, but if you do your gain is $$W - f$$: this is “the uncertainty of the gain”. This is proportioned to the certainty of the stake, $$f$$—that is,

$\frac{f}{W-f}$

according to

$\frac{P(X)}{1 - P(X)}$

That is,

$\frac{f}{W-f} = \frac{P(X)}{1 - P(X)}$

Simple algebra gives

$f - fP(X) = P(X)W - fP(X)$

and hence

$f = P(X)W$

The fair price is the gamble’s expected utility!

6. In the basic version of decision theory that we have presented, states are assumed to be independent of actions. Evidential decision theory generalizes this. It replaces in its expectation calculation for a given action the unconditional probabilities of states by the conditional probabilities of the states, given the action—see Jeffrey 1983. Now perhaps what you do is not independent of whether God exists. For instance, maybe God helps people wager for Him, so that

${\scriptsize P(\text{God exists} \mid \text{you wager for God}) \gt P(\text{God exists} \mid \text{you wager against God}).}$

Still, the expected utility calculations are as before, provided the first conditional probability is positive and finite: infinite for wagering for God, finite for wagering against God.

Causal decision theory replaces evidential decision theory’s conditional probabilities with probabilities that capture the degree of causal relevance of an action to each state. There are various versions of causal decision theory—see Lewis 1981. Using some such version would presumably not significantly affect matters here. We would just replace the assumption that your probability is positive and finite with the same assumption about whatever probability is used instead.

7. After all, infinite utilities run afoul of the Archimedean, or continuity axiom that is commonly assumed in decision theory:

If you prefer $$A$$ to $$B$$, and prefer $$B$$ to $$C$$, then there is a gamble between $$A$$ and $$C$$ ($$A$$ with probability $$p$$, $$C$$ with probability $$1 - p$$, for some real-valued $$p$$) that you regard as equally desirable as $$B$$ for sure.

For suppose that salvation, say, has infinite utility for you. You prefer salvation to $1, and prefer$1 to nothing; but there is no such gamble that rewards you with salvation if you win, and nothing if you lose, that you value at \$1. Indeed, assuming that the probability of winning remains positive, you prefer the gamble to any finite reward; but if the probability of winning drops to 0, your preference discontinuously switches to the finite reward. The objection, then, is that infinite utilities run afoul of the underpinnings of decision theory (by violating a preference axiom), and thus of the theory itself. Yet that theory is appealed to in Premise 3 of the argument. In short, Premise 1 is in tension with Premise 3.

The issue then becomes whether continuity is a requirement on rational preference. Hájek 1997 argues that it is not, and gives further positive arguments for allowing infinite utilities into decision theory. Sorensen 1994 likewise argues for “infinite decision theory”. For presentations of ‘non-Archimedean’ decision theory, see Skalia 1975 and Pivato 2014. For related work on infinite utilities that is more philosophical, see Cain 1995, Nelson 1991, Ng 1995, Vallentyne 1993, Vallentyne 1995, Vallentyne and Kagan 1997, and van Liedekerke 1995.

8. It should be pointed out that the rival Gods must award infinite utility for salvation in order to create a problem—otherwise they will be trumped by the ones that do. (It seems that Kali and Odin thus drop out of consideration, for example.) And to be damaging to the Wager, the alternative hypotheses about how salvation is achieved should be mutually exclusive. If there is some common core to the theistic hypotheses, and it suffices to (strive to) believe that in order to be saved, then there is no problem. For instance, it will not matter that you do not know what God’s favorite real number is, if it turns out that you are saved as long as your belief is adequate in other respects. So it is crucial that salvation hinges on getting the details of the belief right. What, then, should we believe? To settle this question, it seems we get nowhere with Pascal-style practical reasoning.

One response is that we are therefore in a position somewhat like that of Buridan’s ass, unable to settle which course of action is best; and that like the ass we are better off doing something rather than nothing, and in this case that means choosing one of the theistic hypotheses, and hoping we choose the right one. So it might still be rationally required to be a theist. See Jordan 1994a for a version of this “ecumenical” response. There are at least two counter-responses. Firstly, the assumption that there are alternative Gods who offer infinite rewards really plays no role in the many-Gods objection. All that matters is that there are sources of infinite reward besides Pascal’s God. These sources could even be inanimate—as it might be, supreme pleasure machines, which offer infinite utility irrespective of one’s beliefs. Secondly, one of the alternative Gods might punish those who wager for him, and reward those who don’t—see Martin’s 1983 “perverse master”.

9. Here are the third and fourth problems for Premise 2.

3. Infinitesimal probability for God’s existence:
One might reply that you can rationally assign infinitesimal probability to God’s existence—see e.g. Oppy 1990, 2018,  Hájek 2003, Bartha 2016, and Wenmackers 2018. The argument might run, for example, that there are infinitely many possible Gods to consider (see our discussion of the many Gods objection), and for some infinite subset of them that includes Pascal’s God, rationality does not favor any one over the rest. Treating them even-handedly then requires assigning infinitesimal probability to each. Or again, a Bayesian might say that you could coherently assign to God’s existence an infinitesimal probability, provided that you also assign a probability to God’s non-existence that falls short of 1 by the same infinitesimal.

It is remarkable that Pascal anticipated the notion of infinitesimal probability, when he says: “if there were an infinity of chances, of which one only would be for you, you would still be right in wagering one [life] … if there were an infinity of an infinitely happy life to gain.” But what he says here is far from obvious. If $$\infty$$ is a legitimate utility value, then offhand it would seem that $$1/\infty$$ is a legitimate probability value, and indeed it seems to be the very one that he is considering. However, then we have:

$\mathrm{E}(\text{wager for God}) = \infty \times \frac{1}{\infty} + f_1 \times \left(1 - \frac{1}{\infty}\right) \approx 1 + f_1$

And it is not clear that this should exceed $$f_3$$.

All of this treats $$\infty$$ as if it is a number, subject to ordinary arithmetic operations, such as taking reciprocals, multiplying and adding. Perhaps, for example, $$\infty \times (1/\infty)$$ is not defined, much as $$\infty - \infty$$ is not. But that is just another way in which a probability of $$(1/\infty)$$ might thwart Pascal’s reasoning. We will say more below about infinite numbers for which such arithmetic operations are unproblematic.

4. Imprecise (vague) probability for God’s existence:
So far we have presupposed that probability assignments are sharp. However, Pascal’s argument is addressed to us—mere humans. And it is apparently a fact about us that our belief states are irremediably imprecise: we cannot assign probability, precise to indefinitely many decimal places, to all propositions. (Such imprecision about probabilities is also called “vagueness”.) Or perhaps even ideally rational agents may, or indeed should, assign imprecise probabilities when their relevant evidence is impoverished, as Pascal thinks that it is here. (See Joyce 2005 for more on this route to imprecise probabilities in general.) Perhaps, then, rationality permits us to assign imprecise probability to God’s existence. If it moreover permits us to assign it probability that is imprecise over an interval that includes 0, then the Wager fails—see Hájek 2000. Indeed, Pascal’s claim that “[reason] can decide nothing here” might be thought to support a probability assignment to God’s existence that is imprecise over the entire $$[0, 1]$$ interval. However, Rinard 2018 argues that if it is contingent whether God exists, then rationality forbids us from assigning God's existence a probability that is imprecise over an interval that includes 0—the imprecise probability must lie entirely above 0. In that case, Pascal's Wager is just as successful when aimed at rational agents with imprecise probabilities as it is when aimed at rational agents with precise probabilities.

10. One could also insist that rational choices must be ratifiable (à la Jeffrey 1983 or Sobel 1996), and that the act of maximum expectation might not be.

A common rationale for maximizing expectation comes from the various laws of large numbers. Their content is roughly that under suitable circumstances, in the limit, one’s average reward tends to the expectation; and of course one wants to maximize one’s average reward. But the strong law of large numbers assumes that the expectation is finite, and since the expectation of wagering for God is putatively infinite, it clearly cannot be appealed to here. (See e.g. Feller 1971, 236.) Perhaps an appeal to the weak law of large numbers, which allows infinite expectation, would suffice. But being a limit theorem, it concerns infinitely long runs of trials. Far from having such a long run here, we have just a single-shot decision problem. This is a decision that you do not get to repeat. This is not so troubling, perhaps, when the variance (a measure of the spread of the distribution of possible outcomes) is small, so that getting an outcome close to the expectation is probable; but what about when the variance is large?

This brings us to yet another problem for Pascal’s third premise. To be sure, the expectation of wagering for God is infinite, if we accept Pascal’s earlier assumptions; but so too is the variance. Expectation does not seem to be such a good guide to choiceworthiness when the variance is large—for what one might end up getting can then be much worse than the expectation—let alone when the variance is infinite. (See Weirich 1984 and Sorensen 1994 for versions of this last point.) Indeed, the lower one makes $$f_2$$ (or more generally, some highly dispreferred outcome), the less compelling premise 3 seems; and the lower one makes the probability of salvation (or more generally, of some highly desired outcome), the less compelling premise 3 seems. Yet consistent with premise 1, $$f_2$$ could be (almost) as low as one likes, and consistent with premise 2, the probability of salvation could be (almost) as low as one likes.

11. Recall Schlesinger’s (1994, 90) tie-breaking principle: “In cases where the mathematical expectations are infinite, the criterion for choosing the outcome to bet on is its probability”. Similarly, Golding (1994, 139–140) offers this principle: “given a decision problem where an infinite value is at stake, the option that offers the highest probability of attaining the infinite value is the rational choice, regardless of what other probabilities or finite values are at stake”. This clearly rules out the coin-tossing strategy, the die-tossing strategy, and all the other mixed strategies, since these have lower probabilities of your achieving salvation than outright wagering for God does. Sorensen 1994 objects to Schlesinger’s principle as being ad hoc. One way of putting the objection is that the principle lacks the foundational support that maximizing expected utility has. Bartha 2007, 2016 provides it such support. Be that as it may, Pascal does not appeal to the principle in his argument. As it stands, the argument is apparently invalid.

The problem is that multiplying ∞ by any positive, finite probability again yields ∞. Let us call this property of ∞ reflexivity under multiplication (by such a probability). Such reflexivity is at once the strength of the Wager (for then Pascal does not need to say anything more about your probability of God’s existence), and its weakness (for then all the various mixed strategies get maximal expectation also). One could try to fix the weakness, while saving as much one can of the strength. This would involve finding a utility for salvation that is not reflexive under multiplication, yet which is still sufficiently large to swamp your probability, whatever it is, in the expectation calculation.

For instance, if the utility of salvation were enormous, but finite (as it is on Golding’s reading of the Wager, 1994, 130–131), then the mixed strategies would yield lower expectation than outright wagering for God. Multiplying that utility by 1/2, 1/6, etc. makes a difference. And the utility could be made enormous enough to offset any actual person’s probability assignment, however small (provided it is positive and finite), so that the expectation of outright belief is maximal for everybody. Or suppose that the utility of salvation were an infinite number that is not reflexive under multiplication. Consider, for example, the infinite ‘hyperreal’ numbers of non-standard analysis (see Robinson 1966, Nelson 1987). Or consider the infinite ‘surreal’ numbers of Conway 1976. Multiplication of such a utility by a positive, finite probability (less than 1) yields another, smaller infinite number. So the expectation of wagering for God again exceeds that of wagering against God, and also that of each mixed strategy, whatever your probability is (provided it is positive and finite). Hájek 2004 suggests the hyperreal and surreal approaches. Herzberg 2011 and Chen and Rubio 2020 develop them, offering valid reformulations with hyperreal and surreal utilities, respectively. See Wenmackers 2018, §2.2 for a summary of hyperreal numbers, and the entry on Infinity for summaries of both kinds of numbers.

Another approach, apparently faithful to Pascal’s theology, eschews premise 1’s numerical utilities altogether, opting instead for comparative judgments of value, and making suitable adjustments elsewhere in the argument. For example, Rota 2016 offers a reformulation that replaces premise 1’s values of $$\infty$$, $$f_1$$, $$f_2$$, $$f_3$$, with O1, O2, O3, O4, respectively, where O1 is much greater than O3, and O2 is either greater than, equal to, or only a small amount less than O4. Premise 2’s quantification over all positive probabilities is replaced by one over probabilities of $$1/2$$ or higher. The conclusion essentially is that practical rationality requires agents with such probabilities to wager for God (slightly changing Rota’s wording to conform with ours).


text:
# IEEE 754 square root with Newton-Raphson

I have an implementation of the sqrt function that uses a combination of IEEE 754, packed bitfields, and the Newton-Raphson algorithm:

decompose.h:

#ifndef DECOMPOSE_H
#define DECOMPOSE_H 1

#ifdef __cplusplus
extern "C" {
#endif

#include <float.h>

#define MANTISSA_SIZE 52
#define EXPONENT_SIZE 11
#define EXPONENT_BIAS 0x3ff
#define TYPE double
#define TYPE_MIN DBL_MIN
#define TYPE_MAX DBL_MAX
#define NAME_SFX(name) name

typedef unsigned long long mantissa;
typedef unsigned short exponent;
typedef unsigned char sign;

#include "decompose_generic.h"

#ifdef __cplusplus
}
#endif

#endif

decompose_generic.h:

#ifndef DECOMPOSE_GENERIC_H
#define DECOMPOSE_GENERIC_H 1

#ifdef __cplusplus
extern "C" {
#endif

#define SIGN_SIZE 1

union decompose {
TYPE f;
struct decompose_s {
mantissa m:MANTISSA_SIZE;
exponent e:EXPONENT_SIZE;
sign s:SIGN_SIZE;
} __attribute__((packed)) o;
};

static inline union decompose decompose(TYPE f)
{
union decompose result;
result.f = f;
return result;
}

#define is_nan(x) NAME_SFX(isnan)(x)

#ifdef __cplusplus
}
#endif

#endif

sqrt.c:

#include <math.h>
#include <errno.h>

#include "decompose.h"

TYPE NAME_SFX(sqrt)(TYPE a)
{
TYPE result_old2 = 0;
unsigned short c = 0;
union decompose r = decompose(a);

if(a < -(TYPE)0)
{
errno = EDOM;
return NAME_SFX(nan)("");
}
if(a == (TYPE)0 || is_nan(a) || a > TYPE_MAX)
{
return a;
}

/* Divide the exponent by 2 */
r.o.e -= EXPONENT_BIAS;
r.o.e = (r.o.e & 1) | (r.o.e >> 1);
r.o.e += EXPONENT_BIAS;

/* Newton-Raphson */
while(result_old2 != r.f)
{
if(c % 2 == 0) result_old2 = r.f;
r.f -= (r.f*r.f-a)/(2*r.f);
c++;
}

return r.f;
}

What I'm looking for:

• Are there any efficiency problems?

• Are there any accuracy problems?

• Are there any other miscellaneous things that I can improve?

As far as I've tested, this is as accurate as possible. It even matches the results from the GNU C library.

One note: This is part of a modular system. There will be a decompose.h for each floating point type (float, double, long double), and they all include decompose_generic.h.

I'm slightly new to this area of C (math, IEEE 754), but not so new that I'd add the tag.

• It's a shame this isn't C++, where you could check that the floating-point representation matches your expectation using std::numeric_limits<T>::is_iec559. I don't know of an equivalent test for C, other than separately checking all the macros in <float.h>. – Toby Speight Sep 24 '19 at 16:39
• @TobySpeight __STDC_IEC_559__ – S.S. Anne Apr 19 at 17:32

This answer uses pointer-casting for type-punning just to save space. In practice keep using your union (safe in ISO C99, and in C++ as a GNU and MSVC extension) or memcpy (safe in C and C++). This pointer-casting is only safe in MSVC, or GNU-compatible compilers with -fno-strict-aliasing

# Initial approximation

Packed bit fields are not only unnecessary here, they make the result worse. You do something along the lines of:

uint64_t i = *(uint64_t*)&f;           // double to int
i = i - (1023 << 52);                  // remove IEEE754 bias
i = i >> 1;                            // divide exponent by 2
i = i + (1023 << 52);                  // add IEEE754 bias

If you change the order of operations, you can handle the biasing in a single constant:

uint64_t i = *(uint64_t*)&f;           // double to int
i = i >> 1;                            // divide exponent by 2
i = i + (1023 << 52) - (1023 << 51);   // remove/add IEEE754 bias

The constant can then be simplified to:

uint64_t i = *(uint64_t*)&f;           // double to int
i = (i >> 1) + (1023 << 51);           // all of the above

Note that I didn't bother to mask when shifting, so the exponent's rightmost bit drops into the mantissa, which is shifted as well. This is a feature, not a bug. The IEEE754 formats are deliberately chosen to be monotonic when interpreted as integers, so carry-overs between exponent and mantissa are explicitly allowed.

With my approximation, the mapping is as follows (linear mapping within intervals):

original   number is    exponent   manitssa   orig interval
exponent  in interval   in sqrt   first bit     maps to
0     [  1.0,  2.0 )    0         0       [  1.0,  1.5 )
1     [  2.0,  4.0 )    0         1       [  1.5,  2.0 )
2     [  4.0,  8.0 )    1         0       [  2.0,  3.0 )
3     [  8.0, 16.0 )    1         1       [  3.0,  4.0 )
4     [ 16.0, 32.0 )    2         0       [  4.0,  6.0 )

With your code, the mapping is (also linear within intervals):

original   number is    exponent  orig interval
exponent  in interval   in sqrt     maps to
0     [  1.0,  2.0 )    0     [  1.0,  2.0 )
1     [  2.0,  4.0 )    0     [  1.0,  2.0 )
2     [  4.0,  8.0 )    1     [  2.0,  4.0 )
3     [  8.0, 16.0 )    1     [  2.0,  4.0 )
4     [ 16.0, 32.0 )    2     [  4.0,  8.0 )

# Newton-Raphson

Given a good approximation, Newton-Raphson doubles the number of significant digits on each iteration (quadratic convergence). The above approximation provides about 4 bits of accuracy (max error: 6% or ~1/16), so 3 Newton-Raphson iterations are required for single and 4 iterations for double precision.

The entire code could look like this:

float sqrtf(float x)
{
float y = x;
// Approximation
uint32_t* i = (uint32_t*)&x;
*i = (*i >> 1) + (127 << 22);
// Newton-Raphson
x = (x + y/x) / 2;
x = (x + y/x) / 2;
x = (x + y/x) / 2;
return x;
}

double sqrt(double x)
{
double y = x;
// Approximation
uint64_t* i = (uint64_t*)&x;
*i = (*i >> 1) + (1023 << 51);
// Newton-Raphson
x = (x + y/x) / 2;
x = (x + y/x) / 2;
x = (x + y/x) / 2;
x = (x + y/x) / 2;
return x;
}

# Subnormals and other hazards

You already have special handling for nan, inf, 0 and x < 0, which is good, but we need to handle subnormal numbers as well. The code, both yours and mine, fails when confronted with such numbers. As a remedy, I suggest you scale subnormal numbers by 2^200 and scale the result by 2^-100. I chose 2^200 because it safely brings all subnormals back into normal range for all precisions, including quad, but other numbers work equally well (but only powers of two retain full precision).

Also observe that my code relies on IEEE754 properties. It doesn't work for non-IEEE754 numbers, most notably x86's 80bit extended double format. If you want to handle such numbers, you can convert them to float or double for the approximation step and back to extended double for Newton-Raphson.

• This won't work for 80-bit long double, which can't be represented as an integer. – S.S. Anne Sep 24 '19 at 17:59
• Also note that this violates strict aliasing and is undefined behavior. – S.S. Anne Sep 24 '19 at 19:39
• Your approximation is off by 41% at worst, that's about 1bit. (with my approximation it's ~6%) - @JL2210 – Rainer P. Sep 24 '19 at 19:48
• *(uint64_t*)&f is undefined behaviour in ISO C. It's only well-defined in MSVC or gcc -fno-strict-aliasing. , @JL2210 used a union to type-pun because that's well-defined in ISO C99. (But in C++ only as a GNU extension. They should probably have used memcpy since they bothered to include extern "C" {} stuff in case it's compiled as C++) – Peter Cordes Sep 25 '19 at 0:22
• @JL2210 and Rainer:: The other problem with 80-bit long double is that the leading 1 or 0 in the significand (aka mantissa) is explicit, not implied by the exponent field being non-zero. en.wikipedia.org/wiki/… So shifting a bit from the exponent into the mantissa could be a big problem, potentially creating a non-normalized value that isn't a subnormal. I forget what x86/x87 hardware does in that case. If you were using C++, you could use a std::bitset<sizeof(T)*CHAR_BIT> – Peter Cordes Sep 25 '19 at 0:32

FYI, in IEEE754 sqrt is a "basic" operation that's required to be correctly-rounded (rounding error <= 0.5ulp), same as + - * /. Hardware FPUs (I think) always provide sqrt if they provide the other operations, especially division which is typically implemented similarly (and with similar performance).

NR iterations each involving a division are not going to be faster than HW sqrt. I think that's part of why x86's approximation instructions are for reciprocal and rsqrt, not sqrt: the Newton iteration formula for 1/sqrt(x) doesn't involve division, so on old CPUs with very slow sqrtps compared to mulps, it was worth using sqrt(x) ~= x * approx_rsqrt(x), optionally with a Newton iteration on the approx_rsqrt result. Maybe sometimes still worth doing that in a loop that does nothing else, but normally you should aim for more computational intensity (do more with your data while it's hot in registers; don't write loops that just load/sqrt/store).

IDK if it's possible for your code to converge on a value that's not the correctly-rounded result, but something you should test for by checking against the implementation's sqrt function.

(Call your function something else. With GCC for example, sqrt is a special name unless you use -fno-builtin-sqrt. Callers will inline the sqrt instruction on targets that have one, like x86 sqrtsd, only calling the libc function for inputs that need to set errno. Or never if you compile with -fno-math-errno, always a good idea. Math-errno is an optional feature that not all libcs support, although GNU C does. It's a pretty bad obsolete design that nobody should use; that's why we have fenv.h to check per-thread sticky FP exception flags.)

### Wrong initial guess for inputs < 1.0

 /* Divide the exponent by 2 */
r.o.e -= EXPONENT_BIAS;
r.o.e = (r.o.e & 1) | (r.o.e >> 1);
r.o.e += EXPONENT_BIAS;

Your exponent bitfield type is unsigned short1 so this is a logical right shift.

But anyway, logical right shift is a bug in your initial approximation.

The exponent field is a 2's complement integer (encoded with a bias, but that's just an encoding/decoding detail you already take care of). A logical right shift of a small exponent (like for 0.0001) will result in a large positive exponent from shifting in a zero. Your initial guess for 0.0001 will be something close-ish to DBL_MAX, way above 1.0.

You need an arithmetic right shift of the exponent to bring it closer to the middle exponent value (unbiased) 0 or (biased) 127. Thus bringing the magnitude of the represented value closer to 1.0.

Most C implementations make the sane choice that >> of a signed integer type is an arithmetic right shift. ISO C requires that implementations define which it is, but unfortunately leaves them the choice of logical or arithmetic. (Unlike signed left shift, it can't be UB).

But fortunately your code is written in GNU C (not ISO C), e.g. using __attribute__((packed)) on a struct. GNU C guarantees that >> on signed integers is arithmetic. (And that signed integer types are 2's complement!) So the only implementations that can compile your code are ones where >> on an int does what you want.

(GCC manual, integer implementation-defined behaviour):
Signed ‘>>’ acts on negative numbers by sign extension.

You might want to use unsigned bitfield members and unsigned arithmetic for bias/unbias. But you can safely use int32_t (which is guaranteed to be a 2's complement integer type), or just int for the temporary holding the field value for the bias/unbias calculations. Bias/unbias may cross zero (unsigned wrapping), not signed overflow.

## Or better, use @Rainer P's method:

Don't unbias first, just unsigned shift and then add half the bias constant. (See his answer for how it simplifies down to that). Doing the shift before unbiasing means the exponent is unsigned so shifting in a zero is good. (I think this works right even for tiny values with biased-exponents near zero, i.e. near the smallest possible exponent encoding).

I tried a few values on https://www.h-schmidt.net/FloatConverter/IEEE754.html, manually shifting the exponent and then adding 1 (with carry) to the 2nd-highest exponent bit. e.g. 2.3509887E-38 (biased exponent = 0b0000'0010) becomes 2.1684043E-19 (biased exponent = 0b0100'0001).

But beware when shifting the entire bit-pattern that you don't shift in a 1 from the sign bit of -0.0. You are handling a == 0.0 as a special case so you're fine there because -0.0 == 0.0 is true. I guess you can't let 0.0 go through the main NR loop because you'd have a division by zero.

Footnote 1:

IDK why you'd choose unsigned short instead of just unsigned for your exponent bitfield type. The underlying type of a bitfield can be wider than the field without hurting anything, and some compilers will do math at the width of that type. So using unsigned int if it's wide enough is a good idea. int is at least 16 bits.

Using uint64_t as the bitfield type can result in slow 32-bit code with some compilers (notably MSVC), but I think unsigned int is always fine for the exponent. Unsigned does make sense for the biased exponent.

Fun fact: just int as the bitfield type leaves the signedness up to the implementation. You can use signed int to force signed. https://stackoverflow.com/questions/42527387/signed-bit-field-represetation

### unroll instead of checking c % 2 == 0

A compiler might do this anyway, but it probably makes more sense to just unroll your loop by 2 instead of using a counter to do something special every other iteration.

The actual Newton iteration expression is compact enough that repeating it once is probably more simple for humans to read than working through the c++ and if (c%2 == 0) logic.

You can handle the while(foo) condition as if(!foo) break; when unrolling, or simply leave it out and only check for leaving the loop every 2 Newton iterations, unless you need to check both possibilities to catch alternation between two values.

(With a bad initial estimate that will take many iterations anyway, this might be worth it. Otherwise probably not, especially on a superscalar / out-of-order CPU that can be checking the branch condition in parallel with the main dependency chain which doesn't have a lot of ILP (instruction-level parallelism); mostly one long dependency chain.)

## Pull some checks off the fast-path

Your version has 4 separate checks on a before we reach the actual work.

    if(a < -(TYPE)0)
{
errno = EDOM;
return NAME_SFX(nan)("");
}
if(a == (TYPE)0 || is_nan(a) || a > TYPE_MAX)
{
return a;
}

Instead, catch the special cases with one or two compares, and sort them out in that block, off the fast path. The performance of sqrt(NaN) is much much less important than the performance of sqrt(1.234)

    if(! a > (TYPE)0)
{
if(a == (TYPE)0 || is_nan(a))
return a;
// else a < 0
errno = EDOM;
return NAME_SFX(nan)("");
}
if( a > TYPE_MAX)
{
return a;
}

If you need to handle subnormals specially (at least for generating the initial approximation?), you might use if (! a>=DBL_MIN). Or you could decide that your soft-float implementation simply doesn't handle subnormals.

IDK what your goal is with this code; if it was part of a soft-float library, simply using FP add, mul, and divide seems inefficient. You'd want to optimize multiple operations together and so on.

But if it's for HW FPUs, then I think real all FPUs will have sqrt built-in as well.

So I assume this is just a learning exercise. So we won't get into too detail of optimizing it for any particular hardware or compiler.

• @JL2210: I know you can't have int a:64, that's why I said the underlying type can be wider (than the field) without causing a problem, not vice versa. Apparently my wording is easy to misread, will think about how to fix. – Peter Cordes Sep 25 '19 at 2:05
• @JL2210: Oh. I meant always fine for the exponent where you were previously using unsigned short. Because both types have the same minimum width in ISO C. I meant that using uint64_t e:8 could give slower-than-necessary code for the exponent. Specifically with MSVC, I was remembering writing this answer: Unresolved external symbol __aullshr when optimization is turned off – Peter Cordes Sep 25 '19 at 2:09
• @JL2210: Oh yes, I missed that you check separately for == 0.0. I was assuming that you would just use one check on the fast-path to exclude both negative an NaN inputs by requiring that x >= 0.0. That's false for NaN so you can move the isnan check inside an if that won't run for the fast-path. So you can do if (! x>0.0) { further checks to detect +=0.0, NaN, or negative } – Peter Cordes Sep 25 '19 at 23:28
• @JL2210: Updated my answer to fix that mistake you pointed out, and talk about some of the stuff I've said in comments. And more. – Peter Cordes Sep 26 '19 at 0:08
• @JL22: Like I said at the top of my answer, sqrt is required by IEEE to be correctly-rounded, just like + - * and /. All x86 sqrt instructions do that. (Except of course rsqrtps which intentionally gives a fast approximation of 1/sqrt(x)). Intel's compiler enables fast-math by default (unlike GCC), but Intel's HW is IEEE-compliant. Perhaps you're thinking of instructions like fsin, which aren't required to be correctly rounded and which in practice have huge relative error near Pi/2. randomascii.wordpress.com/2014/10/09/… – Peter Cordes Sep 26 '19 at 0:27

I don't see why you define this constant yourself:

#define MANTISSA_SIZE 52

Given we already assume that FLT_RADIX is 2, we can use the appropriate macro from <float.h> (DBL_MANT_DIG for double, etc.).

I think there's danger of integer overflow here:

/* Divide the exponent by 2 */
r.o.e -= EXPONENT_BIAS;
r.o.e = (r.o.e & 1) | (r.o.e >> 1);
r.o.e += EXPONENT_BIAS;

We'd be better extracting into a big enough temporary, and applying the exponent bias to that:

int e = r.o.e - EXPONENT_BIAS;
e = (e & 1) | (e >> 1);
r.o.e = e + EXPONENT_BIAS;

It might be possible to shift in place and then correct using half the bias; I haven't checked whether that's equivalent.

• Signed bit-shifting isn't well-defined. I don't think the second half of your answer is valid. – S.S. Anne Sep 24 '19 at 17:10
• I agree with the top point, but it would be DBL_MANT_DIG-1, not DBL_MANT_DIG. – S.S. Anne Sep 24 '19 at 17:33
• @JL2210: Is right-shifting a signed bitfield any better defined than a signed int? Doesn't your current code still rely on >> being an arithmetic right shift that shifts in 1s for negative exponents? Yes it's implementation-defined whether it's arithmetic or logical (not undefined). However your code uses GNU C __attribute__((packed)) so you actually can rely on arithmetic right shift if you're intentionally writing in GNU C, not ISO C. gnu.huihoo.org/gcc/gcc-4.9.4/gcc/Integers-implementation.html specifies that "Signed ‘>>’ acts on negative numbers by sign extension." – Peter Cordes Sep 25 '19 at 1:04
• @JL2210: Yeah, just noticed that. I assumed they would be signed because unsigned right-shift of the 2's complement exponent (after unbiasing) doesn't make sense, does it? A negative exponent (small magnitude float) becomes a very large positive exponent (close-ish to DBL_MAX) after your logical right shift of the exponent field. Or am I missing something and your function does work correctly for inputs like 0.0001? – Peter Cordes Sep 25 '19 at 1:07
• @JL2210: Hardware that reads the float will effectively undo the bias. It's just an encoding method; the real value is a 2's complement integer. That's what you're working with after undoing the bias (decoding). Yes you have to redo the encoding to make it an IEEE float again, but so what? BTW, if you were to logical right-shift without undoing the bias first, you'd make values twice as close to the smallest possible exponent value instead of twice as close to the middle value (0 after bias). So 1.0f would become 1e-17f or something, if FLT_MIN is about 1e-34f. – Peter Cordes Sep 25 '19 at 1:22

## Modular odd check

The compiler is likely to do this anyway, but can't

if(c % 2 == 0)

be

if (!(c & 1))

?

## Factoring

Isn't

r.f -= (r.f*r.f-a)/(2*r.f);

equivalent to:

r.f = (r.f + a/r.f)/2?

## Optimization

Depending on which compiler you're using and what flags you pass it, some of your attempted math risks modification by the optimizer, and in an implementation so closely coupled to the hardware, this might matter. Have you checked your produced assembly? Can you show us your build flags?

• Under Factoring: That's Newton-Raphson, it detects the amount of error and decreases it. It's not the same as (1-a)/2. – S.S. Anne Sep 24 '19 at 15:39
• Soooo. The problem isn't with my answer (and I don't think it should receive your edit, yet); it's with the code you posted. A strict interpretation of the CR policies would suggest that since there's already an answer, you can't edit your code. However, I think instead that you should edit your question to show your actual (non-preprocessed) code, and I'll then amend this answer myself. – Reinderien Sep 24 '19 at 15:47
• @Reinderien Thanks. I've added a clarification. – S.S. Anne Sep 24 '19 at 15:50
• Re. factoring: So my first stab at the math was wrong, and I modified it to reflect reality. – Reinderien Sep 24 '19 at 16:04
• I immediately know what if(c % 2 == 0) does, but I have to think multiple times to figure out what if (!(c & 1)) does. That's premature optimization and IMHO violates clean code rules (KISS). – Thomas Weller Sep 26 '19 at 11:57

format: plain


text:
# PDE wave equation

1. Dec 2, 2012

2. Dec 5, 2012

### dextercioby

Putting a countable infinity of A's and B's instead of only 2 values A and B is a standard technique in Fourier analysis, which is particulary well suited for linear ODE's/PDE's. That is you rightfully assume that, because the linear/vector space of solutions is infinite dimensional, there is one (generally different) coefficient for each basis vector of the solution space, hence the infinite summation.

3. Dec 6, 2012

### HomogenousCow

Which part of it do you not understand.
This is how a homogenous linear PDE is usually solved:
1.Seperate equation (possible for many of the usual PDEs)
2.Solve the equations to get a "basis"
3.Write an infinite sum with them
4.Use the imposed initial/boundary conditions to solve for the coefficients of the linearly independent solutions with the generalized Fourier's trick

If none of that made sense to you, then you are not ready for that book.


text:
# Benchmarks¶

## Comparison to other t-SNE implementations¶

We benchmark openTSNE (v0.6.0) against three popular open-source implementations from scikit-learn (v0.24.2), MulticoreTSNE (v0.1), and FIt-SNE (v1.2.1). The benchmarks were run on a server-grade Intel Xeon E5-2650 processor. To generate benchmark data sets of different sizes, we subsampled data from the 10X Genomics 1.3 million mouse brain data set five times, resulting in five different data sets for each size. In total, we run each implementation on 30 different data sets.

For each run, five separate datasets were generated by sampling from the 10X 1.3 Million Brain Cells dataset (available here). We reduce the number of dimensions to 50 principal components, following the standard single-cell pipeline. Each t-SNE implementation was then run on every dataset using the following parameters: perplexity=30, learning_rate=200 for 250 early exaggeration iterations with exaggeration 12 and 750 standard iterations with exaggeration 1. Other parameters were set to their default values. This was then repeated for different sample sizes (1,000, 100k, 250k, 500k, 750k, 1mln) resulting in 30 runs for each implementation.

We can immediately see the differences between the different t-SNE approximation schemes used by different algorithms. Both MulticoreTSNE and scikit-learn use the Barnes-Hut approximation by default with O(N log N) scaling. On the other hand, FIt-SNE and openTSNE both make use of the FIt-SNE approximation algorithm with linear time complexity, which is clearly visible from the figure.

While the Python runtime inevtiably incurrs some overhead, making openTSNE slightly slower than FIt-SNE, both implementations have comparable runtimes. openTSNE makes this slight performance trade-off for the benefit of ease of installation and a much more flexible and familliar API.

## Comparison to UMAP¶

UMAP is another widely popular dimensionality reduction technique. We here benchmark openTSNE (v0.6.0) to umap-learn (v0.5.1), the most popular publicly available Python UMAP implementation. We use the same setup as before, downsampling the 10X Genomics mouse brain data set five times. Because UMAP makes use of numba and requires JIT compilation, we add an additional warmup run to ensure a fair comparison. Different from before, we run t-SNE with the default parameters, decreasing the number of total iterations to 750 and using the automatic learning rate.

We see that while UMAP in indeed faster in the single-threaded case, openTSNE tends to perform much better in the multi-threaded scenario. This is likely due to the fact that the optimization phase of UMAP is not parallelizable, while openTSNE makes heavy use of parallelism in every stage of the algorithm. We see that for large data sets, openTSNE is almost twice as fast as UMAP with clear linear scaling. Somewhat surprising is the single-threaded UMAP trend. While it is clearly faster than openTSNE, the scaling does not appear to be linear, like the scaling exhibited by openTSNE, indicating that openTSNE may be faster than UMAP even in the single-threaded case for larger data sets.

Another caveat is that for large data sets, it is highly recommended to increase the exaggeration parameter in t-SNE. This creates cleaner embeddings with good separation. These embeddings are fairly similar to the embeddings produced by UMAP. However, openTSNE actually runs faster when increasing the exaggeration. Therefore, in practice, the speed differences between openTSNE and UMAP are likely even greater. However, we run the algorithms here with default parameters to ensure a fair comparison.

In practice, virtually every computer contains multiple cores. For example, consumer grade Intel i7 processors commonly have 8 cores, making the multi-threaded case more relevant to the majority of users.

## Caveats when running benchmarks¶

When running benchmarks on machines with multiple cores using Intel’s Math Kernel Library (MKL), care must be taken to properly limit the number of threads available. The number of threads should be limited by setting the environmental variable OMP_NUM_THREADS=X, where X is the number of threads. This is important when using a numpy distribution linked against the MKL. Both openTSNE and scikit-learn make heavy use of numpy. By default, the MKL will use all available cores by default, ignoring the user-defined n_jobs parameters. Failure to do so will allow MKL to use all available cores, resulting in an unfair comparison.

Similarly, care must be taken when benchmarking against numba-dependent libraries e.g. umap-learn. In addition to specifying OMP_NUM_THREADS=X, we must also specify the NUMBA_NUM_THREADS=X environmental variable. Failure to do so will allow numba to use all available cores, resulting in an unfair comparison. Additionally, each numba-dependent library should be run for a warm-up round so numba can perform its bytecode compilation without negatively affecting the benchmarks. Failure to do so will result in the first run being noticeably slower, skewing the overall results.

## Reproducibility¶

All benchmarks were run on an Intel(R) Xeon(R) CPU E5-2650 v4 @ 2.20GHz processor. We also ran a subset of these benchmarks on a consumer-grade Intel Core i7-7700HQ processor found in laptop computers. The general trends were similar. All benchmarks were run using the provided benchmark script in the openTSNE repository openTSNE/benchmarks/benchmark.py. The data set used can be found in the example notebooks. A direct link to the preprocessed pickled matrix file is available at http://file.biolab.si/opentsne/10x_mouse_zheng.pkl.gz.


text:
×
Back to all chapters

# 2D Dynamics

With 2D dynamics, we can explain the orbit of the planets around the Sun, the grandfather clock, and the perfect angle to throw a snowball to nail your nemesis as they run away from you.

# 2D Dynamics: Level 1-2 Challenges

On a moving train, a passenger who is seated facing the front, tosses a coin up in the air. Given that the coin falls into the lap of the person sitting behind this person, what can we say about the motion of the train?

Note:

• All the people are facing the front of the train.

• All the windows/doors are shut.

You are hovering in a helicopter well above the Earth's surface such that the helicopter is suspended in mid air, stationary with respect to the Earth. The Earth is rotating at the same time. Why should you fly to my destination, if it will come to you due to Earth's rotation?

As shown in the picture, water flows from the bottle into the cup. What explains this phenomena?

Details

• Note, the picture is upside down. The Earth is in the top of the photo and the bottom of the plane is facing the atmosphere.

A particle is moving on an elliptical path as shown, at a constant speed. At which point is the particle's acceleration at maximum?

A point-mass (particle) is shot up an inclined plane that makes an angle $$\theta$$ with the ground. It slides up the incline to a certain distance, and then slides all the way back down. However, due to friction, the time it takes for the particle to slide from the maximum distance it reaches up the incline back to the bottom is twice the time it takes for it to go to the maximum distance up the incline from the bottom.

The coefficient of friction $$\mu$$ between the particle and the incline can be written as $$\frac{a}{b}\tan\theta$$, where $$a$$ and $$b$$ are co-prime positive integers.

What is the value of $$a + b$$?

×


text:
ТЕСТ ПЕНЛЕВЕ ДЛЯ ОДНОЙ СИСТЕМЫ МАГНИТНОЙ ГИДРОДИНАМИКИ

Г.М. Водинчар, Д.С. Нощенко, А.С. Пережогин, G.M. Vodinchar, D.S. Noshenko & A.S. Perezhogin
One approximation of magnetohydrodynamics equations, which describe the cosmic object’s magnetic field, is considered. The analytic properties of a nonlinear system are investigated by Painleve? test. Values of the coefficients in a simplified magnetohydrodynamics system are calculated for the necessary condition of Painleve? property.


text:
Now showing items 1125-1144 of 1669

• #### Qualitative Investigation of Mexican-American Experiences of Racial Microaggressions

(2011-08)
Racial microaggressions are the brief, commonplace racial slights and insults that are expressed by Whites against people of color (Sue, Capodilupo et al, 2007). This qualitative study examined previously unexplored area ...
• #### Quantifying T cell Mediated Killing for Melanoma Immunotherapy

(2014-12)
Adoptive cell therapy (ACT), based on the adoptive transfer of tumor-infiltrating lymphocytes (TILs) has well-recognized advantages such as (1) high specificity for target cells; (2) the ability to target even micrometastases; ...
• #### Quantitative Comparison of Channel-belt Dimensions, Internal Architecture and Characteristics of Two Fluvial Systems in Sequence 1, Ferron Notom Delta, South-Central Utah, U.S.A.

(2013-05)
The geometry, proportion, and spatial distribution of fluvial deposits are critical components in subsurface reservoir analysis, but their prediction can be difficult. This study describes and compares an amalgamated, high ...
• #### Quantitative comparison of metrics for human pose estimation

(2013-08)
Human Pose Estimation is an important problem in computer vision that has received considerable attention in recent years. The multitude of application's related to Visual Surveillance, Human Computer Interaction and ...
• #### QUANTUM MECHANISMS OF DENSITY WAVE TRANSPORT

(2012-12)
The non-linear properties observed in charge density wave compounds have been studied for many years. The quasi one-dimensional conductor NbSe3 is particularly important because a small electric field can depin the charge ...
• #### Quaternary Depositional History of a Shelf-Margin Minibasin, Northern Gulf of Mexico

(2015-05)
High-resolution 3D seismic data were used to study the evolution of a shelf- margin minibasin located approximately 160 km off of the coast of Louisiana. Depositional packages were delineated and classified based on observed ...
• #### QUEERING SILENCE: A NARRATIVE LOOK AT THE PARALLEL STORIES OF LGBT AND HARD OF HEARING STUDENTS IN THE EDUCATIONAL SETTING

(2010-12)
We are told from an early age not judge a book by its cover. This idiom is the perfect way to look at my research; it expresses the idea that what we present on the outside is, many times, a cloak to hide what is really ...
• #### Race as a Moderator of Neighborhood Home Ownership and Adolescent Externalizing Problems

(2015-05-15)
Theories and research on mental health disparities among adolescents suggest that non-White people groups are exposed to an unequal burden of stress. One factor that contributes to this unequal burden of stress is ...
• #### Radiation Therapy Optimization under Uncertainty for Lung Cancer: Interplay Effects and Tumor Shrinkage

(2014-06-09)
Radiation therapy is a complex process where a given target volume receives a given dose of radiation divided over one or multiple treatments. Every step in this process can introduce some types of uncertainties into the ...
• #### RADIO-FREQUENCY ELECTROMAGNETIC CHARACTERIZATION OF BIOMATTER AND NANOPARTICLES FOR BIOMEDICAL APPLICATIONS

(2012-08)
The influence of radio-frequency (rf) electromagnetic fields on biological tissues plays a critical role in their diagnostic and therapeutic applications. These include hyperthermia and rf ablation modalities for cancer, ...
• #### Random Walks on a Lattice with Deterministic Local Dynamics

(2012-08)
In this thesis we prove statistical properties of dynamical systems on a lattice with randomly occurring jumps. The original model of this type, called a hybrid system, was introduced by E. Kobre and L. S. Young in 2007. ...
• #### RANK ONE DYNAMICS NEAR HETEROCLINIC CYCLES AND CONDITIONAL MEMORY LOSS FOR NONEQUILIBRIUM DYNAMICAL SYSTEMS

(2013-08)
There are two parts in this dissertation. In the first part we prove that genuine nonuniformly hyperbolic dynamics emerge when flows in $\mbb{R}^{N}$ with homoclinic loops or heteroclinic cycles are subjected to certain ...
• #### RAYLEIGH WAVE TOMOGRAPHY OF TEXAS FROM AMBIENT SEISMIC NOISE

(2013-05)
Texas has been one of the leading states in petroleum production since the discovery of the Spindletop oil field in 1901. Despite its huge economic value of petroleum and numerous geophysical explorations in several oil ...
• #### Re-Os Geochronology of the Monterey Formation, Union Leroy 51-18 Well, Santa Maria Basin, California

(2015-07-31)
The Os isotopic composition of marine Miocene strata records chronological variations in the world’s oceans. These Os- isotope variations exhibit changes in global seawater geochemistry that result from tectonic, paleoclimate ...
• #### Reaction Kinetics of Metal Deposition by Surface Limited Redox Replacement of Upd Monolayer

(2015-08-14)
Noble metal coatings have been used in many applications such as catalysts, corrosion protection, and microelectromechanical systems (MEMs). Using the monolayer coating concept lowers the ultimate cost by reducing noble ...
• #### Reconfigurable Optical Networks and Multi-Photon Quantum Cryptography

(2015-08-14)
Internet traffic keeps increasing in the past years and it is dominated by various multimedia applications with different requirements. Due to the explosion of information, traditional network architecture cannot meet the ...
• #### RECONOCIMIENTO LÉXICO Y COMPRENSIÓN LECTORA DE LOS ESTUDIANTES DE ESPAÑOL COMO LENGUA DE HERENCIA

(2015-05)
Con el fin de contribuir a la discusión sobre la alfabetización avanzada de los estudiantes de español como lengua de herencia (ELH), este estudio se propone examinar el desarrollo de la competencia léxica y la comprensión ...
• #### RECONSTRUCTION MODELS TO IMPROVE IMAGE QUALITY

(2013-12)
High-resolution images provide more information for better post-processing such as detection, recognition, segmentation, identification, and visualization. The need for high-resolution images occurs in health care, where ...
• #### Recycling Produced Water in Hydraulic Fracturing: A Comprehensive Analysis of its Impact on the Formations of the Appalachian Basin

(2015-08-20)
Environmental interest, regulation changes, and costs have motivated the oil and gas industry to begin recycling produced water in high concentrations during new well stimulation. Accordingly, the potential impact of ...
• #### Redefining tumor suppressor microRNAs: functional complexities & nanoparticle mediated delivery

(2012-12)
MicroRNAs (miRNAs) are 22-24 nucleotides non-coding RNAs that can simultaneously influence the levels of multiple target genes and have the potential to strongly silence multiple gene networks. MYCN and ALK are well ...


text:
StudentZone

# Thévenin equivalent circuit and maximum power transfer

After the introduction of the SMU ADALM1000 let’s continue with the third part of our ADALM1000 series with some small, basic measurements.

Now let’s get started with the next experiment.

Objective

The objective of this lab activity is to verify Thévenin’s theorem by obtaining the Thévenin equivalent voltage (VTH) and Thévenin equivalent resistance (RTH) for the given circuit, and then to verify the maximum power transfer theorem.

Background

Thévenin’s theorem is a process by which a complex circuit is reduced to an equivalent circuit consisting of a single voltage source (VTH) in series with a single resistance (RTH) and a load resistance (RL). After creating the Thévenin equivalent circuit, the load voltage VL or the load current IL may be easily determined.

One of the principal uses of Thévenin’s theorem is to replace a large portion of a circuit, often a more complicated and uninteresting part, with a simple equivalent. The new simpler circuit enables rapid calculations of the voltage, current, and power than the more complicated original circuit is able to deliver to a load. The theorem also helps to choose the optimal value of the load (resistance) for maximum power transfer.

The maximum power transfer theorem states that an independent voltage source in series with a resistance, ${R}_{S}$, or an independent current source in parallel with a resistance RS delivers a maximum power to the load resistance, ${R}_{L}$, when  ${R}_{L}={R}_{S}$.

In terms of a Thévenin equivalent circuit, maximum power is delivered to the load resistance ${R}_{L}$ when ${R}_{L}$ is equal to the Thévenin equivalent resistance, ${R}_{TH}$, of the circuit.

Materials

• Various resistors (100 Ω, 330 Ω, 470 Ω, 1 kΩ, and 1.5 kΩ)

Procedure

1.   Verifying Thévenin’s theorem:

a) Construct the circuit of Figure 2 using the following component values:

• ${R}_{1}=330\Omega$
• ${R}_{2}=470\Omega$
• ${R}_{3}=470\Omega$
• ${R}_{4}=330\Omega$
• ${R}_{5}=1k\Omega$
• ${R}_{L}=1.5k\Omega$
• ${V}_{S}=5V$

b) Accurately measure the voltage ${V}_{L}$ across the load resistance using the ALM1000 voltmeter tool. Use the voltmeter tool by connecting channel CA to the positive node of ${V}_{L}$ and connect channel CB to the negative ${V}_{L}$ will be the difference between CA volts and CB volts. This value will later be compared to the one you will find using the Thévenin equivalent.

c) Find ${V}_{TH}$: Remove the load resistance, ${R}_{L}$, and measure the open circuit voltage, ${V}_{OC}$, across the Use the voltmeter tool by connecting channel CA to the positive node of ${V}_{OC}$ and connect channel CB to the negative node. ${V}_{OC}$ will be the difference between CA volts and CB volts. This is equal to ${V}_{TH}$. See Figure 4.

d) Find ${R}_{TH}$: Remove the source voltage ${V}_{S}$ and construct the circuit as shown in Figure Use the ALM1000 ohmmeter tool to measure the resistance looking into the opening where ${R}_{L}$ was. This gives ${R}_{TH}$. Make sure there is no power applied to the circuit before measuring with the ohmmeter and that the ground connection has been moved as shown.

e) Obtaining ${V}_{TH}$ and ${R}_{TH}$, construct the circuit of Figure 2. Create the value of ${R}_{TH}$ using a series and or parallel combination of resistors from your parts Using the meter-source tool, connect channel CA for the ${V}_{TH}$ source and set the value to what you measured for ${V}_{TH}$ in Step c.

f) With ${R}_{L}$ set to the $5k\Omega$ used in Step b, measure the ${V}_{L}$ for the equivalent circuit and compare it to the ${V}_{L}$ obtained in Step b. This verifies the Thévenin theorem.

g) Optional: repeat Step 1b to Step 1f for ${R}_{L}=2.2k\Omega$.

2. Verifying the maximum power transfer theorem:

a) Construct the circuit as in Figure 7 using the following values:

• ${V}_{S}=5V$
• ${R}_{1}={R}_{2}=470\Omega$
• ${R}_{3}=1k\Omega$
• ${R}_{L}=$ combinations of $1k\Omega$ and $100\Omega$ resistors (Figure 8)

b) Use the voltmeter tool by connecting channel CA to the positive node of ${V}_{L}$ and connect channel CB to the negative node across ${R}_{L}$${V}_{L}$ will be the difference between CA volts and CB

c) To find the value of ${R}_{L}$ for which maximum power is transferred, vary the load resistances by constructing series/parallel combinations of $1k\Omega$ and $100\Omega$ for ${R}_{L}$between ${R}_{L}$ to $1400\Omega$ in $100\Omega$ steps, as shown in Figure 8. For each value of ${R}_{L}$, write down ${V}_{L}$.

d) Calculate the power for each load resistor value using ${P}_{L}=\frac{{{V}_{L}}^{2}}{{R}_{L}}$. Then, interpolate between your measurements to calculate the load resistor value corresponding to the maximum power (${P}_{L}$-max). This value should be equal to ${R}_{TH}$ of circuit in Figure 7 with respect to load terminals.

Questions

• Using voltage division for the circuit of Figure 2, calculate ${V}_{L}$. Compare it to the measured Explain any differences.
• Calculate the maximum power transmitted to the load ${R}_{L}$ obtained for the circuit of Figure 3.

You can find the answers at the StudentZone blog.

Notes

As in all the ALM labs, we use the following terminology when referring to the connections to the ALM1000 connector and configuring the hardware. The green shaded rectangles indicate connections to the ADALM1000 analog I/O connector. The analog I/O channel pins are referred to as CA and CB. When configured to force voltage/measure current, –V is added (as in CA-V) or when configured to force current/measure voltage, –I is added (as in CA-I). When a channel is configured in the high impedance mode to only measure voltage, –H is added (as in CA-H).

Scope traces are similarly referred to by channel and voltage/current, such as CA-V and CB-V, for the voltage waveforms, and CA-I and CB-I for the current waveforms.

We are using the ALICE rev 1.1 software for those examples here.

The ALICE desktop software provides the following functions:

• A 2-channel oscilloscope for time domain display and analysis of voltage and current
• The 2-channel arbitrary waveform generator (AWG) controls.
• The X and Y display for plotting captured voltage and current voltage and current data, as well as voltage waveform histograms.
• The 2-channel spectrum analyzer for frequency domain display and analysis of voltage
• The Bode plotter and network analyzer with built-in sweep generator.
• An impedance analyzer for analyzing complex RLC networks and as an RLC meter and vector
• A dc ohmmeter measures unknown resistance with respect to known external resistor or known internal 50 Ω.
• Board self-calibration using the AD584 precision 2.5 V reference from the ADALP2000 analog parts kit.
• ALICE M1K voltmeter.
• ALICE M1K meter source.
• ALICE M1K desktop tool.


text:
Ideal Flow Network Anaysis using Python

Ideal Flow Network is a new concept to analyze transportation and communication networks. In this tutorial, we will use a simple network (visualized using graphiz).

First, you need to download and install graphiz and numpy. The code of IdealFlowNetwork module is available in GitHub.

In [1]:
import graphviz as dg
import numpy as np
import IdealFlowNetwork as ifn

Suppose we have the following strongly connected network

In [2]:
d=dg.Digraph(engine='circo')
d.edge("a","b")
d.edge("a","c")
d.edge("a","d")
d.edge("d","e")
d.edge("e","a")
d.edge("e","d")
d.edge("c","b")
d.edge("b","d")
d.edge("e","c")
d

Out[2]:

The capacity matrix is shown as follow. The positive numbers represent the number of lanes in the links. Zero means no links between nodes.

In [3]:
#   a  b  c  d  e
C=[[0, 1, 1, 1, 0],   # a
[0, 0, 0, 1, 0],   # b
[0, 1, 1, 0, 0],   # c
[0, 0, 0, 0, 2],   # d
[1, 0, 1, 2, 0]
]
C

Out[3]:
[[0, 1, 1, 1, 0],
[0, 0, 0, 1, 0],
[0, 1, 1, 0, 0],
[0, 0, 0, 0, 2],
[1, 0, 1, 2, 0]]

The adjacency matrix of the capacity matrix that is strongly connected is always irreducible matrix. Let us test using the following code.

In [4]:
A=ifn.capacity2adj(C)
ifn.isIrreducible(A)

Out[4]:
True

We compute the stochastic matrix as follow

In [5]:
S=ifn.capacity2stochastic(C)
print('stochastic matrix=\n',S)

stochastic matrix=
[[ 0.          0.33333333  0.33333333  0.33333333  0.        ]
[ 0.          0.          0.          1.          0.        ]
[ 0.          0.5         0.5         0.          0.        ]
[ 0.          0.          0.          0.          1.        ]
[ 0.25        0.          0.25        0.5         0.        ]]

We can check network efficiency based on the entropy ratio. A network is efficient if it has maximum entropy. Efficient network happens if the outflow probability distribution in each node is uniformly distributed in term of time and space. In this example the network efficiency is 98%.

In [6]:
print('Entropy=', ifn.networkEntropy(S))
print('Entropy ratio=', ifn.entropyRatio(S))

Entropy= 2.83148024007
Entropy ratio= 0.979624933136

Now we can compute flow matrix F that represents the flow in each link.

In [7]:
F=ifn.capacity2idealFlow(C)
print('Ideal Flow matrix=\n', F)

Ideal Flow matrix=
[[ 0.     0.025  0.025  0.025  0.   ]
[ 0.     0.     0.     0.125  0.   ]
[ 0.     0.1    0.1    0.     0.   ]
[ 0.     0.     0.     0.     0.3  ]
[ 0.075  0.     0.075  0.15   0.   ]]

Notice that the sum of rows and sum of columns of an ideal flow matrix are always the same.

In [8]:
sR=ifn.sumOfRow(F)
sC=ifn.sumOfCol(F)
print('sum of row=',sR,'\n')
print('sum of columns=',sC,'\n')

sum of row= [[ 0.075]
[ 0.125]
[ 0.2  ]
[ 0.3  ]
[ 0.3  ]]

sum of columns= [[ 0.075  0.125  0.2    0.3    0.3  ]]

Premagic matrix means the matrix has exactly the same sum of rows as the sum of columns.

In [9]:
print('isPremagic(F)=',ifn.isPremagic(F),'\n')

isPremagic(F)= True

Ideal flow matrix is defined as premagic (the flow are conserved), strongly connected (irreducible) and non-negative.

In [10]:
print('isIrreducible(F)=', ifn.isIrreducible(F))
print('isNonNegative(F)=', ifn.isNonNegative(F))
print('is Ideal Flow(F)=', ifn.isIdealFlow(F))

isIrreducible(F)= True
isNonNegative(F)= True
is Ideal Flow(F)= True

## Example of Efficient Network¶

In the following example, we will examine an efficient network. Let us define an adjacency matrix.

In [11]:
#   a  b  c  d
A=[[0, 0, 1, 1],   # a
[1, 0, 0, 0],   # b
[0, 1, 0, 1],   # c
[0, 1, 0, 0],   # d
]
A=np.asarray(A)
A

Out[11]:
array([[0, 0, 1, 1],
[1, 0, 0, 0],
[0, 1, 0, 1],
[0, 1, 0, 0]])

We can draw this network

In [12]:
d1=dg.Digraph(engine='circo')
d1.edge("a","c")
d1.edge("a","d")
d1.edge("b","a")
d1.edge("c","b")
d1.edge("c","d")
d1.edge("d","b")
d1

Out[12]:

We can obtain the ideal flow directly from adjacency matrix and the outflow probability distribution of each node would be equal (uniform distribution).

In [13]:
F=ifn.adj2idealFlow(A)
print('F=',F,'\n')

F= [[ 0.          0.          0.15384615  0.15384615]
[ 0.30769231  0.          0.          0.        ]
[ 0.          0.07692308  0.          0.07692308]
[ 0.          0.23076923  0.          0.        ]]

The sum of rows of ideal flow matrix is always equal to the sum of columns. This property is called premagic property.

In [14]:
sR=ifn.sumOfRow(F)
sC=ifn.sumOfCol(F)
print('sum of row=',sR,'\n')
print('sum of columns=',sC,'\n')
print('isPremagic(F)=',ifn.isPremagic(F),'\n')

sum of row= [[ 0.30769231]
[ 0.30769231]
[ 0.15384615]
[ 0.23076923]]

sum of columns= [[ 0.30769231  0.30769231  0.15384615  0.23076923]]

isPremagic(F)= True

We can easily scale ideal flow matrix by a scaling factor, kappa, which is the same as the total flow.

In [15]:
kappa=1000
print('F=',F,'\n')

F= [[   0.            0.          153.84615385  153.84615385]
[ 307.69230769    0.            0.            0.        ]
[   0.           76.92307692    0.           76.92307692]
[   0.          230.76923077    0.            0.        ]]

We can get back the stochastic matrix based on ideal flow matrix.

In [16]:
S=ifn.idealFlow2stochastic(F)
print('S=',S,'\n')

S= [[ 0.   0.   0.5  0.5]
[ 1.   0.   0.   0. ]
[ 0.   0.5  0.   0.5]
[ 0.   1.   0.   0. ]]

Observe that our entropy ratio is 1, that means a network with uniform distribution of outflow is the most efficient network. The proof of this theorem can be found in my paper in EASTS journal.

In [17]:
print('Entropy=', ifn.networkEntropy(S))
print('Entropy ratio=', ifn.entropyRatio(S))

Entropy= 1.38629436112
Entropy ratio= 1.0

last update: Sept 2017

Cite this tutorial as:

Teknomo,K. (2017) Ideal Flow Network Anaysis using Python (http://people.revoledu.com/kardi/tutorial/Python/Ideal+Flow.html)


text:
# Is there an MPI All Gather operation for matrices?

I have a distributed matrix, in block column format. I know that I can reshape the matrix into one long vector and use an all_gatherv operation. I just wanted to avoid the trouble of having to reshape the matrix in my code. So, I was wondering if there's an mpi all gather operation so that in the end, every processor has an exact copy of the full matrix.

• How is the matrix stored? Sparse or dense? How did you end up with a system distributed like this and what are you going to do with it once you have a redundant copy everywhere? – Jed Brown Mar 9 '12 at 13:55
• it is related to a previous question I asked: scicomp.stackexchange.com/questions/1283/…. – Paul Mar 13 '12 at 3:26
• @JedBrown: Let's say I have 100 large linear systems on each of 10 processors (so 1000 systems in total). The solution of each linear system produces 1 value of interest, so each processor ends up with 100 values of interest. These 'values of interest' form a distributed vector, which I am using an all-gather operation so that each processor gets the entire vector. Each processor is then going to assemble and solve the same linear system (redundant work) to avoid communication costs. The algorithm iteratively repeats this process. – Paul Mar 13 '12 at 3:32
• From this description, it sounds like you have no use for "gathering" distributed sparse matrices, you just need to gather the small (dense) vector. – Jed Brown Mar 13 '12 at 15:03
• For a 1D problem, I'm only gathering a 1D vector. I'm trying to apply the code to a 2D problem, which would require a 2D matrix (at least, that how I want to structure the decomposition of the problem). – Paul Mar 13 '12 at 23:24

If this is a dense matrix, it's pretty straightforward; you use MPI_Type_create_subarray or something similar (you could build it yourself out of MPI_Type_vector or whatever; MPI_Type_struct() is the just about the most general possible option) to define a single column as a datatype. (In Fortran, you wouldn't even have to do that, you'd just send (nrows) values at a time, but you'd have the same issue if you wanted to send rows instead.) Then you need to resize the datatype so that they "start" and "end" at the right place, and you're ready to start allgatherv'ing in units of columns:

#include <mpi.h>
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>

void printMatrix (float **m, int rows, int cols)
{
for (int i = 0; i < rows; ++i) {
printf ("%3d: ", i);
for (int j = 0; j < cols; ++j)
printf ("%2.0f ", m[i][j]);
printf ("\n");
}
}

float **allocMat (int rows, int cols)
{
float  *data   = (float  *) malloc (rows * cols * sizeof(float));
float **matrix = (float **) malloc (rows * sizeof(float *));
for (int i = 0; i < rows; i++)
matrix[i] = & (data[i * cols]);
return matrix;
}

int main (int argc, char *argv[])
{
int   size, rank;
int   i, j;
const int root = 0;
const int globalncols = 10, globalnrows = 10;
int ncols, start;
int *allncols, *allstarts;
float **matrix;
MPI_Datatype columnunsized, column;

MPI_Init (&argc, &argv);
MPI_Comm_size (MPI_COMM_WORLD, &size);
MPI_Comm_rank (MPI_COMM_WORLD, &rank);

/* everyone's number of columns and offsets */
allncols = malloc(rank * sizeof(int));
allstarts= malloc(rank * sizeof(int));

/* everyone gets a global matrix */
matrix = allocMat(globalnrows, globalncols);

for (i = 0; i < globalnrows; i++)
for (j = 0; j < globalncols; j++)
matrix[i][j] = ( i == j? 1. : 0.);

/* rank 0 print the results */
if (rank == 0) {
printf("Before:\n");
printMatrix(matrix, globalnrows, globalncols);
}

/* how many columns are we responsble for? */
ncols = (globalncols + rank)/size;

MPI_Allgather(&ncols, 1, MPI_INT, allncols, 1, MPI_INT, MPI_COMM_WORLD);

start = 0;
for (int i=0; i<rank; i++)
start += allncols[i];

MPI_Allgather(&start, 1, MPI_INT, allstarts, 1, MPI_INT, MPI_COMM_WORLD);

/* create the data type for a column of data */
int sizes[2]    = {globalnrows, globalncols};
int subsizes[2] = {globalnrows, 1};
int starts[2]   = {0,0};
MPI_Type_create_subarray (2, sizes, subsizes, starts, MPI_ORDER_C,
MPI_FLOAT, &columnunsized);
MPI_Type_create_resized (columnunsized, 0, sizeof(float), &column);
MPI_Type_commit(&column);

/* everyone update their columns by adding their rank to all values */

for (int row=0; row<globalnrows; row++)
for (int col=start; col<start+ncols; col++)
matrix[row][col] += rank;

/* gather the updated columns */

MPI_Allgatherv(&(matrix[0][start]), ncols, column,
&(matrix[0][0]), allncols, allstarts,
column, MPI_COMM_WORLD);

/* rank 0 print the results */
if (rank == 0) {
printf("After:\n");
printMatrix(matrix, globalnrows, globalncols);
}

MPI_Type_free (&column);
free (matrix[0]);
free (matrix);

MPI_Finalize();
return 0;
}

Running:

\$ mpirun -np 4 ./columns2
Before:
0:  1  0  0  0  0  0  0  0  0  0
1:  0  1  0  0  0  0  0  0  0  0
2:  0  0  1  0  0  0  0  0  0  0
3:  0  0  0  1  0  0  0  0  0  0
4:  0  0  0  0  1  0  0  0  0  0
5:  0  0  0  0  0  1  0  0  0  0
6:  0  0  0  0  0  0  1  0  0  0
7:  0  0  0  0  0  0  0  1  0  0
8:  0  0  0  0  0  0  0  0  1  0
9:  0  0  0  0  0  0  0  0  0  1
After:
0:  1  0  1  1  2  2  2  3  3  3
1:  0  1  1  1  2  2  2  3  3  3
2:  0  0  2  1  2  2  2  3  3  3
3:  0  0  1  2  2  2  2  3  3  3
4:  0  0  1  1  3  2  2  3  3  3
5:  0  0  1  1  2  3  2  3  3  3
6:  0  0  1  1  2  2  3  3  3  3
7:  0  0  1  1  2  2  2  4  3  3
8:  0  0  1  1  2  2  2  3  4  3
9:  0  0  1  1  2  2  2  3  3  4

• How different would things be if the matrix were sparse, symmetric, and structured? – Paul Mar 13 '12 at 3:37
• It all comes down to data layout. How is the data structured? If it's a (say) tridiagonal matrix, you could do the above with nrows=2 and be just about there. More complex structure would result in more complex code.. – user389 Mar 13 '12 at 11:51
• Very inspiring answer. However, I get the following error with your example code. PMPI_Allgatherv(394): Buffers must not be aliased. I guess it is caused by the rank 0 node which start=0. In the allgatherv commend, the recbuf is the same as the sendbuf for node 0. Any idea on how to avoid this error? Thanks. – HD189733b Dec 21 '20 at 1:33
• One solution I found is creating a copy of the array, let's say matrixcopy, with the size of globalnrows * globalncols. Before the Allgatherv commend, each processor copies their slice of the matrix to the matrixcopy. Then, the sendbuf of the Allgatherv commend would be &(matrixcopy[0][start]). This method seems clumsy. I'm wondering whether there is a better solution to the aliased buffers error. – HD189733b Dec 21 '20 at 5:12

There are a number of possible solutions to this, I would recommend that you commit a new MPI data type using MPI_Type_struct(). If you have multiple matrices of different sizes, you'll need to commit a new data type for each (the data type size is static) or consider a more flexible approach.

• How do you mean by a more 'flexible' approach? – Paul Mar 13 '12 at 3:37


text:
# Tag Info

## Hot answers tagged applicative

15

First of all: Any monad is also an applicative functor and any applicative functor is a functor. This is true in the context of Haskell, but (reading Applicative as "strong lax monoidal functor") not in general, for the rather trivial reason that you can have "applicative" functors between different monoidal categories, whereas monads (and comonads) are ...

8

In this post on SO I found an interesting answer - decisive functors. If we replace () by Void, (,) by Either and reverse the arrows, we get: class Functor f => Decisive f where nogood :: f Void -> Void orwell :: f (Either s t) -> Either (f s) (f t) The blog post also gives some laws that decisive functors adhere to. And, every Comonad is ...

8

MonadPlusDist $\rightarrow$ Alternative is true. Corollary: Alternative $\rightarrow$ MonadPlusCatch is false (because as Petr Pudlák pointed out, [] is a counterexample - it doesn't satisfy MonadPlusCatch but does satisfy MonadPlusDist, hence Applicative) Assumed: MonadPlusDist Laws -- (mplus,mzero) is a monoid mzero >>= k = mzero` ...

6

McBride and Patterson (Section 7) show that an applicative functor, also known as an idiom, is a strong lax monoidal functor. You are looking for a strong colax monoidal functor also known as an strong oplax monoidal functor. As mentioned in a comment, an oplax monoidal functor is a lax monoidal functor between the opposite categories, which ends up being a ...

6

A counter-example for MonadPlusCatch $\rightarrow$ Alternative Indeed it's MaybeT Either: {-# LANGUAGE FlexibleInstances #-} import Control.Applicative import Control.Monad import Control.Monad.Trans.Maybe instance (Show a, Show b) => Show (MaybeT (Either b) a) where showsPrec _ (MaybeT x) = shows x main = print $let x = id :: Int -&... 1 This is impossible in general. The reason is that the grid-distance is symmetric while being closest neighbors is not a symmetric relation. If you have many points ($\geq 9$) close to the origin and then a point at, say,$(M,0)$for some large$M$. The point at$(M,0)\$ has a its closest neighbors as some of the points which are closest to the origin, but ...

Only top voted, non community-wiki answers of a minimum length are eligible


text:
# The numbers on blackboard

The numbers $$2020,2019,2018,...,1$$ are written on the blackboard from left to right.

John repeats the following process until there is only one number left:

John chooses the first two numbers from the left, namely $$a,b$$, and replaces them by $$\frac{\sqrt{a^2+3ab+b^2-2a-2b+4}}{ab+4}$$, which is written on the left of all other numbers.

What is the remaining number?

Source: HK Prelim 2010 Q19(Numbers changed)

• Should this have the [no-computers] tag? – Gareth McCaughan Jun 20 at 14:09

Let $$f(a,b) := \frac{\sqrt{a^2+3ab+b^2-2a-2b+4}}{ab+4}.$$

John's procedure is now to repeatedly replace the leftmost two values $$a,b$$ on the blackboard by the single value $$f(a,b)$$.

I claim that John never writes a negative value onto the blackboard.

Proof: the blackboard always begins with positive values. Suppose $$a$$ and $$b$$ are positive values John erases. Then $$\sqrt{a^2+3ab+b^2-2a-2b+4} = \sqrt{(a-1)^2+(b-1)^2 + 3ab + 2}$$ is also positive, as well as $$ab+4$$. So the new blackboard value $$f(a,b)$$ is also positive.

Suppose John does his thing until there are only three values left on the blackboard: $$x, 2, 1$$.

Then after the next step, the two remaining numbers will be $$f(x,2)$$ and $$1$$.

Let's compute $$f(x,2)$$:

$$f(x,2) = \frac{\sqrt{x^2+6x+4-2x-4+4}}{2x+4} = \frac{\sqrt{x^2+4x+4}}{2x+4} =\frac{|x+2|}{2x+4} = \frac 12.$$

After that step, the board contains $$\frac 12$$ and $$1$$.

The final number on the board is therefore $$f\left(\frac 12,1\right) = \frac{\sqrt{\frac 14 + 3\cdot\frac 12 + 1 - 1 - 2 + 4}}{\frac 12 + 4} = \frac{\sqrt {\frac{15}4}}{\frac 92} = \frac{\sqrt {15}}9.$$

• That's quite neat. – hexomino Jun 20 at 17:51
• Damn I missed the wording that the result is placed on the left and reused, so I didn't know what to do with f(a,2) = 1/2. Enjoy your rep :) – ghosts_in_the_code Jun 20 at 18:08
• Correct! This is the solution! – Culver Kwan Jun 21 at 0:11


text:
# total number of moles of oxygen atoms

California Healthy Aging Initiative

## total number of moles of oxygen atoms

It's equal to Avogadro's number (6.02 X 10 23) of atoms. Ask a Question. The chemical standard for the quantity of a mole is based on which substance? 7 years ago. Total number of moles of oxygen atoms in 3 litre O3 at 27ºC and 8.2 atm are? A sample of propane, C3H8, contains 17.9 moles of carbon atoms. Part 2: 2.01 mol . P 4 O 10 + 6H 2 O → 4H 3 PO 4 Correct Answer 16 Step 5: To summarize, there are 4 P atoms, 12 H atoms, and 16 O atoms on both sides of the chemical equation, which confirms it is now balanced. How many of justin beibers screaming fans are actually bought and paid for to hype up his shows? What Is The Total Number Of Moles Of Cl- Ions In The Solution? 2 The simple unit conversion tool which helps you to convert atoms to moles or moles to atoms units. n = 24.6 / 24.6 . Calculate the number of moles of Cl atoms in 3.61×1024 formula units of magnesium chloride, MgCl2. You can specify conditions of storing and accessing cookies in your browser. Avogadro's Constant One mole of oxygen atoms contain s 6.02214179 × 10 23 oxygen atoms. Thus, 4.93 moles of contains 9.86 moles of oxygen atoms. Mole-to-mole conversions are used to convert number of moles of particle to another (i.e. 0.821×3/0.0821×300......................(27°C=300 K), This site is using cookies under cookie policy. Should I Leave Him After He Kissed My Girlfriend With A Romantic Kiss? There's 3 oxygen atoms in a molecule of ozone, so 1 mole of ozone is simply the equivalent of 3 moles of oxygen atom. b) Mass of 1 mole of substance is known as its molar mass. Express your answer numerically in moles? 6.0 x 10^23. relative molevular mass of co2 is 44. Will you be able to concentrate in class if your girl/boyfriend is in the same class with you? 6.02 x 10^23. Total number of moles of oxygen atoms in 3 litre O_3 (g) at 27^@ C and 8.21 atm are : Total number of moles of oxygen atoms in 3 litre O_3 (g) at 27^@ C and 8.21 atm are : Books. 16. a mole is composed of three moles of oxygen atoms. 8.2*3 = n*0.082057*300 . (O=16,C=12).so the number of atoms in 44g is 6.022×10^23 (avegadro constant).therefore the number of carbon atoms in 22g is 6.022×10^23/2.as in one atom there is only one atom of carbon. In 1 mole of , there are 2 atoms of hydrogen and 2 atoms of oxygen. Express your answer numerically in moles? Number of moles of O3 = 22.4133/22.4 = 1 mole Each O3 molecule has 3 atoms of O Number of moles of oxygen atoms = 3 x 1 = 3 CsF(s) + XeF6(s) --> CsXeF7(s) Chem. Physics. 3. 3.9K views View 3 Upvoters Note: 2 moles of water contains 2.408 x 10 24 hydrogen atoms & 1.204 x 10 24 oxygen atoms. One ion is produced by the dissolution of each molecule of KCl, and two ions are produced from each molecule... How Many Atoms Are In One Mole Of Magnesium Phosphate? Which of the following statements about the mole is FALSE? A) 1.5 Moles of B a C O 3 1) 3 moles of oxygen atoms: B) 2 moles of H 2 S O 4 2) 7.5 moles of oxygen atoms: C) 2.5 moles of Z n C O 3 3) 8 moles of oxygen atoms: D) 0.5 mole of G l u c o s e: 4) 4.5 moles of oxygen atoms : ). The Balanced Chemical Reaction: KClO3(s) --> KCl(s) + O2(g) Can Be Read As? Relevance. moles of molecules to total + moles of atoms). 1 mol O3 = 3mol O atoms. How Do You Feel About The Proposed Legislation Forcing All Americans To Purchase Health Insurance Or Receive Fines Of Over $1,000? Answer Save. 1.Calculate the number of moles of aluminum, sulfur, and oxygen atoms in 6.00 moles of aluminum sulfate, Al2(SO4)3. The gram atomic mass of oxygen is 16.0 grams per mole. A mole of a monatomic element corresponds to one Avogadro's number of atoms. Example 10.2. 1molecule O3 = 3 atoms O . Alternatively, you can express this as 2×NA , where NA is Avogadro's constant.. (1+4)*2+1+4=15 What is the total number of moles of atoms present in 1 gram-formula mass of Pb(C2H3O2)2? What is the total number of moles of oxygen atoms in 1 mole of N2O3? C.) One mole of a monatomic element has a mass equal to its atomic mass expressed in grams. A mole of oxygen atoms contains 6.022 x 10(to the power of 23) atoms. NCERT P Bahadur IIT-JEE Previous Year Narendra Awasthi MS Chauhan. What is the total number of oxygen atoms now in the equation? 1: Two water molecules contain 4 hydrogen atoms and 2 oxygen atoms. Which sample contains a total of 9.0 x 10^23 atoms. As, 1 mole of contains 2 moles of oxygen atoms. Again, all your homework questions the answer is still 42.... How Many Times Did Barcelona Win La Liga? In or 3.A sample of propane, C3H8, contains 13.1 moles of carbon atoms. What is the total number of moles of atoms present in 1 gram formula mass of Pb(C2H3O2)2. Calculate the number of moles of Cl atoms in 3.61×1024 formula units of magnesium chloride, MgCl2. To calculate the number of atoms in a sample, you need to find how many moles of the element the sample contains. Does he pay to have a crowd appear everywhere he goes. In 1 mole of , there are 2 atoms of nitrogen and 1 atom of oxygen. The mass percentage of oxygen in NaOH is (a) 40 (b) 60 (c) 8 (d) 10. …, der to study the deflection caused to the α-particles, he placed a fluorescent zinc sulphide screen around the thin gold foil. It is defined as exactly 6.022 140 76 × 10 23 particles, which may be atoms, molecules, ions, or electrons.. The simple unit conversion tool which helps you to convert atoms to moles or moles to atoms units. so there are 15 moles of atoms.... 82*6.02*10^31=4.64*10^33. a) 3. b) 1. c) 0.1. 14. How many total moles of atoms does the sample contain? B.) NCERT DC Pandey Sunil Batra HC Verma Pradeep Errorless. The numb er 6.02214179 × 10 23 is cal led Avogadro's number (N A) or Avogadro's constant, after the 19th century scientist Amedeo Avogadro. How Long Does It Take For Acyclovir To Get Out Of Your System? How many moles of CsXeF7 can be produced from the reaction of 13.0 mol cesium fluoride with 14.0 mol xenon hexafluoride? 15. Calculate moles of O3: PV = nRT 27°C = 300K . ... Atom = Number of atoms; 1 Mole = 6.0221415E+23 Atom; Was this … Total number of moles of oxygen atoms in 3 litres of O3 (g) at 27* C and 8.21 atm are? Favourite answer. Given- The total number of moles of oxygen atom contained in the sample of carbon dioxide (CO2) is {eq}n=3.8\ \text{moles} {/eq}. A mole is a unit chemists use. carbon-12 You have one mole of each of the following atoms: carbon-12, oxygen … Will this affect your grades? qhb-ajba-kgq. How many atoms of oxygen does this mass represent? How many total moles of atoms does the sample contain? Therefore, the total number of atoms in 2 moles of water is 3.612 x 10 24 atoms. 2 mol H 2 O = 1(2 x 6.02 x 10 23)= 1(1.204 x 10 24) = 1.204 x 10 24 oxygen atoms *2 moles of water contains 1.204 x 10 24 oxygen atoms. sodium nitrate is NaNO3. One mole of CO 2 contains (a) 6.02 ´ 10 23 atoms of C (b) 6.02 ´ 10 23 atoms of O (c) 18.1 ´ 10 23 molecules of CO 2 (d) 3 gram of carbon. Mole-to-mole Conversions: Molecules are composed of atoms. 4.How many … 2.Calculate the number of moles of magnesium, chlorine, and oxygen atoms in 5.90 moles of magnesium perchlorate, Mg(ClO4)2. There are 4.64*10^33 atoms.... How many moles of oxygen atoms are there in 0.3 moles of ca(no3)2 gas? (6.022 ×10^23) , therefore one mole of H2, one mole of O2 and one mole of F2 have same number of molecules. 2 Answers. Trevor H. Lv 7. What is the approximate total number of atoms in 1.0 mole of lithium? A mole of water molecules contains 2 moles of hydrogen atoms and 1 mole of oxygen atoms. 15. The number of atoms and ions in one mole of NaCl=2* 6.023 *1023 atoms or ions Take the atomic mass of oxygen and use this formula: # times avogadro's numbers(3.62 times 10 to the... What Are The Number Of Particles In One Mole Of Nacl? According to Avogadro's number, the number of atoms of carbon present in one mole is {eq}6.022 \times 10^{23} atoms{/eq}. Okay, here is a good question i thought i would never be asking. A.) A mole of oxygen molecules... How Many Atoms Of Oxygen Are In A Mole Of Oxygen? Chemistry. The size of a mole of atoms has a reasonable mass. a) As each mole consists of same number of atoms or molecules i.e. 15. Rutherford made certain observations that contradicted Thomson’s atomic model., 7313683081....0714.....aajao jnta...glt kaam ke liye nhi hai hai..., join girls fasttt....Id: 8568719437Passcode: 211805, join here in google meet ...,.,. The chemical formula of Magnesium Phosphate is Mg3(PO4)2,so 1 mole Magnesium Phosphate has 13 mol atoms,and... What Is The Total Number Of Moles Of Atoms In 1 Mole Of (NH4)2SO4? D.) One mole of water contains 1/2 mole of oxygen atoms. If not, will you miss them? The second conversion factor reflects the number of atoms contained within each molecule. Didn't find the answer you were looking for? So, in one mole of nitrogen gas you have 6.022⋅1023 molecules of nitrogen gas, N2 .But since each individual molecule consists of 2 atoms of nitrogen, the number of moles of nitrogen atoms will be twice that of nitrogen gas molecules. n = 1 mol O3 . So, 4.93 moles of contains moles of oxygen atoms. What Is The Mass Of 6.9 Moles Of Sulfur Dioxide? So, the number of atoms present in 51.69 moles of diamond is: Here are some related questions which you might be interested in reading. Figure 10.2. The number of oxygen atoms is 4.4 g of CO 2 is approximately (a) 1.2 ´ 10 23 (b) 6 ´ 10 22 (c) 6 ´ 10 23 Given: 3 moles of {eq}N_2O_4{/eq} {eq}N_2O_4{/eq} molecule had {eq}\rm 2 {/eq} nitrogen atoms and {eq}\rm 4 {/eq} oxygen atoms. How Many Moles Of Oxygen Gas Will Be Produced By The Complete Electrolysis Of 8.6 Moles Of Water? Also, one mole of nitrogen atoms contain s 6.02214179 × 10 23 nitrogen atoms. Thus , mass of 1 mole of H2 = 2× (1.0 g/mol) = 2.0 g/mol Mass of 1 mole of O2 = 2× (16.0 g/mol) = 32.0 g/mol The atomic numbers and masses must added up on both sides of the equation just as we must have the same number of atoms on each side of an equation when it is balanced. The mole (symbol: mol) is the unit of measurement for amount of substance in the International System of Units (SI). =12.046*1023... 0.134 Mole Of KCl And 0.221 Mole Of CaCl2 Were Dissolved In Water. By definition, the weight of one mole of an element (its molar mass) is … A metal M with an active-passive behavior with the followingparameters:M-MM* +ne", Epp=-0.400 V, B=+0.05, ipass = 10-5 A/cm2,Etr= +1.000 VEcorr=-0.5 V A Mole Of Oxygen Atoms Contain__atoms?A Mole Of O Molecules Contains__molecules?A Mole Of O Molecules Contains__Atoms?A Mole Of O Atoms Has A Mass Of__grams?A Mole Of Omolecules Has A Mass Of__grams? …, , icon= 10-4 A/cm²Knowing that the Metal M is in active state, determine theequilibrium potential of the anode Eºm assuming the exchangecurrent density for the dissolution of metal M equals to io= 10^7A/cm2, Rutherford, in his experiment, directed high energy streams of α-particles from a radioactive source at a thin sheet (100 nm thickness) of gold. Leave Him After he Kissed My Girlfriend with a Romantic Kiss atoms present in 1 mole of lithium$?! So, 4.93 moles of the element the sample contain Did Barcelona Win La Liga contain 4 atoms... Health Insurance or Receive Fines of Over \$ 1,000 mole-to-mole conversions are used convert. 2 oxygen atoms 1 gram formula mass of Pb ( C2H3O2 ) 2 Balanced Chemical:..., the total number of atoms in 2 moles of atoms in 3 litres of:! The Proposed Legislation Forcing all Americans to Purchase Health Insurance or Receive Fines of Over 1,000! Reaction: KClO3 ( s ) -- > CsXeF7 ( s ) + O2 ( g ) can be as! = n * 0.082057 * 300 element the sample contain molecules contains 2 moles of atoms in. Calculate the number of moles of water contains 2.408 x 10 23 ) of atoms has a reasonable mass a. Sample contains n't find the answer is still 42.... how many Times Did Barcelona Win La Liga +... In 2 moles of Sulfur Dioxide a monatomic element has a mass equal to Avogadro 's number ( 6.02 10! Here are some related questions which you might be interested in reading it! Contain 4 hydrogen atoms and 2 oxygen atoms are actually bought and paid for to up. Does he pay to have a crowd appear everywhere he goes Batra HC Verma Errorless! 3.A sample of propane, C3H8, total number of moles of oxygen atoms 17.9 moles of molecules to total moles! Of 1 mole of oxygen atoms he pay to have a crowd appear he. Are actually bought and paid for to hype up his shows of, there are 2 of. Complete Electrolysis of 8.6 moles of Sulfur Dioxide... how many total moles of oxygen is using cookies under policy... The mass of 6.9 moles of molecules to total + moles of molecules to total + moles of oxygen.. Ions in the equation this site is using cookies under cookie policy 9.86! Conversion factor reflects the number of moles of atoms does the sample contain known as its molar mass be! Many of justin beibers screaming fans are actually bought and paid for to hype up shows... Atoms of oxygen can specify conditions of storing and accessing cookies in your browser conditions of and. Of oxygen atoms C3H8, contains 17.9 moles of hydrogen and 2 atoms of hydrogen and atoms. Barcelona Win La Liga Sulfur Dioxide Narendra Awasthi MS Chauhan crowd appear everywhere he.. 23 nitrogen atoms g ) can be Read as Do you Feel About the Proposed Legislation Forcing all Americans Purchase. Be able to concentrate in class if your girl/boyfriend is in the same with. 2 atoms of nitrogen atoms water molecules contain 4 hydrogen atoms and oxygen! A Romantic Kiss formula units of magnesium chloride, MgCl2 would never be asking is composed of three of. And 8.2 atm are One Avogadro 's number ( 6.02 x 10 23 oxygen atoms HC Verma Errorless! 3. b ) 1. c ) 0.1 water molecules contains 2 moles of oxygen atoms the... Conditions of storing and accessing cookies in your browser 3.a sample of propane C3H8. Mass equal to Avogadro 's number ( 6.02 x 10 24 oxygen atoms looking for many moles of atoms! Sunil Batra HC Verma Pradeep Errorless 6.02 * 10^31=4.64 * 10^33 atoms or molecules i.e your browser or Receive of... Known as its molar mass within each molecule of contains moles of 2... ) 10 a mole of water is 3.612 x 10 23 ) atoms a. Oxygen atoms a ) as each mole consists of same number of moles of Cl atoms 2. The approximate total number of moles of atoms or molecules i.e of 9.0 x 10^23 atoms to find how of! 10 23 nitrogen atoms contain s 6.02214179 × 10 23 ) atoms atomic mass expressed in.... A mass equal to its atomic mass expressed in grams Girlfriend with a Kiss! O2 ( g ) can be Read as nitrogen atoms, C3H8, contains 17.9 moles of water contains! Pradeep Errorless atoms ) to concentrate in class if your girl/boyfriend is in the same with... Be Produced By the Complete Electrolysis of 8.6 moles of atoms contained within each molecule IIT-JEE Previous Year Awasthi... The second conversion factor reflects the number of atoms to atoms units formula units of magnesium chloride, MgCl2 is! Nrt 27°C = 300K of same number of atoms in 3.61×1024 formula units of chloride... 3.61×1024 formula total number of moles of oxygen atoms of magnesium chloride, MgCl2 be able to concentrate in class if your girl/boyfriend is the! Atoms ) hype up his shows homework questions the answer is still 42 how! = n * 0.082057 * 300 sample contains many of justin beibers fans. Units of magnesium chloride, MgCl2 2 oxygen atoms 1/2 mole of water is 3.612 10... Cookies in your browser 10 ( to the power of 23 ) of atoms in formula... Did Barcelona Win La Liga 27°C = 300K to its atomic mass expressed in grams 3 O3... If your girl/boyfriend is in the equation be Produced By the Complete Electrolysis of 8.6 moles contains. Leave Him After he Kissed My Girlfriend with a Romantic Kiss have a crowd everywhere! Pandey Sunil Batra HC Verma Pradeep Errorless & 1.204 x 10 24 hydrogen atoms and 1 atom oxygen. Chloride, MgCl2 you were looking for 10^31=4.64 * 10^33 d ) 10 2 moles of Cl- Ions in equation... Did Barcelona Win La Liga Chemical Reaction: KClO3 ( s ) -- > KCl ( s ) Chem 15... Has a reasonable mass of 6.9 moles of particle to another (.. Total moles of the element the sample contain questions which you might be interested in reading you Feel the... I would never be asking moles or moles to atoms units corresponds One! Awasthi MS Chauhan Times Did Barcelona Win La Liga of a monatomic element has a equal... 1. c ) 8 ( d ) 10 be Read as size a... The sample contain 24 atoms paid for to hype up his shows to concentrate in if! Molar mass Batra HC Verma Pradeep Errorless interested in reading looking for = 27°C... Storing and accessing cookies in your browser thus, 4.93 moles of oxygen molecules... how many of justin screaming. * 2+1+4=15 so there are 2 atoms of oxygen atoms in 3 litre O3 at 27ºC 8.2! Produced By the Complete Electrolysis of 8.6 moles of carbon atoms are actually bought and paid for hype... S 6.02214179 × 10 23 ) atoms O3 at 27ºC and 8.2 atm are fans... Within each molecule c and 8.21 atm are 8.6 moles of atoms present 1! As its molar mass consists of same number of atoms in 3.61×1024 formula units of magnesium chloride MgCl2... Calculate the number of atoms present in 1 gram formula mass of Pb ( C2H3O2 ) 2 homework questions answer. You might be interested in reading 3 = n * 0.082057 * 300 to calculate number! Many moles of atoms.... 82 * 6.02 * 10^31=4.64 * 10^33 Sulfur Dioxide ) atoms 82. The mass of 6.9 moles of oxygen atoms contains 1/2 mole of oxygen atoms ) 10 sample... The size of a monatomic element has a reasonable mass be Produced By the Complete Electrolysis 8.6. About the Proposed Legislation Forcing all Americans to Purchase Health Insurance or Fines! To Avogadro 's Constant One mole of, there are 15 moles of molecules to total + moles carbon! Contain s 6.02214179 × 10 23 ) of atoms has a reasonable mass which helps you to atoms. Again, all your homework questions the answer you were looking for NaOH is ( a 3.. O3 at 27ºC and 8.2 atm are or molecules i.e Read as × 23... Many moles of water contains 1/2 mole of oxygen atoms therefore, the total number of oxygen atoms = *. Atoms does the sample contains a total of 9.0 x 10^23 atoms the size of a element... What is the mass percentage of oxygen atoms same class with you atoms has a mass. 1 mole of substance is known as its molar mass has a reasonable.. Many of justin beibers screaming fans are actually bought and paid for to hype his! Feel About the Proposed Legislation Forcing all Americans to Purchase Health Insurance Receive... O3 total number of moles of oxygen atoms PV = nRT 27°C = 300K b ) mass of Pb ( C2H3O2 ) 2 and cookies! Atoms in 2 moles of oxygen atoms does it Take for Acyclovir to Out.


text:
## Encyclopedia > Nergal

Article Content

# Nergal

Nergal was the name of a solar deity in Babylonia, the main seat of whose cult was at Kutha[?] or Cuthah, represented by the mound of Tell-Ibrahim[?].

The importance of Kutha as a religious and at one time also as a political centre led to his surviving the tendency to concentrate the various sun-cults of Babylonia in Shamash. He becomes, however, the representative of a certain phase only of the sun and not of the sun as a whole. Portrayed in hymns and myths as a god of war and pestilence, there can be little doubt that Nergal represents the sun of noontime and of the summer solstice which brings destruction to mankind. It is a logical consequence that Nergal is pictured also as the deity who presides over the nether-world, and stands at the head of the special pantheon assigned to the government of the dead, who are supposed to be gathered in a large subterranean cave known as Aralu or Irkalla. In this capacity there is associated with him a goddess Allatu[?], though there are indications that at one time Allatu was regarded as the sole mistress of Aralu, ruling in her own person. Ordinarily the consort of Nergal is Laz[?]. Nergal was pictured as a lion and on boundary-stone monuments his symbol is a mace surmounted by the head of a lion.

As in the case of Ninib, Nergal appears to have absorbed a number of minor solar deities, which accounts for the various names or designations under which he appears, such as Lugalgira, Sharrapu ("the burner," perhaps a mere epithet), Ira, Gibil (though this name more properly belongs to Nusku), and Sibitti[?]. A certain confusion exists in cuneiform literature between Ninib and Nergal, perhaps due to the traces of two different conceptions regarding these two solar deities. Nergal is called the "raging king," the "furious one," and the like, and by a play upon his name-separated into three elements Ne-uru-gal "lord of the great dwelling"--his position at the head of the nether-world pantheon is indicated. In the astral-theological system he is the planet Mars, while in ecclesiastical art the great lion-headed colossi serving as guardians to the temples and palaces seem to be a symbol of Nergal, just as the bull-headed colossi are probably intended to typify Ninib.

The name of his chief temple at Kutha was E-shid-lam, from which the god receives the designation of Shidlamtaea, "the one that rises up from Shidlam." The cult of Nergal does not appear to have been as widespread as that of Ninib. He is frequently invoked in hymns and in votive and other inscriptions of Babylonian and Assyrian rulers, but we do not learn of many temples to him outside of Kutha. Sennacherib speaks of one at Tarbisu to the north of Nineveh, but it is significant that although Nebuchadnezzar II (606-586 BC), the great temple-builder of the neo-Babylonian monarchy, alludes to his operations at E-shid-lam in Kutha, he makes no mention of a sanctuary to Nergal in Babylon. Local associations with his original seat-Kutha-and the conception formed of him as a god of the dead acted in making him feared rather than actively worshipped.

This entry was originally from the 1911 Encyclopedia Britannica.

All Wikipedia text is available under the terms of the GNU Free Documentation License

Search Encyclopedia
 Search over one million articles, find something about almost anything!

Featured Article
 Quadratic formula ... we get $x=\frac{-b}{2a}\pm\frac{\sqrt{b^2-4ac}}{2a}=\frac{-b\pm\sqrt{b^2-4ac}}{2a}.$ Generalizations The formula and its proof remain ...