text:
# How to create an “intercept missile” for a game?

I have a game I am working on that has homing missiles in it. At the moment they just turn towards their target, which produces a rather dumb looking result, with all the missiles following the target around.

I want to create a more deadly flavour of missile that will aim at the where the target "will be" by the time it gets there and I am getting a bit stuck and confused about how to do it.

I am guessing I will need to work out where my target will be at some point in the future (a guess anyway), but I can't get my head around how far ahead to look. It needs to be based on how far the missile is away from the target, but the target it also moving.

My missiles have a constant thrust, combined with a weak ability to turn. The hope is they will be fast and exciting, but steer like a cow (ie, badly, for the non HitchHiker fans out there).

Anyway, seemed like a kind of fun problem for Stack Overflow to help me solve, so any ideas, or suggestions on better or "more fun" missiles would all be gratefully received.

Next up will be AI for dodging them ...

-
BTW: you haven't mentioned whether your missiles are atmospheric or not. Do they use their control surfaces or their thrust to change their vector? The constant bearing simplification continues to work either way but you get different / interesting behaviors with atmospheric missiles at varying speeds. E.g., the Sidewinder immediately after launch is very much a snake trail of smoke, not so much immediately prior to impact. –  Bob Cross Jul 30 '09 at 12:56
The nickname "sidewinder" came from it's back and forth flight path... When first launched, it is slow, and it pulls a lot of lead to get to the collision course. As it accelerates, it needs less lead, and turns back towards the target. After the motor burns out and it begins decellerating, it pulls lead once again. The net result is a flight pat hand smoke trail that looks much like a rattlesnakes' sideways motion across the sand. –  Charles Bretana Aug 1 '09 at 17:34
This Sidewinder effect was one of the motivating factors behind adding the variable proportionality feature to radar guided missiles. It's pointless to pull extra lead early when closure is low, if you're going to speed up and need less lead anyway.. So, for radar missiles which 'know' the closure, they base missile rate of turn on closure and this causes them to pull less extra lead early when they are not going to need it later. –  Charles Bretana Aug 1 '09 at 17:36

What you are suggesting is called "Command Guidance" but there is an easier, and better way.

The way that real missiles generally do it (Not all are alike) is using a system called Proportional Navigation. This means the missile "turns" in the same direction as the line-of-sight (LOS) between the missile and the target is turning, at a turn rate "proportional" to the LOS rate... This will do what you are asking for as when the LOS rate is zero, you are on collision course.

You can calculate the LOS rate by just comparing the slopes of the line between misile and target from one second to the next. If that slope is not changing, you are on collision course. if it is changing, calculate the change and turn the missile by a proportionate angle... you can use any metrics that represent missile and target position.

In 3-d problem is identical except the "Change in LOS Rate", (and resultant missile turn rate) is itself a vector, i.e., it has not only a magnitude, but a direction (Do I turn the missile left, right or up or down or 30 deg above horizontal to the right, etc??... Imagine, as a missile pilot, where you would "set the wings" to apply the lift...

Radar guided missiles, which "know" the rate of closure. adjust the proportionality constant based on closure (the higher the closure the faster the missile attempts to turn), but other missiles (like Sidewinders), which do not know the closure, use a constant pre-determined proportionality value)

-
+1 for giving the answer that I was about to type in. Summary for the casual reader: if the target bearing is changing to the left, steer left. If it's drifting right, steer right. If it's at a constant bearing (other than directly behind you), you're on an intercept course. Sidenote: this also works on an entrance ramp on the highway when you're trying to merge. If you see a car at a constant bearing that's getting steadily bigger in your view, you need to make a change.... –  Bob Cross Jul 30 '09 at 12:50
@Bob, actually even works when target is behind you! only issue is what the closure is... If LOS rate is zero (LOS constant and stable) then You may be getting closer to target, or furthur away, but you're on collision course. This is, actually exactly the way most air-to-air missiles work. –  Charles Bretana Jul 30 '09 at 13:17
@elliot, This will not produce a collision course. It may not even produce an intercept course. When you say "travelling faster than target", I suspect you are not really talking about your speed, buit your closure on the target. Clearly, if you stop "turning towards the tgt" once you are "... faster than the tgt", then at that point you might be pointed in a completely wrong direction. But even if you meant closure, this is by no means the best collision course. And in some cases (when in lead with less than the tgt's speed ), turning towards the tgt will reduce closure even furthur. –  Charles Bretana Jul 7 '10 at 13:13
@elliot, No matter what the missile's speed, it WILL steer towards the correct collision course for the current missile and tgt velocity vectors. i.e., if you do as outlined, and the tgt does not change velocity, and the missile only changes direction, not speed, then when the LOS rate has been reduced to zero, the missile will be on the collision course and the intercept will occur with no furthur maneuvering. –  Charles Bretana Jul 7 '10 at 13:16
@elliot, It is interesting to note that Sidewinders, because the missile DOES change speed, accelarating to Mach 3 or so while the motor is running, and then decellerating afterwards, does initially pull way more lead than needed (it's initially slow when it comes off the rail), and then turns back towards the tgt as it speeds up, and then turns more in lead again as it slows down after motor butnout. This back and forth is where the nickname "Sidewinder" came from... –  Charles Bretana Jul 7 '10 at 13:19

I've used this CodeProject article before - it has some really nice animations to explain the math.

"The Mathematics of Targeting and Simulating a Missile: From Calculus to the Quartic Formula": http://www.codeproject.com/KB/recipes/Missile_Guidance_System.aspx

(also, hidden in the comments at the bottom of that article is a reference to some C++ code that accomplishes the same task from the Unreal wiki)

-
+1, excellent article, even if it requires quite a commitment to read when you COULD just provide the algorithm(s). –  Adam Robinson Jul 29 '09 at 19:21
I would have liked to accept this answer as well, as the article is very good. I've up-voted and recommend others do the same. –  Rik Heywood Jul 31 '09 at 16:12

Take a look at OpenSteer. It has code to solve problems like this. Look at 'steerForSeek' or 'steerForPursuit'.

-

Have you considered negative feedback on the recent change of bearing over change of time?

Details left as an exercise.

The suggestions is completely serious: if the target does not maneuver this should obtain a near optimal intercept. And it should converge even if the target is actively dodging.

Need more detail?

Solving in a two dimensional space for ease of notation. Take \vec{m} to be the location of the missile and vector \vec{t} To be the location of the target. The current heading in the direction of motion over last time unit: \vec{h} = \bar{\vec{m}_i - \vec{m}_i-1}}. Let r be the normlized vector between the missile and the target: \vec{r} = \bar{\vec{t} - \vec{m}}. The bearing is b = \vec{r} \dot \vec{h} Compute the bearing at each time tick, and the change thereof, and change heading to minimize that quantity.

The math is harrier in 3d because of the need to find the plane of action at each step, but the process is the same.

-
@dmckee: I think you've been downvoted because the majority of people reading this answer will have no clue what you're saying, and the original version of your question said virtually nothing. –  Adam Robinson Jul 30 '09 at 3:39
The reality of the naive missile intercept problem is simpler than this. You're computing an intercept vector that you might want to provide to an intelligent fighter. A missile is perfectly happy with "I'm getting closer" so the constant bearing simplification discussed in other answers is perfectly acceptable for this application. –  Bob Cross Jul 30 '09 at 12:53
@Bob: This is the constant bearing approach. Negative feed back on <input>, leads to constant input. Modulo lags and rates of change, which might call for a PID controller rather than simple proportional circuit. –  dmckee Sep 2 '09 at 1:16

You'll want to interpolate the trajectory of both the target and the missile as a function of time. Then look for the times in which the coordinates of the objects are within some acceptable error.

-


text:
# Riemann sphere explained

In mathematics, the Riemann sphere, named after Bernhard Riemann,[1] is a model of the extended complex plane: the complex plane plus one point at infinity. This extended plane represents the extended complex numbers, that is, the complex numbers plus a value

infty

for infinity. With the Riemann model, the point

infty

is near to very large numbers, just as the point

0

is near to very small numbers.

The extended complex numbers are useful in complex analysis because they allow for division by zero in some circumstances, in a way that makes expressions such as

1/0=infty

well-behaved. For example, any rational function on the complex plane can be extended to a holomorphic function on the Riemann sphere, with the poles of the rational function mapping to infinity. More generally, any meromorphic function can be thought of as a holomorphic function whose codomain is the Riemann sphere.

In geometry, the Riemann sphere is the prototypical example of a Riemann surface, and is one of the simplest complex manifolds. In projective geometry, the sphere can be thought of as the complex projective line

P1(C)

, the projective space of all complex lines in

C2

. As with any compact Riemann surface, the sphere may also be viewed as a projective algebraic curve, making it a fundamental example in algebraic geometry. It also finds utility in other disciplines that depend on analysis and geometry, such as the Bloch sphere of quantum mechanics and in other branches of physics.

The extended complex plane is also called the closed complex plane.

## Extended complex numbers

The extended complex numbers consist of the complex numbers

C

together with

infty

. The set of extended complex numbers may be written as

C\cup\{infty\}

, and is often denoted by adding some decoration to the letter

C

, such as

\widehat{C

C*

has also seen use, but as this notation is also used for the punctured plane

C\setminus\{0\}

, it can lead to ambiguity.[2]

Geometrically, the set of extended complex numbers is referred to as the Riemann sphere (or extended complex plane).

### Arithmetic operations

Addition of complex numbers may be extended by defining, for

z\inC

,

z+infty=infty

for any complex number

z

, and multiplication may be defined by

z x infty=infty

for all nonzero complex numbers

z

, with

infty x infty=infty

. Note that

infty-infty

and

0 x infty

are left undefined. Unlike the complex numbers, the extended complex numbers do not form a field, since

infty

does not have an additive nor multiplicative inverse. Nonetheless, it is customary to define division on

C\cup\{infty\}

by
 z 0

=inftyand

 z infty

=0

for all nonzero complex numbers

z

with

infty/0=infty

and

0/infty=0

. The quotients

0/0

and

infty/infty

are left undefined.

### Rational functions

f(z)=g(z)/h(z)

(in other words,

f(z)

is the ratio of polynomial functions

g(z)

and

h(z)

of

z

with complex coefficients, such that

g(z)

and

h(z)

have no common factor) can be extended to a continuous function on the Riemann sphere. Specifically, if

z0

is a complex number such that the denominator

h(z0)

is zero but the numerator

g(z0)

is nonzero, then

f(z0)

can be defined as

infty

. Moreover,

f(infty)

can be defined as the limit of

f(z)

as

z\toinfty

, which may be finite or infinite.

The set of complex rational functions—whose mathematical symbol is

C(z)

—form all possible holomorphic functions from the Riemann sphere to itself, when it is viewed as a Riemann surface, except for the constant function taking the value

infty

everywhere. The functions of

C(z)

form an algebraic field, known as the field of rational functions on the sphere.

For example, given the function

f(z)=

 6z2+1 2z2-50
we may define

f(\pm5)=infty

, since the denominator is zero at

\pm5

, and

f(infty)=3

since

f(z)\to3

as

z\toinfty

. Using these definitions,

f

becomes a continuous function from the Riemann sphere to itself.

## As a complex manifold

As a one-dimensional complex manifold, the Riemann sphere can be described by two charts, both with domain equal to the complex number plane

C

. Let

\zeta

be a complex number in one copy of

C

, and let

\xi

be a complex number in another copy of

C

. Identify each nonzero complex number

\zeta

of the first

C

with the nonzero complex number

1/\xi

of the second

C

. Then the map

f(z)=

 1 z

is called the transition map between the two copies of

C

—the so-called charts—glueing them together. Since the transition maps are holomorphic, they define a complex manifold, called the Riemann sphere. As a complex manifold of 1 complex dimension (i.e. 2 real dimensions), this is also called a Riemann surface.

Intuitively, the transition maps indicate how to glue two planes together to form the Riemann sphere. The planes are glued in an "inside-out" manner, so that they overlap almost everywhere, with each plane contributing just one point (its origin) missing from the other plane. In other words, (almost) every point in the Riemann sphere has both a

\zeta

value and a

\xi

value, and the two values are related by

\zeta=1/\xi

. The point where

\xi=0

should then have

\zeta

-value "

1/0

"; in this sense, the origin of the

\xi

-chart plays the role of

infty

in the

\zeta

-chart. Symmetrically, the origin of the

\zeta

-chart plays the role of

infty

in the

\xi

-chart.

Topologically, the resulting space is the one-point compactification of a plane into the sphere. However, the Riemann sphere is not merely a topological sphere. It is a sphere with a well-defined complex structure, so that around every point on the sphere there is a neighborhood that can be biholomorphically identified with

C

.

On the other hand, the uniformization theorem, a central result in the classification of Riemann surfaces, states that every simply-connected Riemann surface is biholomorphic to the complex plane, the hyperbolic plane, or the Riemann sphere. Of these, the Riemann sphere is the only one that is a closed surface (a compact surface without boundary). Hence the two-dimensional sphere admits a unique complex structure turning it into a one-dimensional complex manifold.

## As the complex projective line

The Riemann sphere can also be defined as the complex projective line. The points of the complex projective line are equivalence classes established by the following relation on points from

C2\setminus\{(0,0)\}

: If for some

λ\ne0

,

wu

and

zv

, then

(w,z)\thicksim(u,v)

.

In this case, the equivalence class is written

[w,z]

using projective coordinates. Given any point

[w,z]

in the complex projective line, one of

w

and

z

must be non-zero, say

w\ne0

. Then by the equivalence relation,

[w,z]\thicksim\left[1,z/w\right]

, which is in a chart for the Riemann sphere manifold.[3]

This treatment of the Riemann sphere connects most readily to projective geometry. For example, any line (or smooth conic) in the complex projective plane is biholomorphic to the complex projective line. It is also convenient for studying the sphere's automorphisms, later in this article.

## As a sphere

The Riemann sphere can be visualized as the unit sphere

x2+y2+z2=1

in the three-dimensional real space

R3

. To this end, consider the stereographic projection from the unit sphere minus the point

(0,0,1)

onto the plane

z=0

, which we identify with the complex plane by

\zeta=x+iy

. In Cartesian coordinates

(x,y,z)

and spherical coordinates

(\theta,\phi)

on the sphere (with

\theta

the zenith and

\phi

the azimuth), the projection is

\zeta=

 x+iy 1-z

=\cot\left(

 1 2

\theta\right)ei.

Similarly, stereographic projection from

(0,0,-1)

onto the plane

z=0

, identified with another copy of the complex plane by

\xi=x-iy

, is written

\xi=

 x-iy 1+z

=\tan\left(

 1 2

\theta\right)e-i.

In order to cover the unit sphere, one needs the two stereographic projections: the first will cover the whole sphere except the point

(0,0,1)

and the second except the point

(0,0,-1)

. Hence, one needs two complex planes, one for each projection, which can be intuitively seen as glued back-to-back at

z=0

. Note that the two complex planes are identified differently with the plane

z=0

. An orientation-reversal is necessary to maintain consistent orientation on the sphere, and in particular complex conjugation causes the transition maps to be holomorphic.

The transition maps between

\zeta

-coordinates and

\xi

-coordinates are obtained by composing one projection with the inverse of the other. They turn out to be

\zeta=1/\xi

and

\xi=1/\zeta

, as described above. Thus the unit sphere is diffeomorphic to the Riemann sphere.

Under this diffeomorphism, the unit circle in the

\zeta

-chart, the unit circle in the

\xi

-chart, and the equator of the unit sphere are all identified. The unit disk

|\zeta|<1

is identified with the southern hemisphere

z<0

, while the unit disk

|\xi|<1

is identified with the northern hemisphere

z>0

.

## Metric

A Riemann surface does not come equipped with any particular Riemannian metric. The Riemann surface's conformal structure does, however, determine a class of metrics: all those whose subordinate conformal structure is the given one. In more detail: The complex structure of the Riemann surface does uniquely determine a metric up to conformal equivalence. (Two metrics are said to be conformally equivalent if they differ by multiplication by a positive smooth function.) Conversely, any metric on an oriented surface uniquely determines a complex structure, which depends on the metric only up to conformal equivalence. Complex structures on an oriented surface are therefore in one-to-one correspondence with conformal classes of metrics on that surface.

Within a given conformal class, one can use conformal symmetry to find a representative metric with convenient properties. In particular, there is always a complete metric with constant curvature in any given conformal class.

K

. It follows that the metric must be isometric to the sphere of radius

1/\sqrt{K}

in

R3

via stereographic projection. In the

\zeta

-chart on the Riemann sphere, the metric with

K=1

is given by

ds2=\left(

 2 1+|\zeta|2

\right)2|d\zeta|2=

 4 \left(1+\zeta\overline\zeta\right)2

In real coordinates

\zeta=u+iv

, the formula is

ds2=

 4 \left(1+u2+v2\right)2

\left(du2+dv2\right).

Up to a constant factor, this metric agrees with the standard Fubini–Study metric on complex projective space (of which the Riemann sphere is an example).

Up to scaling, this is the only metric on the sphere whose group of orientation-preserving isometries is 3-dimensional (and none is more than 3-dimensional); that group is called

. In this sense, this is by far the most symmetric metric on the sphere. (The group of all isometries, known as

O(3)

, is also 3-dimensional, but unlike

SO(3)

is not a connected space.)

Conversely, let

S

denote the sphere (as an abstract smooth or topological manifold). By the uniformization theorem there exists a unique complex structure on

S

up to conformal equivalence. It follows that any metric on

S

is conformally equivalent to the round metric. All such metrics determine the same conformal geometry. The round metric is therefore not intrinsic to the Riemann sphere, since "roundness" is not an invariant of conformal geometry. The Riemann sphere is only a conformal manifold, not a Riemannian manifold. However, if one needs to do Riemannian geometry on the Riemann sphere, the round metric is a natural choice (with any fixed radius, though radius

1

is the simplest and most common choice). That is because only a round metric on the Riemann sphere has its isometry group be a 3-dimensional group. (Namely, the group known as

SO(3)

, a continuous ("Lie") group that is topologically the 3-dimensional projective space

P3

.)

## Automorphisms

See main article: article and Möbius transformation.

The study of any mathematical object is aided by an understanding of its group of automorphisms, meaning the maps from the object to itself that preserve the essential structure of the object. In the case of the Riemann sphere, an automorphism is an invertible conformal map (i.e. biholomorphic map) from the Riemann sphere to itself. It turns out that the only such maps are the Möbius transformations. These are functions of the form

f(\zeta)=

 a\zeta+b c\zeta+d

,

where

a

,

b

,

c

, and

d

are complex numbers such that

. Examples of Möbius transformations include dilations, rotations, translations, and complex inversion. In fact, any Möbius transformation can be written as a composition of these.

The Möbius transformations are homographies on the complex projective line. In projective coordinates, the transformation f can be written

[\zeta, 1]\begin{pmatrix}a&c\b&d\end{pmatrix} =[a\zeta+b,c\zeta+d] =\left[\tfrac{a\zeta+b}{c\zeta+d}, 1\right] =[f(\zeta), 1].

PGL(2,C)

.

If one endows the Riemann sphere with the Fubini–Study metric, then not all Möbius transformations are isometries; for example, the dilations and translations are not. The isometries form a proper subgroup of

PGL(2,C)

, namely

PSU(2)

. This subgroup is isomorphic to the rotation group

SO(3)

, which is the group of symmetries of the unit sphere in

R3

(which, when restricted to the sphere, become the isometries of the sphere).

## Applications

In complex analysis, a meromorphic function on the complex plane (or on any Riemann surface, for that matter) is a ratio

f/g

of two holomorphic functions

f

and

g

. As a map to the complex numbers, it is undefined wherever

g

is zero. However, it induces a holomorphic map

(f,g)

to the complex projective line that is well-defined even where

g=0

. This construction is helpful in the study of holomorphic and meromorphic functions. For example, on a compact Riemann surface there are no non-constant holomorphic maps to the complex numbers, but holomorphic maps to the complex projective line are abundant.

The Riemann sphere has many uses in physics. In quantum mechanics, points on the complex projective line are natural values for photon polarization states, spin states of massive particles of spin

1/2

, and 2-state particles in general (see also Quantum bit and Bloch sphere). The Riemann sphere has been suggested as a relativistic model for the celestial sphere.[4] In string theory, the worldsheets of strings are Riemann surfaces, and the Riemann sphere, being the simplest Riemann surface, plays a significant role. It is also important in twistor theory.

## References

• Book: Brown, James . Churchill, Ruel . amp . Complex Variables and Applications. New York . McGraw-Hill. 1989 . 0-07-010905-2.
• Book: Griffiths, Phillip . Harris, Joseph . amp . Principles of Algebraic Geometry. John Wiley & Sons. 1978. 0-471-32792-1.
• Book: Roger Penrose. Penrose, Roger. The Road to Reality. New York. Knopf. 2005. 0-679-45443-8. registration.
• Book: Rudin, Walter. Real and Complex Analysis. New York . McGraw–Hill. 1987. 0-07-100276-6.

format: plain


text:
KEY2CHEM

Elementary Reactions

An elementary reaction is one that occurs via a single collision between the reacting particles. Generally, elementary reactions that are unimolecular (one particle reacts) or bimolecular (two particles react) are the most common. Aligning three or particles with appropriate collision energy and orientation is quite rare. As the collision frequency increases, the rate of the reaction increases. Additionally, as the molecular complexity increases (more atoms are contained in the structure), it becomes increasingly challenging to align particles with precisely the correct orientation, as the rate of the reaction decreases.

Example 1.

Which elementary reaction is most likely to occur successfully?

A. $$\require{mhchem}\ce{ 2 NO + Cl2 -> 2 NOCl}$$

B. $$\require{mhchem}\ce{ 2 NO2 -> N2O4}$$

C.  $$\require{mhchem}\ce{ 2 NO + O2 -> 2 NO2}$$

Solution

B. $$\require{mhchem}\ce{ 2 NO2 -> N2O4}$$

Elementary reactions are those that occur in a single collision. Bimolecular reactions (two particles collide) are more likely than termolecular reactions (three particles collide) due to the requirement for correct orientation and energy of all particles for a successful reaction.

Example 2.

Which elementary reaction is unimolecular?

A. $$\require{mhchem}\ce{ CH3CN -> CH3NC}$$

B. $$\require{mhchem}\ce{ NO + O3 -> NO2 + O2}$$

C.  $$\require{mhchem}\ce{ 2 Br -> Br2}$$

Solution

B. $$\require{mhchem}\ce{ CH3CN -> CH3NC}$$

A unimolecular reaction is one where one particle reacts (in this case, it is an isomerization, where the bonds rearrange). A bimolecular reaction is one where two particles (either the same as one another or different) react.

Example 3.

Which elementary reaction is most rare?

A. $$\require{mhchem}\ce{ N2O4 -> 2 NO2}$$

B. $$\require{mhchem}\ce{ 2 NO + O2 -> 2 NO2}$$

C.  $$\require{mhchem}\ce{ CH3Br + OH- -> CH3OH + Br-}$$

Solution

B. $$\require{mhchem}\ce{ 2 NO + O2 -> 2 NO2}$$

Termolecular reactions requiring aligning three molecules with correct orientation; these are rare due to the difficulty in aligning all three particles with exactly the correct orientation.


text:
This is “Choice under Uncertainty: Expected Utility Theory”, section 3.3 from the book Enterprise and Individual Risk Management (v. 1.0). For details on it (including licensing), click here.

Has this book helped you? Consider passing it on:
Creative Commons supports free culture from music to education. Their licenses helped make this book available to you.
DonorsChoose.org helps people like you help teachers fund their classroom projects, from art supplies to books to calculators.

## 3.3 Choice under Uncertainty: Expected Utility Theory

### Learning Objectives

• In this section the student learns that an individual’s objective is to maximize expected utility when making decisions under uncertainty.
• We also learn that people are risk averse, risk neutral, or risk seeking (loving).

We saw earlier that in a certain world, people like to maximize utility. In a world of uncertainty, it seems intuitive that individuals would maximize expected utilityA construct to explain the level of satisfaction a person gets when faced with uncertain choices.. This refers to a construct used to explain the level of satisfaction a person gets when faced with uncertain choices. The intuition is straightforward, proving it axiomatically was a very challenging task. John von Neumann and Oskar Morgenstern (1944) advocated an approach that leads us to a formal mathematical representation of maximization of expected utility.

We have also seen that a utility function representation exists if the four assumptions discussed above hold. Messrs. von Neumann and Morgenstern added two more assumptions and came up with an expected utility function that exists if these axioms hold. While the discussions about these assumptionsThese are called the continuity and independence assumptions. is beyond the scope of the text, it suffices to say that the expected utility function has the form

$E( U )= ∑ i=1 n π i u i ,$

where u is a function that attaches numbers measuring the level of satisfaction ui associated with each outcome i. u is called the Bernoulli function while E(U) is the von Neumann-Morgenstern expected utility function.

Again, note that expected utility function is not unique, but several functions can model the preferences of the same individual over a given set of uncertain choices or games. What matters is that such a function (which reflects an individual’s preferences over uncertain games) exists. The expected utility theory then says if the axioms provided by von Neumann-Morgenstern are satisfied, then the individuals behave as if they were trying to maximize the expected utility.

The most important insight of the theory is that the expected value of the dollar outcomes may provide a ranking of choices different from those given by expected utility. The expected utility theoryTheory that says persons will choose an option that maximizes their expected utility rather than their expected wealth. then says persons shall choose an option (a game of chance or lottery) that maximizes their expected utility rather than the expected wealth. That expected utility ranking differs from expected wealth ranking is best explained using the example below.

Let us think about an individual whose utility function is given by $u( W )= W$ and has an initial endowment of $10. This person faces the following three lotteries, based on a coin toss: Table 3.1 Utility Function with Initial Endowment of$10

Outcome (Probability) Payoff Lottery 1 Payoff Lottery 2 Payoff Lottery 3
H (0.5) 10 20 30
T (0.5) −2 −5 −10
E(G) 4 7.5 10

We can calculate the expected payoff of each lottery by taking the product of probability and the payoff associated with each outcome and summing this product over all outcomes. The ranking of the lotteries based on expected dollar winnings is lottery 3, 2, and 1—in that order. But let us consider the ranking of the same lotteries by this person who ranks them in order based on expected utility.

We compute expected utility by taking the product of probability and the associated utility corresponding to each outcome for all lotteries. When the payoff is $10, the final wealth equals initial endowment ($10) plus winnings = ($20). The utility of this final wealth is given by $20 =4.472.$ The completed utility table is shown below. Table 3.2 Lottery Rankings by Expected Utility Outcome (Probability) Utility Lottery 1 Utility Lottery 2 Utility Lottery 3 H (0.5) 4.472 5.477 6.324 T (0.5) 2.828 2.236 0 E(U) = 3.650 3.856 3.162 The expected utility ranks the lotteries in the order 2–1–3. So the expected utility maximization principle leads to choices that differ from the expected wealth choices. The example shows that the ranking of games of chance differs when one utilizes the expected utility (E[U]) theory than when the expected gain E(G) principle applies This leads us to the insight that if two lotteries provide the same E(G), the expected gain principle will rank both lotteries equally, while the E(U) theory may lead to unique rankings of the two lotteries. What happens when the E(U) theory leads to a same ranking? The theory says the person is indifferent between the two lotteries. ## Risk Types and Their Utility Function Representations What characteristic of the games of chance can lead to same E(G) but different E(U)? The characteristic is the “risk” associated with each game.At this juncture, we only care about that notion of risk, which captures the inherent variability in the outcomes (uncertainty) associated with each lottery. Then the E(U) theory predicts that the individuals’ risk “attitude” for each lottery may lead to different rankings between lotteries. Moreover, the theory is “robust” in the sense that it also allows for attitudes toward risk to vary from one individual to the next. As we shall now see, the E(U) theory does enable us to capture different risk attitudes of individuals. Technically, the difference in risk attitudes across individuals is called “heterogeneity of risk preferences” among economic agents. From the E(U) theory perspective, we can categorize all economic agents into one of the three categories as noted in Chapter 1 "The Nature of Risk: Losses and Opportunities": • Risk averse • Risk neutral • Risk seeking (or loving) We will explore how E(U) captures these attitudes and the meaning of each risk attitude next. Consider the E(U) function given by $E( U )= ∑ i=1 n π i u( W i ).$ Let the preferences be such that the addition to utility one gets out of an additional dollar at lower levels of wealth is always greater than the additional utility of an extra dollar at higher levels of wealth. So, let us say that when a person has zero wealth (no money), then the person has zero utility. Now if the person receives a dollar, his utility jumps to 1 util. If this person is now given an additional dollar, then as per the monotonicity (more-is-better) assumption, his utility will go up. Let us say that it goes up to 1.414 utils so that the increase in utility is only 0.414 utils, while earlier it was a whole unit (1 util). At 2 dollars of wealth, if the individual receives another dollar, then again his families’ utility rises to a new level, but only to 1.732 utils, an increase of 0.318 units (1.732 − 1.414). This is increasing utility at a decreasing rate for each additional unit of wealth. Figure 3.2 "A Utility Function for a Risk-Averse Individual" shows a graph of the utility. Figure 3.2 A Utility Function for a Risk-Averse Individual The first thing we notice from Figure 3.2 "A Utility Function for a Risk-Averse Individual" is its concavityProperty of a curve in which a chord connecting any two points on the curve will lie strictly below the curve., which means if one draws a chord connecting any two points on the curve, the chord will lie strictly below the curve. Moreover, the utility is always increasing although at a decreasing rate. This feature of this particular utility function is called diminishing marginal utilityFeature of a utility function in which utility is always increasing although at a decreasing rate.. Marginal utility at any given wealth level is nothing but the slope of the utility function at that wealth level.Mathematically, the property that the utility is increasing at a decreasing rate can be written as a combination of restrictions on the first and second derivatives (rate of change of slope) of the utility function, $u′(W)>0,u″(W)<0.$ Some functions that satisfy this property are $u( W )= W ,LN( W ),− e −aW .$ $u′(W)>0,u″(W)<0u(W)= W ,LN( W ), − e −2W .$ The functional form depicted in Figure 3.2 "A Utility Function for a Risk-Averse Individual" is LN(W). The question we ask ourselves now is whether such an individual, whose utility function has the shape in Figure 3.2 "A Utility Function for a Risk-Averse Individual", will be willing to pay the actuarially fair price (AFP)The expected loss in wealth to the individual., which equals expected winnings, to play a game of chance? Let the game that offers him payoffs be offered to him. In Game 1, tables have playoff games by Game 1 in Table 3.1 "Utility Function with Initial Endowment of$10" based on the toss of a coin. The AFP for the game is $4. Suppose that a person named Terry bears this cost upfront and wins; then his final wealth is$10 − $4 +$10 = $16 (original wealth minus the cost of the game, plus the winning of$10), or else it equals $10 −$4 − $2 =$4 (original wealth minus the cost of the game, minus the loss of $2) in case he loses. Let the utility function of this individual be given by $W .$ Then expected utility when the game costs AFP equals $0.5 16 +0.5 4 =3$ utils. On the other hand, suppose Terry doesn’t play the game; his utility remains at $10 =3.162.$ Since the utility is higher when Terry doesn’t play the game, we conclude that any individual whose preferences are depicted by Figure 3.2 "A Utility Function for a Risk-Averse Individual" will forgo a game of chance if its cost equals AFP. This is an important result for a concave utility function as shown in Figure 3.2 "A Utility Function for a Risk-Averse Individual". Such a person will need incentives to be willing to play the game. It could come as a price reduction for playing the lottery, or as a premium that compensates the individual for risk. If Terry already faces a risk, he will pay an amount greater than the actuarially fair value to reduce or eliminate the risk. Thus, it works both ways—consumers demand a premium above AFP to take on risk. Just so, insurance companies charge individuals premiums for risk transfer via insurances. An individual—let’s name him Johann—has preferences that are characterized by those shown in Figure 3.2 "A Utility Function for a Risk-Averse Individual" (i.e., by a concave or diminishing marginal utility function). Johann is a risk-averse person. We have seen that a risk-averse person refuses to play an actuarially fair game. Such risk aversions also provide a natural incentive for Johann to demand (or, equivalently, pay) a risk premium above AFP to take on (or, equivalently, get rid of) risk. Perhaps you will recall from Chapter 1 "The Nature of Risk: Losses and Opportunities" that introduced a more mathematical measure to the description of risk aversion. In an experimental study, Holt and Laury (2002) find that a majority of their subjects under study made “safe choices,” that is, displayed risk aversion. Since real-life situations can be riskier than laboratory settings, we can safely assume that a majority of people are risk averse most of the time. What about the remainder of the population? We know that most of us do not behave as risk-averse people all the time. In the later 1990s, the stock market was considered to be a “bubble,” and many people invested in the stock market despite the preferences they exhibited before this time. At the time, Federal Reserve Board Chairman Alan Greenspan introduced the term “irrational exuberance” in a speech given at the American Enterprise Institute. The phrase has become a regular way to describe people’s deviations from normal preferences. Such behavior was also repeated in the early to mid-2000s with a real estate bubble. People without the rational means to buy homes bought them and took “nonconventional risks,” which led to the 2008–2009 financial and credit crisis and major recessions (perhaps even depression) as President Obama took office in January 2009. We can regard external market conditions and the “herd mentality” to be significant contributors to changing rational risk aversion traits. An individual may go skydiving, hang gliding, and participate in high-risk-taking behavior. Our question is, can the expected utility theory capture that behavior as well? Indeed it can, and that brings us to risk-seeking behavior and its characterization in E(U) theory. Since risk-seeking behavior exhibits preferences that seem to be the opposite of risk aversion, the mathematical functional representation may likewise show opposite behavior. For a risk-loving person, the utility function will show the shape given in Figure 3.3 "A Utility Function for a Risk-Seeking Individual". It shows that the greater the level of wealth of the individual, the higher is the increase in utility when an additional dollar is given to the person. We call this feature of the function, in which utility is always increasing at an increasing rate, increasing marginal utilityFeature of a utility function in which utility is always increasing at an increasing rate.. It turns out that all convex utility functionsUtility function in which the curve lies strictly below the chord joining any two points on the curve. look like Figure 3.3 "A Utility Function for a Risk-Seeking Individual". The curve lies strictly below the chord joining any two points on the curve.The convex curve in Figure 3.2 "A Utility Function for a Risk-Averse Individual" has some examples that include the mathematical function $u( W )= W 2 , e W .$ $u( W )= W 2 , e W$ . Figure 3.3 A Utility Function for a Risk-Seeking Individual A risk-seeking individual will always choose to play a gamble at its AFP. For example, let us assume that the individual’s preferences are given by $u( W )= W 2 .$ As before, the individual owns$10, and has to decide whether or not to play a lottery based on a coin toss. The payoff if a head turns up is $10 and −$2 if it’s a tail. We have seen earlier (in Table 3.1 "Utility Function with Initial Endowment of $10") that the AFP for playing this lottery is$4.

The expected utility calculation is as follows. After bearing the cost of the lottery upfront, the wealth is $6. If heads turns up, the final wealth becomes$16 ($6 +$10). In case tails turns face-up, then the final wealth equals $4 ($6 − $2). People’s expected utility if they play the lottery is $u( W )=0.5× 16 2 +0.5× 4 2 =136$ utils. On the other hand, if an individual named Ray decides not to play the lottery, then the $E( U )= 10 2 =100.$ Since the E(U) is higher if Ray plays the lottery at its AFP, he will play the lottery. As a matter of fact, this is the mind-set of gamblers. This is why we see so many people at the slot machines in gambling houses. The contrast between the choices made by risk-averse individuals and risk-seeking individuals is starkly clear in the above example.Mathematically speaking, for a risk-averse person, we have $E( U[ W ] )≤U[E( W )].$ Similarly, for a risk-seeking person we have $E(U[ W )]≥U[E( W )].$ This result is called Jensen’s inequality. To summarize, a risk-seeking individual always plays the lottery at its AFP, while a risk-averse person always forgoes it. Their concave (Figure 3.1 "Links between the Holistic Risk Picture and Risk Attitudes") versus convex (Figure 3.2 "A Utility Function for a Risk-Averse Individual") utility functions and their implications lie at the heart of their decision making. Finally, we come to the third risk attitude type wherein an individual is indifferent between playing a lottery and not playing it. Such an individual is called risk neutral. The preferences of such an individual can be captured in E(U) theory by a linear utility function of the form $u( W )=aW,$ where a is a real number > 0. Such an individual gains a constant marginal utility of wealth, that is, each additional dollar adds the same utility to the person regardless of whether the individual is endowed with$10 or $10,000. The utility function of such an individual is depicted in Figure 3.4 "A Utility Function for a Risk-Neutral Individual". Figure 3.4 A Utility Function for a Risk-Neutral Individual ### Key Takeaways • This section lays the foundation for analysis of individuals’ behavior under uncertainty. Student should be able to describe it as such. • The student should be able to compute expected gains and expected utilities. • Finally, and most importantly, the concavity and convexity of the utility function is key to distinguishing between risk-averse and risk-seeking individuals. ### Discussion Questions 1. Discuss the von Neumann-Morgenstern expected utility function and discuss how it differs from expected gains. 2. You are told that $U( W )= W 2$ is a utility function with diminishing marginal utility. Is it correct? Discuss, using definition of diminishing marginal utility. 3. An individual has a utility function given by $( W )= W ,$ and initial wealth of$100. If he plays a costless lottery in which he can win or lose \$10 at the flip of a coin, compute his expected utility. What is the expected gain? Will such a person be categorized as risk neutral?
4. Discuss the three risk types with respect to their shapes, technical/mathematical formulation, and the economic interpretation.


text:
# Thread: Last 4 logarithm questions - unknown indices and logarithmic equations

1. ## Last 4 logarithm questions - unknown indices and logarithmic equations

Hi, here are my last 4 queries for the week on logarithms.

It involves finding the value x, usually as an unknown indice.

Thanks


text:
IFT Notes for Level I CFA® Program
IFT Notes for Level I CFA® Program

# Part 2

## 4.  Non-Current Assets

Instructor’s Note

This material will be covered in detail in the reading on Long-Lived Assets.

Non-current assets include all assets that cannot be classified as current assets. Some common examples of non-current assets are discussed below:

### 4.1. Property, Plant, and Equipment

Property, plant, and equipment (PPE) are tangible assets that are used in the company’s operations. They are expected to be used over more than one fiscal period. Examples of PPE include land, machinery, equipment, etc. PPE is measured differently under IFRS and US GAAP:

• IFRS permits companies to report PPE using either a cost model or a revaluation model.
• US GAAP permits only the cost model for reporting PPE.

### 4.2. Investment Property

IFRS defines investment property as property that is not used in the regular operations of a company. Instead, it is used to earn rental income or capital appreciation. US GAAP has no separate definition for investment property. Similar to PPE, investment property is valued using either the cost model or the fair value model.

### 4.3. Intangible Assets

These are long-term assets that lack physical substance. Examples include patents, licenses, and trademarks. IFRS allows companies to report intangible assets using either a cost model or a revaluation model. US GAAP allows only the cost model.

### 4.4. Goodwill

Goodwill is an unidentifiable intangible asset. It is created when one company is purchased by another company. If the purchase price is greater than fair value at acquisition, then the excess amount is recognized as an asset on the acquirer’s balance sheet and referred to as goodwill.

Let us consider a simple example. Company A buys Company T for $100 million. The book value of Company T’s assets and liabilities are$125 million and $75 million respectively. The fair value of Company T’s assets and liabilities are$160 million and $75 million respectively. What is the goodwill? In this case, the purchase price is$100 million and the net fair value is $160 –$75 million = $85 million. Hence, goodwill is ($100 million – $85 million)$15 million. Note that the book values of assets and liabilities are not used in the goodwill calculation.

Under both IFRS and US GAAP, goodwill is capitalized (i.e., shown as an asset on the balance sheet). Goodwill is not amortized but is tested for impairment annually. If goodwill is impaired, it is written down and the impairment loss is shown on the income statement.

### 4.5. Financial Assets

IFRS defines a financial instrument as a contract that gives rise to a financial asset of one company and a financial liability or equity instrument of another entity. Financial assets include stocks and bonds, derivatives, loans and receivables.

Financial assets can be measured either at fair value or amortized cost. The measurement basis depends on how financial asset is categorized. The major categories for financial assets are:

• Measured at Cost or Amortized Cost: Under IFRS, financial assets are measured at amortized cost if the asset’s cash flows occur on specified dates and consist solely of principal and interest, and if the business model is to hold the asset to maturity. For example, investment in a long-term bond. Unrealized gains and losses are not recorded anywhere.
• Measured at Fair value through profit or loss (FVTPL) under IFRS or Held-for-Trading under US GAAP: This category of asset is acquired primarily for the purpose of selling in the near term and is likely to be held for only a short period of time. Unrealized gains and losses are shown in the income statement.
• Measured at Fair value through other comprehensive income (FVTOCI) under IFRS or available-for-sale under US GAAP: This category of asset is expected neither to be held till maturity nor traded in the near term. Unrealized gains and losses are shown in other comprehensive income.

Unlike IFRS, the US GAAP category available-for-sale applies only to debt securities and is not permitted for investments in equity securities.

The table below summarizes where gains and losses associated with the financial asset are recognized in the financial statements of the company.

 Asset Category Treatment Measured at Fair Value through Profit and Loss ·      Measured at fair value. ·      Unrealized gains shown on Income Statement. Measured at Fair Value through Other Comprehensive Income ·      Measured at fair value. ·      Unrealized gains/losses shown in other comprehensive income (OCI). Measured at Cost or Amortized Cost ·      Measured at cost or amortized cost. ·      Unrealized gains not recorded anywhere.

Realized gains for all categories are shown on the income statement of the company. An important concept related to these assets is mark-to-market. It is the process whereby the value of a financial instrument is adjusted to reflect current value based on market prices. Let us illustrate the different accounting treatments for each of these categories through a simple example.

Example

Company owners contribute $100,000, which is invested in a 20-year bond with a 5% coupon paid semi-annually. After six months, the company receives the first coupon payment of$2,500. At this stage, the market price has increased to $102,000. Show the balance sheet and income statement treatment under each of the following categorizations: HFT, AFS and HTM. Solution: The accounting treatment under the three categories is summarized below:  Measured at Fair Value through Profit and Loss Measured at Fair Value through Other Comprehensive Income Measured at Cost or Amortized Cost Balance Sheet Cash$2,500 $2,500$2,500 Cost of securities $100,000$100,000 $100,000 Unrealized gains/losses$2,000 $2,000 PIC$100,000 $100,000$100,000 RE Up by $4,500 Up by$2,500 Up by $2,500 OCI Up by$2,000 Income Statement Interest income $2,500$2,500 $2,500 Unrealized gain$2,000

For Measured at Fair Value through Profit and Loss, unrealized gains and cash from coupon payments are shown on the asset side of the balance sheet. On the equity side, paid-in capital remains the same at $100,000. Retained earnings increase by$4,500 (sum of coupon payment of $2,500 and unrealized gain of 2,000). On the income statement unrealized gain of$2,000 and interest income of $2,500 is recognized. For Measured at Fair Value through Other Comprehensive Income, the accounting treatment is the same as HFT except for unrealized gains. For AFS, the unrealized gain is shown as part of other comprehensive income (OCI). It is not shown on the income statement. For Measured at Cost or Amortized Cost, the asset is valued at amortized cost. Therefore, the unrealized gain of$2,000 is not shown on the balance sheet or income statement. Only the coupon payment of \$2,500 is shown on the balance sheet as cash and on the income statement as interest income.

### 4.6 Deferred Tax Assets

Deferred tax assets (DTA) arise when income tax payable based on income for tax purposes is temporarily greater than income tax expense based on reported financial statement income. In other words, taxable income is higher than accounting profit. Any deferred tax asset is the result of a temporary difference that is expected to reverse in the future. Deferred tax asset reverses when tax benefits are realized in the future resulting in lower cash outflows.

## 5.  Non-Current Liabilities

All liabilities that are not classified as current are considered to be non-current or long-term liabilities.

Long-term financial liabilities – Include loans, notes and bonds payable. These are usually reported at amortized cost on the balance sheet.

Deferred tax liabilities – Result from temporary timing difference between a company’s taxable income and reported income. They are defined as the amounts of income taxes payable in future periods in respect of taxable temporary differences.


text:
It is currently September 20th, 2020, 8:53 pm

## Help with changing the text option with Lua

Discuss the use of Lua in Script measures.
KENDARRR
Posts: 5
Joined: December 15th, 2015, 1:08 am

### Help with changing the text option with Lua

I've downloaded Rainmeter skin and have been adding onto it as I think up different uses for it. My latest thought was a ping monitor. All I've set up the skin to, on a button press, run a batch file, write the contents to a .txt file, and lua to read and interpret the text file. I'm having trouble getting my lua script to update the skin properly though. I've managed to get it to update the skin with strings I've defined myself, but when I put it all together I can't get it to work. Here's what I have so far for my Lua script:

Code: Select all

function Initialize()
i = 11
ping = ""
hat = io.open("pingtest.txt", "rb")
hat:seek("end", -52)
hat:close()
end

function Update()
while (data:sub(i,i) ~= ",") do
ping = ping .. data:sub(i,i)
i = i + 1
end
form = string.format('[!setoption PV text %s]' , ping)
SKIN:Bang(form)
end
And here's the pertinent part of my skin's .ini:

Code: Select all

[pingTest]
Measure=Plugin
Plugin=RunCommand
StartinFolder=C:\Users\Kendall\Documents\Rainmeter\Skins\transbar\bar_up_1680
Parameter=ech.bat
outputtype=ANSI
OutputFile=pingtest.txt
FinishAction=[!UpdateMeasure #CURRENTSECTION#][!SetOption Output MeasureName pingtest][!UpdateMeter Output][!Redraw]

[LUAS]
measure=script
scriptfile=mylua.lua

[pingLabel]
x=15r
y=2
meter=string
FontColor=ACACAC
FontFace=Tahoma
FontSize=7
Stringstyle=BOLD
AntiAlias=0
text="Ping: "
LeftMouseUpAction=[!CommandMeasure pingtest run][!UpdateMeasure pingtest][!Redraw]

[PV]
x=0r
y=14
meter=string
fontcolor=ACACAC
FontFace=Tahoma
FontSize=7
AntiAlias=0
text='0ms'
balala
Rainmeter Sage
Posts: 11369
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Help with changing the text option with Lua

Try to modify the last two lines of the Update() function:

Code: Select all

form = string.format('[!setoption PV text %s]' , ping)
SKIN:Bang(form)
to a this kind of command: SKIN:Bang('!SetOption', 'PV', 'Text', ping) or SKIN:Bang('!SetOption', 'PV', 'Text', string.format('%s' , ping)) (I must admit that I'm not sure how the string.format command will work in this context).
Optionally you can add after this line a new one to update the PV meter: SKIN:Bang('!UpdateMeter', 'PV').
KENDARRR
Posts: 5
Joined: December 15th, 2015, 1:08 am

### Re: Help with changing the text option with Lua

I got it to work with other variables like that, and the way you mentioned. For what ever reason it won't work if I put

Code: Select all

SKIN:Bang('!Setoption', 'PV', 'text ', ping)
either. I tried the format way because I suspected that Lua might have been interpreting ping incorrectly. The script works, I can verify that it works by running the script in the compiler, and checking with print statements, I can even get a script to use !SetOption correctly, but for what ever reason when I introduce ping into the !setOption bang it just stop working. I can't seem to figure out why it's not working. I really appreciate any help I can get on this, I've been trying to work this out for days now.

Edit:
Another problem I've come across is if I put the bang after the while loop it doesn't set the text to anything.So this doesn't work

Code: Select all

function Update()
while (data:sub(i,i) ~= ",") do
ping = ping .. data:sub(i,i)
i = i + 1
end
SKIN:Bang('!SetOption', 'PV', 'Text', 'cats')
SKIN:Bang('!UpdateMeter', 'PV')
end
But this does

Code: Select all

function Update()
SKIN:Bang('!SetOption', 'PV', 'Text', 'cats')
SKIN:Bang('!UpdateMeter', 'PV')
while (data:sub(i,i) ~= ",") do
ping = ping .. data:sub(i,i)
i = i + 1
end
end
balala
Rainmeter Sage
Posts: 11369
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Help with changing the text option with Lua

KENDARRR wrote:I got it to work with other variables like that, and the way you mentioned. For what ever reason it won't work if I put

Code: Select all

SKIN:Bang('!Setoption', 'PV', 'text ', ping)
either. I tried the format way because I suspected that Lua might have been interpreting ping incorrectly. The script works, I can verify that it works by running the script in the compiler, and checking with print statements, I can even get a script to use !SetOption correctly, but for what ever reason when I introduce ping into the !setOption bang it just stop working. I can't seem to figure out why it's not working. I really appreciate any help I can get on this, I've been trying to work this out for days now
What is the value of the ping variable? Depending on it, try a tostring(ping) function instead of the simple ping.
KENDARRR wrote:Another problem I've come across is if I put the bang after the while loop it doesn't set the text to anything.So this doesn't work

Code: Select all

function Update()
while (data:sub(i,i) ~= ",") do
ping = ping .. data:sub(i,i)
i = i + 1
end
SKIN:Bang('!SetOption', 'PV', 'Text', 'cats')
SKIN:Bang('!UpdateMeter', 'PV')
end
But this does

Code: Select all

function Update()
SKIN:Bang('!SetOption', 'PV', 'Text', 'cats')
SKIN:Bang('!UpdateMeter', 'PV')
while (data:sub(i,i) ~= ",") do
ping = ping .. data:sub(i,i)
i = i + 1
end
end
It seems that here's a problem with the data:sub(i,i) ~= "," function. I don't know what it should do, but for sure it is causing the error. If you replace that function, the script will work, no matter where are you putting the !SetOption and the !UpdateMeter bangs. I suppose that in the first form, because the while statement is wrong, the Bang commands are never reached and executed, but in the last one, the bangs are executed first and the script match that wrong while statement after that (for sure a good programmer could explain better what's happening). What is the essence of this function? Could you post a link, because I tried to find a description, but found nothing interesting.
KENDARRR
Posts: 5
Joined: December 15th, 2015, 1:08 am

### Re: Help with changing the text option with Lua

The goal of the script is to read a text file to which I have output the result of the ping command in command prompt.
The result looks like this:

Code: Select all

Pinging 104.160.131.1 with 32 bytes of data:
Reply from 104.160.131.1: bytes=32 time=69ms TTL=56

Ping statistics for 104.160.131.1:
Packets: Sent = 1, Received = 1, Lost = 0 (0% loss),
Approximate round trip times in milli-seconds:
Minimum = 69ms, Maximum = 69ms, Average = 69ms
P
The only thing that will change is the numbers for the ping.

I just realized an error,

Code: Select all

hat:seek("end", -52)
should be

Code: Select all

hat:seek("end", -49)
. That shouldn't have any effect on whether or not it works though.

The initalize() function will read that text document -49 characters from the end. Which will be at the line

Code: Select all

Minimum = 69ms, Maximum = 69ms, Average = 69ms
without the spaces at the beginning. The while loop is supposed to check if what ever character in that line in the index 11 is a comma(In this case that first 6), then it appends it to ping and moves on to the next character until it hits a comma, then the loop should end.

And this is where I got the data:sub(i,i) ~= "," thing from.

Update: The code works as is. But if I add the SKIN:Bang it won't update the meter.
ech.jpg
You do not have the required permissions to view the files attached to this post.
balala
Rainmeter Sage
Posts: 11369
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Help with changing the text option with Lua

KENDARRR wrote:And this is where I got the data:sub(i,i) ~= "," thing from.
Ok, until now I used the sub function in a bit different form. I used it as string.sub(data,i,i) instead of data:sub(i,i) and that's why didn't realize what we are talking about. Sorry...
Now it's not very clear for me, but as I see you'd like to see on the screen the content of the pingtest.txt file, until the first comma. Maybe I'm wrong, but that's what I realized from the code. Am I right?
Anyway, in lua I read the content of a text file in a different way:

Code: Select all

function Read()
local FilePath = SKIN:MakePathAbsolute('pingtest.txt')
local hat = io.open(FilePath, 'r')
data = {}
for Line in hat:lines() do
table.insert(data, Line)
end
hat:close()
return data
end
This is created as a stand-alone function, which must be called in the Initialize() or in the Update() function.
After that, you'll have the content of the pingtest.txt file into an array. But if I'm not wrong, you can't go through it as you did. Instead I tried the following code (that's the content of the whole mylua.lua file):

Code: Select all

function Read()
local FilePath = SKIN:MakePathAbsolute('pingtest.txt')
local hat = io.open(FilePath, 'r')
data = {}
for Line in hat:lines() do
table.insert(data, Line)
end
hat:close()
return data
end

function Initialize()

end

function Update()
ping = ''
j = 1
repeat
i = 1
comma = false
repeat
if MyData[j]:sub(i,i) == ',' then
comma = true
else
comma = false
end
ping = ping .. MyData[j]:sub(i,i)
i = i + 1
until ( comma ) or (i > #MyData[j])
j = j + 1
until ( comma ) or ( j > #MyData )
SKIN:Bang('!SetOption', 'PV', 'Text', ping)
end
KENDARRR
Posts: 5
Joined: December 15th, 2015, 1:08 am

### Re: Help with changing the text option with Lua

I only want the "69ms" portion. I'll give this a shot though. Thanks. I'll post results when I'm done.

Update:
I had to make some tweaks, but I got it to do what I wanted.

Code: Select all

function Read()
local FilePath = SKIN:MakePathAbsolute('pingtest.txt')
local hat = io.open(FilePath, 'r')
data = {}
for Line in hat:lines() do
table.insert(data, Line)
end
hat:close()
return data
end

function Initialize()
end

function Update()
ping = ''
j = 8
i = 15
comma = false
repeat
if MyData[j]:sub(i,i) == ',' then
comma = true
else
comma = false
ping = ping .. MyData[j]:sub(i,i)
i = i + 1
end
until ( comma == true) or ( j > #MyData )
SKIN:Bang('!SetOption', 'PV', 'Text', ping)
end
There's a few things I didn't understand, like the table and arrays, but I get it now. Thanks I really appreciate your help.

FInal Update:
I figured out why my first one didn't work... local FilePath = SKIN:MakePathAbsolute('pingtest.txt') I only had io.open(pingtest.txt, 'r'), which is good enough for Lua, but not when you incorporate Rainmeter. Thank you so much for your help.
balala
Rainmeter Sage
Posts: 11369
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Help with changing the text option with Lua

KENDARRR wrote:I only want the "69ms" portion.
I'm not sure what this mean? You want the whole line, or just those numbers (69)?
KENDARRR wrote:There's a few things I didn't understand, like the table and arrays, but I get it now.
This is a very good manual for the lua programmers. I use it often. See the 11.1 section.
KENDARRR wrote:Thank you so much for your help.
You're welcome. Just let me (us) know if you have further questions.
KENDARRR
Posts: 5
Joined: December 15th, 2015, 1:08 am

### Re: Help with changing the text option with Lua

The text file I read from is rewritten with new information every time I run the ping command. So it won't be "69ms" everytime. It might be "20ms" it might me "566ms" I just need to read what ever number is there and update the meter with that value.

I'll be doing a lot of Rainmeter stuff in the future I imagine, so I'll read up on more Lua too. Thanks for the tip.
balala
Rainmeter Sage
Posts: 11369
Joined: October 11th, 2010, 6:27 pm
Location: Gheorgheni, Romania

### Re: Help with changing the text option with Lua

You're welcome and I'm glad if I could help.


text:
听歌学英文，是一种非常好的学英语的方式。

White Horse by Taylor Swift

建议大家先对着歌词听一遍音乐，再看后面的精析。效果会更好~

Say you're sorry

That face of an angel

Comes out just when you need it to

As I paced back

and forth all this time

Cause I honestly believed in you

Holding on

The days drag on

Stupid girl,

I should have known, I should have known

I'm not a princess, this ain't a fairy tale

I'm not the one you'll sweep off her feet,

This ain't Hollywood, this is a small town,

I was a dreamer before you went and let me down

Now it's too late for you

And your white horse, to come around

Maybe I was naive,

And never really had a chance

My mistake,

I didn't know to be in love

You had to fight to have the upper hand

Happy endings

Now I know

I'm not a princess, this ain't a fairy tale

I'm not the one you'll sweep off her feet,

This ain't Hollywood, this is a small town,

I was a dreamer before you went and let me down

Now it's too late for you

And your white horse, to come around

And there you are on your knees,

Begging for forgiveness, begging for me

Just like I always wanted but I'm sooo sorry

Cause I'm not your princess, this ain't a fairytale

I'm gonna find someone someday

who might actually treat me well

This is a big world, that was a small town

There in my rearview mirror disappearing now

And it's too late for you and your white horse

Now it's too late for you and your white horse

to catch me now

Oh, whoa, whoa, whoa

Try and catch me now

Oh, it's too late

To catch me now

Perusal

The days drag on

You say that an event or process drags on when you disapprove of the fact that it lasts for longer than necessary.

The conflict with James has dragged on for two years.

I should have known, I should have known

“should have done something”这是一个高频考点。一共有四种含义：

1

①I never did actually, so I think I should have done more.

②You should have reported them to the police. 你应当向警方控告他们的。

2

“should + 完成时”与虚拟条件连用，表示“与过去事实不符或相反的虚拟语气”。

if 从句用过去完成时，主句用“should + 完成时”，主句的主语仅限于使用第一人称。这时，should 可以用would 代替。例如：

①If I had seen Mary I should/would have invited her. 我当时要是看到玛丽的话我本会邀请她的。

②If I had received the present, I should/would have thanked him. 如果我收到了礼物，我是应当向他道谢的。

3

“should + 完成时”，还可以表示推测，推测“在将来某个时间之前应该业已完成的动作”

①They should have arrived in Beijing by this time. 他们这个时候该到北京了。

②I think I should gave finished it by then. 我想到那时应该完成了。

4

“should + 完成时”，还可以用来“对过去发生的情况，表示惊讶、后悔、难过、不理解、不可思议”等情绪，翻译时通常含有“竟然”的意味。

I am surprised that you should have acted so indiscreetly. 你竟然表现得如此轻率，我感到惊讶。

I'm not the one you'll sweep off her feet,

If someone sweeps you off your feet, you fall in love with them very quickly because you find them very attractive or exciting to.

I was swept off my feet. I had always dreamed of being an officer's wife.

“使...一见倾心”的表达，常见的还有这个单词：

enamour ”vt. 使倾心,使迷恋【To fall in love with sb or sth or be attracted by some characteristics.】

She was truly enamoured of New York.

You had to fight to have the upper hand

control or an advantage over a person or situation.

①Agassi briefly got the upper handin the second set.

②Government troops have the upper hand in the offensive.

EVA01专线最低三元起

ExpCloud·Trojan协议机场

GsouCloud·全专线机场

MZFast机场|高性价比

Last modification：June 2, 2021
If you think my article is useful to you, please feel free to appreciate


text:
Finding duplicates in arrays

I'm given two sorted arrays, arr1 and arr2. They can either be of the same length or arr2 will be longer than arr1. I implemented a method findDuplicates that returns an array of all numbers that are both in arr1 and arr2. Note that the output array should be sorted in an ascending order.

I know there are better solutions than the one I came up with. What I'm trying to understand is the space complexity of the solution I came up with.

  static int[] findDuplicates(int[] arr1, int[] arr2) {
HashMap<Integer, Integer> table = new HashMap<>();
ArrayList<Integer> returnlist = new ArrayList<Integer>();
int arr1Length = arr1.length;
int arr2Length = arr2.length;

// this is for the first array
for(int i=0; i<arr1Length; i++){
int n = arr1[i];
table.put(n, 1);
}

for(int i=0; i<arr2Length; i++){
int n = arr2[i];

if(table.containsKey(n)){
}
}
int[] arr = new int[returnlist.size()];

for(int i=0; i<=returnlist.size()-1; i++){
arr[i] = returnlist.get(i);
}
return arr;
} // end of method

Since I created a temporary Hashtable and an ArrayList, and then another array to return the duplicates is my space complexity $O(n^3)$. I know its greater than $O(n)$. If someone can help me understand this better, I would really appreciate it.

• Why $\mathcal O(n^3)$? Since you are creating a list plus a map plus an array, I only see $\mathcal O(n+n+n)$, which is equivalent to $\mathcal O(n)$. – Roland Illig Dec 25 '17 at 22:18
• @RolandIllig okay, that's what I was confused about. I thought it would be O(n^3) because I created three extra data structures to store the inputs in. It's not about the data structures but the size of the input. Thanks. – Rocky Singh Dec 25 '17 at 23:42

I think this is little bit tweaked algorithm, I am not holding any temporary variables to find duplicate (like HashMap or HashSet). Only temporary variable I am using is List<Integer> duplicate later I am converting it to int array, or else you can use List<Integer> but it depends upon your use case.

Below code only works if the arr1 and arr2 are sorted arrays, as per you problem statement.

static int[] findDuplicates(int[] arr1, int[] arr2) {
List<Integer> duplicate = new ArrayList<>();

int[] largeArray;
int[] smallArray;

if(arr1.length == arr2.length) {
largeArray = arr1;
smallArray = arr2;
} else {
largeArray = arr1.length > arr2.length ? arr1 : arr2;
smallArray = arr1.length < arr2.length ? arr1 : arr2;
}

int largeArrayIndex = 0;

for(int smallArrayIndex = 0; smallArrayIndex < smallArray.length; smallArrayIndex++) {
for(; largeArrayIndex < largeArray.length; largeArrayIndex++) {
if(largeArray[largeArrayIndex] == smallArray[smallArrayIndex]) {
largeArrayIndex++;
break;
} else if(smallArray[smallArrayIndex] < largeArray[largeArrayIndex]) {
break;
}
}
if(largeArrayIndex > largeArray.length) {
break;
}
}

return duplicate.stream().mapToInt(Integer::intValue).toArray();

}

static int[] findDuplicates(int[] arr1, int[] arr2) {

"Duplicates" is probably not the best name here. You would expect a duplicate to occur twice in the same collection of values or objects, not at least once in two collections. Maybe findPairs would be better, however still not perfect.

You might consider using an interface like List or even Iterable for the parameter types, to be able to support different types of collections instead of just arrays.

HashMap<Integer, Integer> table = new HashMap<>();

Do you really need a HashMap? It seems like you always use 1 as value and actually just want the keys. Use HashSet in that case. Call it uniqueValuesFirstArray or similar, instead of table. Use a name that tells you what you use it for.

ArrayList<Integer> returnlist = new ArrayList<Integer>();

Call the list result or better pairwiseOccuring or duplicates, because that is what you are saving in it. The name should not imply what the code will be doing with it later, e. g. returning it.

int arr1Length = arr1.length;
int arr2Length = arr2.length;

This is obsolete. There is no reason to save these values, instead just access them directly.

// this is for the first array
for(int i=0; i<arr1Length; i++){
int n = arr1[i];
table.put(n, 1);
}

This comment is obsolete. The code tells you that it is for array1, even better if you improve your variable names and access the array's length directly, like for (int i=0; i < array1.length; i++). Note the spaces that I added, to make it more readable.

Saving the value in a variable an then accessing it is obsolete. Just do table.put(arr1[i], 1);.

If you use HashSet instead of HashMap, you can replace the whole loop with HashSet<Integer> uniqueValuesFirstArray = new HashSet<>(Arrays.asList(array1));

for (int i=0; i < arr2Length; i++) {
int n = arr2[i];

if (table.containsKey(n)) {
}
}

This is what the indentation and whitespaces in this part of your code should look like.

As above, you do not need the variable n. Just use the value from the array directly.

If you change HashMap to HashSet, replace containsKey with contains.

int[] arr = new int[returnlist.size()];

for(int i=0; i<=returnlist.size()-1; i++){
arr[i] = returnlist.get(i);
}

This can be done much easier. Instead of the for-loop, just use returnlist.toArray(arr);. It is probably faster, and definitely shorter and more readable.


text:
anonymous 4 years ago Calculus II - Volume of Solids Hello, having some problems with this volume of a solid question. I cannot find a similar example, so I come to you for assistance! Find the volume of the solid generated by revolving the shaded region about the y-axis. x = 3tan((PI*y)/3)

1. anonymous

2. anonymous

$x = 3\tan ((\pi*y)/3)$

3. anonymous

From y = 0 to 1 |dw:1327692518967:dw|

4. anonymous

I thought the setup would be; $\int\limits_{0}^{1} \pi(3\tan((\pi/3)y)^2$ But this does not seem to be right. Any help would be appreciated.

5. amistre64

the bounds is from 0 to 1 right? up the y axis

6. anonymous

Yes, 0 to 1 up the Y axis.

7. amistre64

$\pi\int_{0}^{1}(3\ tan(\frac{\pi}{3}y))^2dy$does seem to be appropriate so where is the hiccup your having in this?

8. anonymous

Interesting... I guess I am having some problems with the arithmetic and integration. Trying to work out the answer now.

9. amistre64

$\pi\int_{0}^{1}3^2\ tan^2(\frac{\pi}{3}y)dy$ $9\pi\int_{0}^{1} tan^2(\frac{\pi}{3}y)dy$ can you think of a simpler way to write tan^2 that would be more doable?

10. anonymous

Ahh, sec^2x - 1 I assume?

11. amistre64

$9\pi\int_{0}^{1} sec^2(\frac{\pi}{3}y)-1\ dy$ yes

12. anonymous

I forgot my trig identities! Ahhh

13. amistre64

now for practice and to see whats missing lets see that htis comes from the derivative of tan :) tan(ny) = n sec^2(y) so we are missing the n part which is just a constant

14. amistre64

pi/3 is missing meaning we had a 3/pi to get rid of it to begin with am i seeing that right or you wanna go for the so called usub?

15. anonymous

Probably u-sub, much more familiar with that.

16. amistre64

u = pi/3 y du/dy = pi/3 dy = du/(pi/3) = 3du/pi

17. amistre64

same results, we need to include a 3/pi

18. amistre64

$9\pi\int_{0}^{1} \frac{3}{\pi}(sec^2(u)-1)\ du$ $\frac{3*9\pi}{\pi}\int_{0}^{1}sec^2(u)-1\ du$ $27\int_{0}^{1}sec^2(u)-1\ du$

19. amistre64

now, do you want to go ahead with this? or do we dare change the limits to match u instead of y :)

20. amistre64

$u=\frac{\pi}{3}*0=0$ $u=\frac{\pi}{3}*1=\frac{\pi}{3}$ $27\int_{0}^{pi/3}sec^2(u)-1\ du$ fancy!!!

21. anonymous

Sorry for the slow replies. At work trying to go through your work step by step while taking the odd call. This has been great... my biggest downfall was forgetting tan^(x) = sec^(x) -1.. The tan was just making my integral the nastiest thing ever. Now that you have changed the interval it is possible to sub those values in for U as opposed to subbing U back in and using the original interval?

22. amistre64

yep, now the whole thing is speaking in us and not partial tongues lol

23. anonymous

Haha, great stuff man. Thanks so much. I find this volume of solid stuff to just be some of the nastiest stuff imaginable. Do you have any recommended resources for learning the stuff or just practice, practice, practice?

24. amistre64

$27(tan(60^o)-\frac{pi}{3})\cancel{-27(tan(0^0)-0)}^{(\ 0\ )}$

25. amistre64

practice practice practice; after a bit it starts to sink in and make sense :)

26. amistre64

i started with the older textbooks out of the college libraries and learnt myself up til now

27. anonymous

Great, well thanks again for all of the help. Im going to try working through this start to finish again and see about getting the right answer :)

28. amistre64

if im right about this: $Volume=27\sqrt{3}-9pi$

29. anonymous

I'll let you know. I use Mymathlab for HW, so it only allows the right answer. Can be a bit of a pain (ex .01 off)

30. amistre64

mathlab costs money; i use interactmath.com. same setup but free; and you can choose from alot of different subjects

31. amistre64
32. anonymous

Yep! We got it! Oh, I'm doing a paid online Calculus II class.. don't have a choice.


text:
# How do you find abs( 3 - 7i )?

$\sqrt{58}$
$| x + i y | = \sqrt{{x}^{2} + {y}^{2}}$
Here, x=3 and $y = - 9$
$\sqrt{{3}^{2} + {\left(- 7\right)}^{2}} = \sqrt{58}$.


text:
# CO2 conversion to a harmless gas like oxygen [duplicate]

I am doing some research about indoor purifiers and I was wondering if there is any approach to purify co2 or convert it to harmless gases like oxygen just like what plants do.

• You could use sodium peroxide: $\ce{2Na2O2 +2 CO2 -> 2Na2CO3 + O2}$ Jul 14, 2016 at 19:59
• Plants do the job pretty well: why not use them? Besides carbon dioxide isn't harmful in the quantities normally found in the atmosphere (you produce it when you breathe). Only when there is a lot more than normal levels does it become a problem for living things which have adapted to low levels because they produce it. Jul 14, 2016 at 20:09


text:
# Lesson 5

More Dilations

## 5.1: Many Dilations of a Triangle (5 minutes)

### Warm-up

Students have seen many examples of scale factors that are less than and greater than 1, but the goal of this warm up is to have students focus explicitly on how the size of the scale factor impacts the dilation of a figure. Several dilations of one figure, with the same center but different scale factors, are displayed and students are asked to make observations about the shapes.

If using the digital activity, students will be able to scale a triangle by sliding the scale factor button. Students will informally make conjectures about the relationship between the original and scaled triangles. For example, the triangles are similar, the angles do not change, etc.

### Launch

Show students the image from the task (or demonstrate the applet from the digital activity) and ask “What do you notice? What do you wonder?” Record their responses for all to see. Students may notice and wonder many things. Relevant mathematical things students may notice:

• There are triangles that look like dilations of each other.
• The center of dilation is point $$P$$.
• The corresponding sides of the triangles are parallel to each other.
• There is a dashed line through each set of corresponding vertices.
• The corresponding angles appear to be congruent.

Things students may wonder:

• Which was the original triangle, and which are dilations of it?
• What scale factors were used?

Give students 2 minutes of quiet work time followed by a whole-class discussion.

### Student Facing

Explore the applet and observe the dilation of triangle $$ABC$$. The dilation always uses center $$P$$, but you can change the scale factor. What connections can you make between the scale factor and the dilated triangle?

### Launch

Show students the image from the task (or demonstrate the applet from the digital activity) and ask “What do you notice? What do you wonder?” Record their responses for all to see. Students may notice and wonder many things. Relevant mathematical things students may notice:

• There are triangles that look like dilations of each other.
• The center of dilation is point $$P$$.
• The corresponding sides of the triangles are parallel to each other.
• There is a dashed line through each set of corresponding vertices.
• The corresponding angles appear to be congruent.

Things students may wonder:

• Which was the original triangle, and which are dilations of it?
• What scale factors were used?

Give students 2 minutes of quiet work time followed by a whole-class discussion.

### Student Facing

All of the triangles are dilations of Triangle D. The dilations use the same center $$P$$, but different scale factors. What do Triangles A, B, and C have in common? What do Triangles E, F, and G have in common? What does this tell us about the different scale factors used?

### Anticipated Misconceptions

If students try to determine the actual scale factors between dilations, let them know that they only need to make an overall observation about the sizes of the dilations compared to Triangle D.

### Activity Synthesis

Important observations include

• The smaller triangles come from scale factors less than one while the bigger triangles correspond to scale factors larger than one
• The original triangle, itself, can be seen as coming from a scale factor of one
• All of the triangles have the same angles and orientation in the plane

A few other points worth discussing include

• Any of these triangles is a dilation of any other with center $$P$$.
• The lines from $$P$$ contain “corresponding vertices” of the triangles (in the sense that these points map to one another via the dilations taking one triangle to another).

## 5.2: Info Gap: Dilations (20 minutes)

### Activity

This info gap activity gives students an opportunity to determine and request the information needed for a dilation, and to realize that using coordinates greatly simplifies talking about specific points. In order to perform a dilation, students will need to know the center of dilation (which can be communicated using the coordinate grid), the coordinates of the polygon that they are dilating (also communicated using the coordinate grid), and the scale factor. With this information, they can find the dilation as in previous activities.

The info gap structure requires students to make sense of problems by determining what information is necessary, and then to ask for the information they need to solve the problem. This may take several rounds of discussion if their first requests do not yield the information they need (MP1). It also allows them to refine the language they use and ask increasingly more precise questions until they get the information they need (MP6).

Here is the text of one of the cards for reference and planning:

Listen for how students request (and supply) information about the center of dilation and the location of the polygon that is being dilated. The coordinate grid helps name and communicate the location of points, which is essential in this activity. In addition to the location of points, listen for how students use “center of dilation” and “scale factor” in order to communicate this essential information.

### Launch

Tell students they will continue to practice describing and drawing dilations using coordinates. Explain the Info Gap and consider demonstrating the protocol if students are unfamiliar with it. Arrange students in groups of 2. Provide access to geometry toolkits. In each group, distribute a problem card to one student and a data card to the other student. After you review their work on the first problem, give them the cards for the second problem and instruct them to switch roles.

Engagement: Develop Effort and Persistence. Display or provide students with a physical copy of the written directions. Check for understanding by inviting students to rephrase directions in their own words. Keep the display of directions visible throughout the activity.
Supports accessibility for: Memory; Organization
Conversing: This activity uses MLR4 Information Gap to give students a purpose for discussing information necessary to dilate a polygon on a coordinate grid. Display questions or question starters for students who need a starting point such as: “Can you tell me . . . (specific piece of information)”, and “Why do you need to know . . . (that piece of information)?”
Design Principle(s): Cultivate Conversation

### Student Facing

Your teacher will give you either a problem card or a data card. Do not show or read your card to your partner.

If your teacher gives you the problem card:

3. Explain how you are using the information to solve the problem.

Continue to ask questions until you have enough information to solve the problem.

4. Share the problem card and solve the problem independently.

If your teacher gives you the data card:

2. Ask your partner “What specific information do you need?” and wait for them to ask for information.

If your partner asks for information that is not on the card, do not do the calculations for them. Tell them you don’t have that information.

3. Before sharing the information, ask “Why do you need that information?” Listen to your partner’s reasoning and ask clarifying questions.

4. Read the problem card and solve the problem independently.

5. Share the data card and discuss your reasoning.

### Student Facing

#### Are you ready for more?

Triangle $$EFG$$ was created by dilating triangle $$ABC$$ using a scale factor of 2 and center $$D$$. Triangle $$HIJ$$ was created by dilating triangle $$ABC$$ using a scale factor of $$\frac12$$ and center $$D$$.

1. What would the image of triangle $$ABC$$ look like under a dilation with scale factor 0?
2. What would the image of the triangle look like under dilation with a scale factor of -1? If possible, draw it and label the vertices $$A’$$, $$B’$$, and $$C’$$. If it’s not possible, explain why not.

3. If possible, describe what happens to a shape if it is dilated with a negative scale factor. If dilating with a negative scale factor is not possible, explain why not.

### Activity Synthesis

After students have completed their work, share the correct answers and ask students to discuss the process of solving the problems. Some guiding questions:

• “Other than the answer, what information would have been nice to have?”
• “How did using coordinates help in talking about the problem?”
• “If this same problem had a figure on a grid without coordinates, how would you talk about the points?”
• “What if there had been no grid at all? Would you still have been able to request or provide the needed information to perform the transformation?”

Highlight that coordinates allow us to unambiguously provide the location of a polygon’s vertices. In addition, reinforce the idea that in order to perform a dilation, we need to know the scale factor and the center of dilation. The coordinate grid again provides an efficient means to communicate the center of dilation.

## Lesson Synthesis

### Lesson Synthesis

Ask students to think about the question: “Why does anyone bother putting coordinate axes on a grid? Why are coordinates useful? What are they good for?”

Here are the points to emphasize: Coordinates are an exceptionally powerful tool for communicating the location of points in the plane. There is only one point 3 units to the left of the origin and 2 units up from the origin, the point $$(\text-3, 2)$$. The location of a polygon is determined by the location and order of its vertices. On a coordinate plane, these can be communicated by giving their coordinates. When we perform a dilation, we also need to know the center of dilation (another point) and the scale factor (a number). On the coordinate plane, all of the information we need to dilate a polygon can be communicated unambiguously with some numbers!

Coordinates in the plane are much like an address in the city: they tell you where to go unambiguously. Because the plane is laid out in a grid, these “addresses” are particularly simple, consisting of two signed numbers. We will use coordinates much more in this unit and beyond, not only to describe individual points but also to describe relationships (like proportional relationships and other new types of relationships).

## Student Lesson Summary

### Student Facing

One important use of coordinates is to communicate geometric information precisely. Let’s consider a quadrilateral $$ABCD$$ in the coordinate plane. Performing a dilation of $$ABCD$$ requires three vital pieces of information:

1. The coordinates of $$A$$, $$B$$, $$C$$, and $$D$$
2. The coordinates of the center of dilation, $$P$$
3. The scale factor of the dilation

With this information, we can dilate the vertices $$A$$, $$B$$, $$C$$, and $$D$$ and then draw the corresponding segments to find the dilation of $$ABCD$$. Without coordinates, describing the location of the new points would likely require sharing a picture of the polygon and the center of dilation.


text:
# Is Mechanical Equilibrium Really Driven by Entropy Increase?

It is a standard result in statistical mechanics that when two interacting systems are free to exchange energy and volume, then in the macrostate of maximum entropy the systems will have equal temperature and pressure. The second law of thermodynamics then suggests that in thermal and mechanical equilibrium, such interacting systems will always equilibrate so as to have equal temperature and pressure.

But consider two ideal gases separated by a partition, in perfect thermal contact but with different initial pressures. If the partition is suddenly allowed to move, then thinking of pressure in terms of force per unit area (and using the ideal gas law) we can exactly solve for the motion of the partition. Assuming there is some damping force present, it is certainly true that the system will eventually settle down to the state where the pressure on either side of the partition is equal, but the reason for this equilibrium seems to me to be purely mechanical, and completely unrelated to entropy increase and the second law of thermodynamics. In fact, it seems false to assume some sort of ergodic hypothesis for volume microstates here (which underlies the assumption that mechanical equilibrium occurs at a volume macrostate of maximal entropy), as it is certainly not the case that every volume microstate is equally likely at a given moment in time (thanks to our exact solution for the volume as a function of time).

So basically, I'm confused why mechanical equilibrium should have anything to do with entropy, given that the volume exchange process can, at least for simple examples, be completely understood using Newton's Laws. How do we reconcile these two viewpoints?

• " but the reason for this equilibrium seems to me to be purely mechanical, and completely unrelated to entropy increase and the second law of thermodynamics" Why do you think it is completely unrelated to entropy increase. Entropy is generated as a result of mechanical or thermal disequilibrium. Jul 2, 2021 at 19:44
• @BobD I am trying to think about this from a fundamental perspective, where entropy is the logarithm of the number of possible microstates. While it's true that macrostate with the greatest entropy happens to correspond to the two gases having equal pressure, I don't buy that you can assume all volume microstates are equally likely, since we completely understand the process by which volume will be transferred here. In other words, I don't see why increase in entropy should be thought of as the reason behind mechanical equilibrium--it just seems like a side effect. Jul 2, 2021 at 20:07
• Frankly, I don't look at it as entropy being the reason behind mechanical equilibrium. Regarding the title of your post, as I see it mechanical disequilibrium drives entropy generation. But I confess not being conversant in statistical mechanics. Jul 2, 2021 at 20:37

It is a standard result in statistical mechanics that when two interacting systems are free to exchange energy and volume, then in the macrostate of maximum entropy the systems will have equal temperature and pressure.

This is true if entropy exchange through heat transfer is allowed, but Callen, for example, in Thermodynamics and an Introduction to Thermostatistics takes care to note that an adiabatic frictionless partition would continue to oscillate from side to side, with similar reasoning to yours. (Of course, damping would ultimately eliminate this oscillation in the real world.) From problem 2.7-3:

"The hypothetical problem of equilibrium in a closed composite system with an internal moveable adiabatic wall is a unique indeterminate problem. Physically, release of the piston would lead it to perpetual oscillation in the absence of damping. With damping, the piston would eventually come to rest at such position that the pressures on either side would be equal, but the temperatures in each subsystem would then depend on the relative viscosity in each subsystem. The solution of this problem depends on dynamical considerations. Show that the application of the entropy maximum formalism is correspondingly indeterminate with respect to the temperatures but determinate with respect to pressures."

The problem is also discussed with care and solved in Müller's An Expedition to Continuum Theory with citations to the following reports:

• Crosignani B, Di Porto P, Segev M (1996) Approach to thermal equilibrium in a system with adiabatic constraints. Am J Phys 64:610–613 ("...while the final pressure turns out to depend in a unique way on initial temperatures and volumes, the two final temperature and volumes cannot be predicted [within the framework of elementary thermodynamics], since they depend upon parameters lying outside the domain of thermodynamic description.")

• Gislason EA (2010) A close examination of the motion of an adiabatic piston. Am J Phys 78(10):995–1001

The reference lists of these two papers will probably also be of interest to you, as they include various discussions of entropy and entropy paradoxes.

I used to find this notion mysterious, but after I started teaching thermo out of Lemons' "Mere Thermodynamics" it made sense to me. The notion is this:

When a system cannot increase its internal entropy, the Second Law of Thermodynamics (basically, that entropy increases until an equilibrium is reached) states that it will reach equilibrium by attaining a local minimum of energy.

The logic is actually fairly simple. If the system can't increase its entropy, then its energy isn't doing it any good, at least as far as increasing the universe's entropy. Consequently, it will give up its energy to its surroundings, to try to increase the total entropy. This is a useful principle to know, since it lets us solve for mechanical equilibrium without worrying about the quite complicated microscopic mechanisms of dissipation.

Lemons regards this analysis as not terribly useful, but to me it explains why essentially any macroscopic system comes to mechanical equilibrium. Consider a featureless particle moving in a 1D potential, $$V(x)$$. Subject to conservative mechanics, it might oscillate forever about a local minimum. Coupled dissipatively to an environment at a positive temperature, it will instead come to rest at that minimum, with the lost energy, divided by the environmental temperature, comprising the total increase in the universe's entropy. Transparently, the particle doesn't lose any entropy itself since it doesn't have any internal structure.


text:
# rotaryio¶

The rotaryio module contains classes to read different rotation encoding schemes. See Wikipedia’s Rotary Encoder page for more background. .. warning:: This module is not available in some SAMD21 (aka M0) builds. See the Support Matrix for more info.

All classes change hardware state and should be deinitialized when they are no longer needed if the program continues after use. To do so, either call deinit() or use a context manager. See Lifetime and ContextManagers for more info.

class rotaryio.IncrementalEncoder(pin_a: microcontroller.Pin, pin_b: microcontroller.Pin)

IncrementalEncoder determines the relative rotational position based on two series of pulses.

position :int

The current position in terms of pulses. The number of pulses per rotation is defined by the specific hardware.

deinit(self)

Deinitializes the IncrementalEncoder and releases any hardware resources for reuse.

__enter__(self)

No-op used by Context Managers.

__exit__(self)


text:
## Trigonometry (10th Edition)

$y$$_{1} = \sin y$$_{2}$ = $\tan$
We must verify the values in each column to each function. $\sin$ 0$^{\circ}$ = 0 $\sin$ 15$^{\circ}$ = .25882 $\sin$ 30$^{\circ}$ = $\frac{1}{2}$ = 0.5 $\sin$ 45$^{\circ}$ = $\frac{\sqrt2}{2}$ = 0.70711 $\sin$ 60$^{\circ}$ = $\frac{\sqrt3}{2}$ = 0.86603 $\sin$ 75$^{\circ}$ = $\frac{\sqrt3 + 2}{2\sqrt2}$ = 0.96593 $\sin$ 90$^{\circ}$ = 1 $\tan$ 0$^{\circ}$ = 0 $\tan$ 15$^{\circ}$ = .26795 $\tan$ 30$^{\circ}$ = $\frac{1}{\sqrt3}$ = .57735 $\tan$ 45$^{\circ}$ = 1 $\tan$ 60$^{\circ}$ = $\sqrt3$ = 1.7321 $\tan$ 75$^{\circ}$ = 3.7321 $\tan$ 90$^{\circ}$ = undefined


text:
# Numbering failed

4 posts / 0 new
Numbering failed
#1

Job ID 32176 failed with this error:

ERROR: FR_L3 length 28 is not between 32 and 34
Numbering failed.  Exiting.

Any ideas on how I can remedy this? Thank you

Category:
Post Situation:
Mon, 2017-06-05 08:07
Sbrendle

You've got an antibody which is outside the norm of antibodies - according to the automated annotation in ROSIE, the framework region in your light chain is too short (28 verus a standard 32 to 34). Due to the way ROSIE Antibody is set up, it can't apply the automated proceedure to thread this onto the standard backbones.

The first thing to check is if this antibody light chain does indeed match what it's supposed to.  I'd highly recommend reading https://doi.org/10.1016/j.jmb.2010.10.030 and https://doi.org/10.1006/jmbi.1997.1442  and looking through the website  https://www.bioc.uzh.ch/plueckthun/antibody/  to check your antibody sequence against what is "normal" for antibodies, to see if there's something special/funky going on with your particular light chain.

Past that, given that your antibody is outside the norm for antibodies, you're likely going to have to run the antibody modeling proceedure manually. So you'd download Rosetta locally, and then follow the RosettaAntibody proceedures outlined in https://doi.org/10.1038/nprot.2016.180   You're likely going to need to tweak the alignments and settings to be able to get Rosetta to work with your "short" antibody, or to correct the misalignment that the automatic tools are doing.

Mon, 2017-06-05 08:44
rmoretti

I am counting 32 aa between CDR2 and 3 unless I am using a different system to assign the CDRs. Is this probably what the issue is?

Wed, 2017-06-21 11:51
Sbrendle

The issue is with the light chain, not the heavy chain. Check all the sequences (all the loops, all the framework regions, for both chains) that are reported in the output of your ROSIE job, and see if they match up with what you think they should be.

Comparing different system for deliniating the start and end points of the loop (the various system in the different papers I mentioned) is a good idea, as any conflict there may point to what the issue may be with the way Rosetta is modeling things.

Thu, 2017-06-29 07:58
rmoretti