A minus times a minus is a plus -Are you sure you know why?

What exactly are negative numbers?
A reference , from Wikipedia:
In A.D. 1759, Francis Maseres, an English mathematician, wrote that negative numbers “darken the very whole doctrines of the equations and make dark of the things which are in their nature excessively obvious and simple”.
He came to the conclusion that negative numbers were nonsensical.[25]

A minus times a minus is a plus
Two minuses make a plus
Dividing by a negative, especially a negative fraction !!!!
(10 – 2) x (7 – 3) = 10 x 7 – 2 x 7 + 10 x -3 + 2 x 3, really? How do we know?
Or we use “the area model”, or some hand waving with the number line.

It’s time for some clear thinking about this stuff.

Mathematically speaking, the only place that requires troublesome calculations with negative numbers is in algebra, either in evaluation or in rearrangement, but what about the real world ?
Where in the real world does one encounter negative x negative ?
I found two situations, in electricity and in mechanics:

1: “volts x amps = watts”, as it it popularly remembered really means “voltage drop x current flowing = power”
It is sensible to choose a measurement system (scale) for each of these so that a current flowing from a higher to a lower potential point is treated as positive, as is the voltage drop.

Part of simple circuit A———–[resistors etc in here]————–B
Choosing point A, at potential a, as the reference, and point B, at potential b, as the “other” point, then the potential drop from A to B is a – b
If b<a then a current flows from A to B, and its value is positive, just as a – b is positive
If b>a then a current flows from B to A, and its value is negative, just as a – b is negative

In each case the formula for power, voltage drop x current flowing = power, must yield an unsigned number, as negative power is a nonsense. Power is an “amount”.
So when dealing with reality minus times minus is plus (in this case nosign at all).

The mechanics example is about the formula “force times distance = work done”
You can fill in the details.

Now let’s do multiplication on the number line, or to be more precise, two number lines:
Draw two number lines, different directions, starting together at the zero. The scales do not have to be the same.
To multiply 2 by three (3 times 2):
1: Draw a line from the 1 on line A to the 2 on line B
2: Draw a line from the 3 on line A parallel to the first line.
3: It meets line B at the point 6
4: Done: 3 times 2 is 6
numberlines mult pospos
Number line A holds the multipliers, number line B holds the numbers being multiplied.

To multiply a negative number by a positive number we need a pair of signed number lines, crossing at their zero points.

So to multiply -2 by 3 (3 times -2) we do the same as above, but the number being multiplied is now -2, so 1 on line A is joined to -2 on line B

numberlines mult posneg
The diagram below is for -2 times 3. Wow, it ends in the same place.
numberlines mult posneg

Finally, and you can see where this is going, we do -2 times -3.

Join the 1 on line A to the -3 on line B, and then the parallel to this line passing through the -2 on line A:

numberlines mult negneg

and as hoped for, this line passes through the point 6 on the number line B.

Does this “prove” the general case? Only in the proverbial sense. The reason is that we do not have a proper definition of signed numbers. (There is one).

Incidentally, the numbering on the scales above is very poor. The positive numbers are NOT NOT NOT the same things as the unsigned numbers 1, 1.986, 234.5 etc

Each of them should have a + in front, but mathematicians are Lazy. More on this another day.

Problem for you: Show that (a-b)(c-d) = ac – bc – ad + bd without using anything to do with “negative numbers”

*******************************************

References.
Wikipedia:
Reference direction for current
Since the current in a wire or component can flow in either direction, when a variable I is defined to represent
that current, the direction representing positive current must be specified, usually by an arrow on the circuit
schematic diagram. This is called the reference direction of current I. If the current flows in the opposite
direction, the variable I has a negative value.

Yahoo Answers: Reference direction for potential difference
Best Answer: Potential difference can be negative. It depends on which direction you measure the voltage – e.g.
which way round you connect a voltmeter. (if this is the best answer, I hate to think of what the worst answer is)
********************************************

3 Comments

Filed under algebra, arithmetic, definitions, education, geometrical, math, meaning, negative numbers, Number systems, operations, subtraction, teaching, Uncategorized

Part 5: James Watt, the steam engine, and the first automatic control system

I was going to do my own version of the James Watt flyball governor, but I found a very readable, illustrated account of the life and inventions of James Watt. Here it is:

http://www.mainlesson.com/display.php?author=bachman&book=inventors&story=watt

In the picture below you can see the flyball governor, driven by the output shaft of the engine. The link from the governor to the steam valve however is not clear, but it is there.

watt steam engine

Here is a detailed view of the governor.regodis

See also the previous four posts.

 

Leave a comment

Filed under dynamic systems, engineering, flyball governor, James Watt, Uncategorized

Part 4: Tuning the feedback controller

Our first order process is described by the equation yn+1 = ayn + kxn , where yn is the process output now (at time n),  xn is the process input between time n and time n+1, and yn+1 is the process output at time n+1.
a is the coefficient determining how quickly the process settles after a change in the input, and k is related to the process steady state gain (ratio of settled output to constant input).

If we set the input to be a constant x and the output settled value to be a constant y, then

y = ay + kx, and solving for y/x we get y/x = k/(1-a), the actual steady state gain.

In what follows the k will represent the actual steady state gain, the old k divided by (1-a)

The fist two plots show the process alone, with input set to 6 at time zero. In the first the steady state gain is set to 1, and in the second it is set to 2

contpic1

contpic 2

Now we look a t the process under “direct” control, where the input is determined only by the chosen setpoint value. The two equations are

yn+1 = ayn + kxn  and  xn = Adn  (direct control: h is zero)

To obtain a controlled system with overall steady state gain equal to 1 (settled output  equal to desired output) it is easy to see that  has to be equal to (1-a)/k

contpic4

contpic5

It is not so obvious how the choice of h affects the performance of the controlled system. To do this we observe that the complete system is described entirely by the process equation and the controller equation together, and we can eliminate the xn from the two equations to get yn+1 = ayn + k(Adn + h(yn – dn))

which rearranged is yn+1 = (a + kh)yn + k(A – h)dn 

Substituting   (1-a)/k for A, as found above, gives  yn+1 = (a + kh)yn + (1 – a – kh)dn 

which has the required steady state gain of 1.

This final equation has the SAME structure as the process equation,
with a + kh in place of a

So now we will see how the value of the “a” coefficient affects the dynamic response of the system.

If h > 0 the controlled system will respond slower than with h = 0, and if h < 0 it will respond faster:

contpic6

contpic7
Setpoint changes were made at time 20 and at time 40

Congratulations if you got this far. This introduction to computer controlled processes has been kept as simple as possible, while using just the minimum amount of really basic math. The difficulties are in the interpretation and meaning of the various equations, and this something which is studiously avoided in school math. Such a shame.

Now you can run the program yourself, and play with the coefficients. It is a webpage with javascript:  http://mathcomesalive.com/mathsite/firstordersiml.html

Aspects and theoretical stuff which follow this (not here !) include the  backward shift operator z and its use in forming the transfer function of the system, behaviour of systems with wave form inputs to assess frequency response, representation of systems in matrix form (state space), non-linear systems and limit cycles, optimal control, adaptive control, and more…..

1 Comment

Filed under algebra, computer, control systems, discrete model, engineering, math, tuning, Uncategorized

Part 3: Computer control of real dynamic systems

Let us return to the industrial steam engine driving a range of equipment, each piece in the charge of an operator. In order to keep the factory working properly it is necessary to keep the speed of the steam engine reasonably constant, at what is called the desired output, or the set point. A human controller can achieve this fairly well, by direct observation of the speed and experience of the effect of changing the steam flow rate, but automatically? Well, James Watt solved the problem with a mechanical device (details later). We will now see how to “do it with a computer”.

steam physical
Diagram of the physical system. There will be a valve on the steam line (not shown).

steam informational
The information flow diagram. The load is not measured, and may vary.

steam controlled
Now we have a controller in the picture, fed with two pieces of information, the current speed and the desired speed. The controller can be human, mechanical or computer based. It has a set of rules to figure out the appropriate steam flow rate.

steam controlled with equations

Now we have computer control. The output of the system is measured (sampled) at regular intervals, the computer calculates the required flow rate , sends the corresponding value to the valve actuating mechanism, which holds this value until the next sampling time, when the process is repeated. Using n=1, 2, 3, ….. for the times at which the output is sampled and the controller does its bit, we have at time n the speed measure yn, the desired speed dn and the difference between them (or error in the speed), and they are used to calculate the system input xn with the formula shown in the controller box.

The equation in the steam engine box is our fairly simple first order linear system model as described in the previous post. It is a good idea to have a model of the process dynamics for many reasons (!), one of which is that we can do experiments on the whole controlled system by simulation rather than on the real thing.

Looking at the controller function (formula), xn = Adn + h(yn – dn) , it is “obvious” that if the coefficient h is zero we have direct control (no feedback), and so the value of the coefficient A must be chosen accordingly (see next post).

It is not so obvious how the choice of h affects the performance of the controlled system. To do this we observe that the complete system is described entirely by the process equation and the controller equation together, and we can eliminate the xn from the two equations to get yn+1 = ayn + k(Adn + h(yn – dn))

which rearranged is yn+1 = (a + h)yn + k(A – h)dn 

and has the SAME structure as the process equation, with a + h in place of a

In the next post, on tuning our controller, we will see how the value of the “a” coefficient affects the dynamic response of the system.

1 Comment

Filed under algebra, computer, discrete model, dynamic systems, engineering, forecasting, math, Uncategorized

Time Series and Discrete Processes, continued

A simple function has an input, call it x, and an output, f(x). Sometimes the input is t, for time, and the output is the value f(t), observed at time t. With such a function, or process, we can look at what happened in the past, but we cannot know for certain what will happen in the future. Of course, we may have a (mathematical) model of the process, which allows us to make predictions about the future. These processes are “simple”, insofar as the future behaviour depends only on the value of the time variable.

An example is the height of a projectile, s(t) = ut – 0.5gt2

will it hit the hoop dydan
Borrowed from dy/dan “Will it hit the hoop?”

Far more interesting are what I shall call “dynamic” processes, in which the future behaviour depends on how the process output got to its current value (at time now!). This implies that in the simplest case the rate of change of the process output is involved.

watt steam engine
This is an early industrial static steam engine, designed by James Watt. The input is steam flow, the output is the rotational speed of the flywheel.

An example is a DC (direct current) electric motor driving a load. The way its speed changes over time depends not only on the voltage applied, but also on the speed at the moment (now).

This setup can be modeled by a simple first order differential equation,  but since computers came along it became clear that a simpler model using difference equations would do the job as well.

Let time be seen as equally spaced points, labeled …n-1, n, n+1, … and the speed of the motor at time n be vn.

Then the model of the process  is vn+1 = avn + kun, where un is the  voltage input at time n. The values of a and k are to be determined from theoretical or observed behaviour of the motor.This model is very good if we choose to keep the input voltage constant for the duration of the time interval.

Now for the amusing bit. I had taught business students about exponentially weighted averages numerous times previous to my sabbatical year studying control systems, and when I finally became happy with the discrete models as described above I realized in one of those moments that don’t happen very often that the equations were THE SAME in both cases. A bit of rewriting needed !

ewma(n) = (1-k)*ewma(n-1) + k*x(n)
vn+1 = avn + kun

Next post will look at feedback and computer control of dynamic systems.

4 Comments

Filed under discrete model, dynamic systems, engineering, forecasting, math, math apps, time series, Uncategorized

Time Series and Discrete Processes, or Calculus Takes a Back Seat

 

In the business and manufacturing world data keeps on coming in. What is it telling me? What is it telling me about the past? Can it tell me something believable about the future. These streams of data form the food for “time series analysis”, procedures for condensing
the data into manageable amounts.

Here is a plot of quarterly Apple I-phone sales. (ignore the obvious error, this is common)

applepic

I see several things, one is a pronounced and fairly regular variation according to the quarter, another is an apparent tendency for the sales to be increasing over time, and the third is what I will call the jiggling up and down, more formally called the unpredictable or random behaviour.
The quarterly variation can be removed from the data by “seasonal analysis”, a standard method which I am not going to deal wirh (look it up. Here’s a link:

https://onlinecourses.science.psu.edu/stat510/node/69
The gradual increase, if real, can be found by fitting a straight line to the data using linear regression, and then subtracting the line value from the observed value for each data point. This gives the “residuals”, which are the unpredictable bits.

Some time series have no pattern, and can be viewed as entirely residuals.
We cannot presume that the residuals are just “random”, so we need a process of smoothing the data to a) reveal any short term drifting, and b) some help with prediction.
The simple way is that of “moving average”, the average of the last k residuals. Let’s take k = 5, why not !
Then symbolically, with the most recent five data items now as x(n), x(n-1),..,x(n-4), the moving average is

ma = (x(n)+x(n-1)+x(n-2)+x(n-3)+x(n-4))/5

If we write it as ma = x(n)/5 + x(n-1)/5 + x(n-2)/5 + x(n-3)/5 + x(n-4)/5 we can see that this is a weighted sum of the last five items, each with a weight of 1/5 (the weights add up to 1).
This is fine for smoothing the data, but not very good for finding out anything about future short term behaviour.
It was figured out around 60 years ago that if the weights got smaller as the data points became further back in time then things might be better.

Consider taking the first weight, that applied to x(n) as 1/5, or 0.2 so the next one back is 0.2 squared and so on. These won’t add up to 1 which is needed for an average, so we fix it.
0.2 + 0.2^2 + 0.2^3 + … is equal to 0.2/(1-0.2) or 0.2/0.8 so the initial weights all need to be divided by the 0.8, and we get the “exponentially weighted moving average” ewma.

ewma(n) =
x(n)*0.8+x(n-1)*0.8*0.2+x(n-2)*0.8*0.04+x(n-3)*0.8*0.008+x(n-)*0.8*0.0016 + …… where n is the time variable, in the form 1, 2, 3, 4, …

A quick look at this shows that ewma(n-1) is buried in the right hand side, and we can see that ewma(n) = 0.2*ewma(n-1) + 0.8*x(n),
which makes the progressive calculations very simple.
In words, the next value of the ewma is a weighted average of the previous value of the ewma and the new data value. (0.2 + 0.8 = 1)

The weighting we have just worked out is not very useful, as it pays too much attention to the new data, and the ewma will therefore be almost as jumpy as the data. Better values are in the range 0.2 to 0.05 as you can see in the following pictures, in which the k value is the weighting of the data value x, and the weighting of the ewma value is then (1-k):

So the general form is ewma(n) = (1-k)*ewma(n-1) + k*x(n)

mapic1

With k=0.5 we do not get a very good idea of the general level of the sequence, as the ewma value is halfway between the data and the previous ewma value, so we try k=0.1

mapic2

Much better, in spite of my having increased the random range from 4 to 10.

Going back to random=4, but giving the data an upward drift the ewma picks up the direction of the drift, but fails to provide a good estimate of current data value. This can be fixed by modifying the ewma formula. A similar situation arises when the data values rise at first and then start to fall (second picture)

mapic3mapic4

Common sense says that to reduce the tracking error for a drifting sequence it is enough to increase the value of k. But that does not get rid of the error. We need a measure of error which gets bigger and bigger as long as the error persists. Well, one thing certainly gets bigger is the total error, so let us use it and see what happens.

Writing the error at time n as err(n), and the sum of errors to date as totalerr(n) we have

err(n) = x(n) – ewma(n), and totalerr(n) = totalerr(n-1) + err(n)

Then we can incorporate the accumulated error into the ewma formula by adding a small multiple of totalerr(n) to get

ewma(n) =  ewma(n) = (1-k)*ewma(n-1) + k*x(n) + h*totalerr(n)

In the first example below h = 0.05, and in the second h = 0.03, as things were too lively with h=0.05.

mapic5mapic6

A good article on moving averages is:
http://www.mcoscillator.com/learning_center/kb/market_history_and_background/who_first_came_up_with_moving_averages/

In my next post I will show how the exponentially weighted moving average can be described in the language of discrete time feedback systems models, as used in modern control systems, and with luck I will get as far as the z-transfer function idea.

4 Comments

Filed under algebra, computer, discrete model, engineering, errors, forecasting, math, statistics, time series, Uncategorized

I found Ciedie Aech. Now you have.

Well, actually, she commented on a comment of mine on someone else’s blog, which led me to finding her book, here:

https://ciedieaech.files.wordpress.com/2015/12/why-is-you-always-got-to-be-trippin2.pdf

Have you seen it yet? Have you read it yet?

It is a brilliant first-hand account of the school “reform” process from the receiving end, with a logically presented sequence of analyses, intertwined with actual happenings and incidents which make your hair stand on end.
The often believed statement “Corporate school reformers were once open about their belief that public education was hopelessly broken” she argues is simply untrue, but that this was what they wanted others to believe. They didn’t have to.
Her story covers the years from 1995 to the present, and shows the full depth of mayhem caused by the “reform” movement.

Her account of the not too imaginary classroom where all the time is taken up following all the edicts and mandates that there is no time to actually do any teaching. It is priceless.

Here is a section on one of the many stupidities encountered:

Flying Blind
Frantically written upon demand by an evidently unbounded
wellspring of young hires, a torrent of suddenly created
district exams gushed up in a manner which soon began to feel
truly magical. And, as was becoming rapidly apparent, actually
understanding many of these precipitately manufactured tests?
Called for just a touch of magic as well.
Pushed repeatedly into the role of test graders, it wasn’t long
before a diversely collected school personnel began to comment
upon, and even argue about, not only the point value attached
to student responses but, more and more frequently, to the
tangible intentions behind the intricately worded test questions
themselves.
“Help!” I whispered to a grading partner one afternoon.
“Do you have any idea what this means?”
Sliding a test booklet across the table, I pointed to an essay
prompt so convoluted that I could make little sense of it:

“In what way does this story’s diction create foreshadowing while
working sympathetically inside the author’s choice of syntax?”

My students – well, if we were being very optimistic, at
least a couple of them – possibly knew what diction, foreshadowing,
and syntax meant. But even I didn’t know how to combine
these three uniquely discrete elements in a logical response for
this tortuous prompt. I struggled with my conscience, tempted to
give full credit to the student who had written simply, and I thought most reasonably:

“I don’t know what the fuck this is talking about.”

Another student, less inclined to waste words?
Had printed more succinctly: IDK.
I Don’t Know.
Well damn, kid, me neither.
Holding little patience for those old-school processes so
monotonously tied to a methodically careful (and oh-so-tedious)
analysis, as the years bent to the magic of no-waiting transformations
systematically edged out an educator resistance, it was
rapidly determined that a test question ambiguity (up to and including
plainly misleading typos) did not, actually, invalidate
tests. Nor, subsequently, nullify an endlessly collected testing
data. Specifically hired to address issues of examination, testing
experts were ready to advise; expressly versed in party line, assuredly
and absolutely they always knew the answer. Every single
time.
Oh, it was magical.
They could simply walk over and show you. “See?” Here
they could point with an absolute confidence to the official answer
sheet. “It’s right here,” they could tell you. “The answer is: D.”
Or: Two.
Or: No change.
In years now gloriously imbued with the high brilliance of
an instantaneous reformation, all you ever really had to do? Was
close your eyes. And, then, clicking your heels together: Believe.
Believe, as you took your first frightening step over an unknowable
cliff; believe, as anxiously you began to flap your arms; believe,
as apprehensively you started to fly alongside in a blind
obedience:
Believe, absolutely and without reservation?
In the answer sheet.

3 Comments

Filed under big brother, education, horrors, school, teaching, testing, tests, Uncategorized

Cleopatra, reborn in Mayaguez

When not blogging, gardening or cooking I assist in the productions of our ballet company, Western Ballet Theatre of PR, with my wife, Nana Badrena, the choreographer and artistic director. So to “Cleopatra”, the latest ballet, in neoclassical, Cuban School tradition. A flight from Newark, JFK, Philly, Miami and more, to Aguadilla (BQN) to see this wonderful recreation of ancient Egypt and its interaction with the Roman Empire.
WBT-Cleopatra2016 OFICIAL

And a few publicity pictures of the protagonists, Cleopatra, Mark Anthony and Julius Caesar:

color2color4color

787 241 5248 is me.

2 Comments

Filed under ballet, caribbean, Mayaguez, neoclassical, Uncategorized

New role for statisticians

The Onion strikes again, with real math humour (UK spelling, of course):

http://www.theonion.com/article/gop-statisticians-develop-new-branch-math-formulat-52463

Picture of target not needed !

Leave a comment

Filed under humor, statistics, Uncategorized

How A Plan Becomes A Policy

A+, 100%, 10/10, summa cum laude for this:

https://mathemagicalsite.wordpress.com/2016/02/28/how-a-plan-becomes-a-policy/

1 Comment

Filed under Uncategorized