Hopefully not too difficult maths problem

SLAM: debunk creationism, pseudoscience, and superstitions. Discuss logic and morality.

Moderator: Alyrium Denryle

Post Reply
User avatar
Prozac the Robert
Jedi Master
Posts: 1327
Joined: 2004-05-05 09:01am
Location: UK

Hopefully not too difficult maths problem

Post by Prozac the Robert »

Because there are days when algebra keeps going wrong, and this is one of them.

Need to minimise this: a.cos(k) + b.cos(2.k) , where a and b can have different values in different situations.

It ought to be a matter of using a double angle formula and then playing with the algebra, but I keep loosing factors of two and so on. Hopefully one of you kind souls will write the answer down in a few steps. Or someone will tell me it's more complicated than I thought. Either way I'd be greatful.
Hi! I'm Prozac the Robert!

EBC: "We can categorically state that we will be releasing giant man-eating badgers into the area."
User avatar
Darth Wong
Sith Lord
Sith Lord
Posts: 70028
Joined: 2002-07-03 12:25am
Location: Toronto, Canada
Contact:

Post by Darth Wong »

Normally, you find the minimum(s) or maximum(s) of a function by taking its derivative (with respect to the variable for which you want to minimize the function) and setting it to zero.
Image
"It's not evil for God to do it. Or for someone to do it at God's command."- Jonathan Boyd on baby-killing

"you guys are fascinated with the use of those "rules of logic" to the extent that you don't really want to discussus anything."- GC

"I do not believe Russian Roulette is a stupid act" - Embracer of Darkness

"Viagra commercials appear to save lives" - tharkûn on US health care.

http://www.stardestroyer.net/Mike/RantMode/Blurbs.html
User avatar
Prozac the Robert
Jedi Master
Posts: 1327
Joined: 2004-05-05 09:01am
Location: UK

Post by Prozac the Robert »

Aye, but in this case that gets you more trig functions, which still have to be sorted out. I'm fairly certain the way I'm not doing right should be simpler.
Hi! I'm Prozac the Robert!

EBC: "We can categorically state that we will be releasing giant man-eating badgers into the area."
User avatar
Darth Wong
Sith Lord
Sith Lord
Posts: 70028
Joined: 2002-07-03 12:25am
Location: Toronto, Canada
Contact:

Post by Darth Wong »

Prozac the Robert wrote:Aye, but in this case that gets you more trig functions, which still have to be sorted out. I'm fairly certain the way I'm not doing right should be simpler.
What's so difficult about determining the point at which a trig function evaluates to zero?
Image
"It's not evil for God to do it. Or for someone to do it at God's command."- Jonathan Boyd on baby-killing

"you guys are fascinated with the use of those "rules of logic" to the extent that you don't really want to discussus anything."- GC

"I do not believe Russian Roulette is a stupid act" - Embracer of Darkness

"Viagra commercials appear to save lives" - tharkûn on US health care.

http://www.stardestroyer.net/Mike/RantMode/Blurbs.html
User avatar
Kuroneko
Jedi Council Member
Posts: 2469
Joined: 2003-03-13 03:10am
Location: Fréchet space
Contact:

Post by Kuroneko »

Let x = cos k. Then F = a cos(k) + b cos(2k) = 2bx²+ax-b, so that dF/dx = 4bx+a. From the chain rule, the roots of dF/dk occur at either dF/dx = 0 or dx/dk = 0, each of which are easily solvable for k.
"The fool saith in his heart that there is no empty set. But if that were so, then the set of all such sets would be empty, and hence it would be the empty set." -- Wesley Salmon
User avatar
Darth Servo
Emperor's Hand
Posts: 8805
Joined: 2002-10-10 06:12pm
Location: Satellite of Love

Post by Darth Servo »

The derivitive of cos is -sin. Sin is always 0 at x=0 and x=Pi. Since the second half of the function has 2x in the trig function, it has a derivative equal to zero every multiple of Pi/2. Therefore they BOTH have zeros and therefore the entire derivative equals zero at every multiple of Pi.
"everytime a person is born the Earth weighs just a little more."--DMJ on StarTrek.com
"You see now you are using your thinking and that is not a good thing!" DMJay on StarTrek.com

"Watching Sarli argue with Vympel, Stas, Schatten and the others is as bizarre as the idea of the 40-year-old Virgin telling Hugh Hefner that Hef knows nothing about pussy, and that he is the expert."--Elfdart
User avatar
Wyrm
Jedi Council Member
Posts: 2206
Joined: 2005-09-02 01:10pm
Location: In the sand, pooping hallucinogenic goodness.

Post by Wyrm »

Darth Servo wrote:The derivitive of cos is -sin. Sin is always 0 at x=0 and x=Pi. Since the second half of the function has 2x in the trig function, it has a derivative equal to zero every multiple of Pi/2. Therefore they BOTH have zeros and therefore the entire derivative equals zero at every multiple of Pi.
Strictly speaking, sin(k) has zeros at k=πn where n is an integer. Unless the domain is restricted, a cos(k) + b cos(2k) has an infinite number of extrema. Fortunately, the function is periodic on [0,2π), so we just need to find the extrema in that interval, and add a term 2πn to them to get all the roots.

Taking from Kuroneko's chain rule solution (I would've never thought to do it that way! I could do it, but I'd end up with a pain in the butt solution, and thus Kuroneko demonstrates why his coolness tends toward infinity!), the extrema are at the roots of dF/dx = 0 and dx/dk = 0. dF/dx = 0 where x = 0, which for cos(k) means k = π/2 + πn. Combined with our previous determination that extrema are at k = πn, means that all the extrema happen at k = πn/2.

Now, finding out if an extremum is a minimum, rather than a maximum, you need to determine if the second derivitive of the function at that extremum is positive (ie, the function is concave up).

d²F/dk² = d/dk[dF/dx dx/dk] = d²F/dx² (dx/dk)² + dF/dx d²x/dk² (because if we take f = dF/dx, d/dk[dF/dx] = df/dk = df/dx dx/dk = d²F/dk² dx/dk).

d²F/dk² = 4b cos²(x) - 4b cos²(x) - a cos(x) = - a cos(x).

d²F/dk² is therefore positive only on the extrema k = 3π/2 + 2πn, and thus F has minima at k = 3π/2 + 2πn, where F(3π/2 + 2πn) = -b. Since all the local minima achieve the same value, they are also global minima.

Now, if there is a closed interval for a domain for a completely arbitrary F, you would do well to check each end of the interval against the local minima we found by the above methods to find the global minimum. (If the interval is open, then the global minimum has to be in the interior of the interval, or it's Just Not Fair.)
Darth Wong on Strollers vs. Assholes: "There were days when I wished that my stroller had weapons on it."
wilfulton on Bible genetics: "If two screaming lunatics copulate in front of another screaming lunatic, the result will be yet another screaming lunatic. 8)"
SirNitram: "The nation of France is a theory, not a fact. It should therefore be approached with an open mind, and critically debated and considered."

Cornivore! | BAN-WATCH CANE: XVII | WWJDFAKB? - What Would Jesus Do... For a Klondike Bar? | Evil Bayesian Conspiracy
User avatar
Prozac the Robert
Jedi Master
Posts: 1327
Joined: 2004-05-05 09:01am
Location: UK

Post by Prozac the Robert »

Mike: It ought not be too difficult, but I seem to be somewhat rusty. This is a bad thing. But also, I was assured that there was a more elegant solution along the lines I was trying to describe.

That said, I do quite like that piece of maths Kuroneko, it's clever. It took me a while to work through (mostly due to my own ineptitude), but it works out nicely. So thanks very much.

In case anyone is interested, the equation results from attempting to describe a 1d line of evenly spaced spins in the Heisenberg model of magnetism. (This is probably mostly just added in the hope of making myself sound a little smarter after this little bout of mathematical failure).
Hi! I'm Prozac the Robert!

EBC: "We can categorically state that we will be releasing giant man-eating badgers into the area."
User avatar
Kuroneko
Jedi Council Member
Posts: 2469
Joined: 2003-03-13 03:10am
Location: Fréchet space
Contact:

Post by Kuroneko »

Some use of the chain rule is necessary in either case, but most people find polynomial functions to be easier to deal with. The content is not really changed; it's just a bit more compact. In any case, d²F/dk² = [d²F/dx²][dx²/dk²] + [dF/dx][d²x/dk²] = [4b][1-x²] + [4bx+a][-x] = -8bx²-ax+4b (note: dx²/dk² = sin²k = 1-x²). Plugging in x = -a/4b gives d²F/dk² = -[1/4][a²-16b²]/b. In other words, x = -a/4b is a local minimum iff [0<2b<|a|<4b or 0<-2b<|a|<-4b]. This is actually countably many solutions in k, with x = cos k.
"The fool saith in his heart that there is no empty set. But if that were so, then the set of all such sets would be empty, and hence it would be the empty set." -- Wesley Salmon
Post Reply