# Can cos(a + 90 - b)=k.a be solved?

1. Jun 25, 2011

### kennethgilpin

hi,

quick question, is it possible to solve an equation of the type:

cos(a + 90 - b) = k.a

to find a where b and k are known? Do you have to solve this by iteration?

kenneth

2. Jun 25, 2011

### micromass

Staff Emeritus
Hi kennethgilpin!

I very much doubt that your equation can be solved analytically. But I'm quite sure you can find a numerical answer. Let's define

$$f:\mathbb{R}\rightarrow\mathbb{R}:x\rightarrow \frac{\cos(x+90-b)}{k}$$

take $x_0$ arbitrary and keep applying f on it. You'll get a sequence

$$x_0,f(x_0),f(f(x_0)),f(f(f(x_0))),...$$

Compute the first few terms and see if it converges. If it doesn't, then we'll have to apply more powerful methods...

3. Jun 26, 2011

### TylerH

We can group x and 90 and use the angle sum identity of cosine to say cos(x+90-b)=cos(x+90)cos(b)+sin(x+90)sin(b). We can use the same identity to say cos(x+90=cos(x)cos(90)-sin(x)sin(90)=-sin(x) and we can use the angle sum identity of sine to say sin(x+90)=sin(x)cos(90)+sin(90)cos(x)=cos(x). It follows that cos(x+90)cos(b)+sin(x+90)sin(b)=-sin(x)cos(b)+cos(x)sin(b). Therefore, cos(x+90-b)=cos(x)sin(b)-sin(x)cos(b).

We had to use the same identity twice, so I guess you could call it iterated.

4. Jun 27, 2011

### HeaVyJazZ

Sorry, didn't understand a thing the guys before me said xD sorry, but I'm guessing that it's not possible to find a FINITE answer as it is only one ecuation with three unknown answers.

5. Jun 27, 2011

### Mentallic

TylerH misunderstood the question, and the word you're looking for isn't finite, it's "expressible in terms of elementary functions". The solution(s) are definitely finite.

6. Jun 28, 2011

### kennethgilpin

Thank you for your detailed replies.

although I was pretty handy at maths, that was 'A' level which was almost 20 years ago, so I don't understand the notation in micromasses answer.

I'm a physiological modeller, and solved the equation by induction, i.e. by knowing my upper and lower limit for the equation I picked a value halfway, then calculated an answer for both sides of the equation, then picked a value halfway between that and so on. I'm guessing that micromass was sort of suggesting that.

The problem is that this has to be done about 25 times (*10 iterations) and each iteration has floating point stuff that computers don't like. Having to solve things by induction is the bane of physiological modelling.

kenneth

7. Jun 28, 2011

### Mentallic

The numerical method you're applying is quite slow, as you can tell. Applying Newton's method however will be a lot quicker.

It's defined as follows:

$$a_n=a_{n-1}-\frac{f(a_{n-1})}{f '(a_{n-1})}$$

And basically, this is how it works:

Since you need to solve for a (usually denoted as x), you let $$y=f(a)=ka-\cos\left(a+90-b\right)$$

Then find its derivative, $$f '(a)=k+\sin\left(a+90-b\right)$$

And for the first iteration, take a reasonably good guess at what the value of a is (denoted a0), then apply the Newton's method:

$$a_1=a_0-\frac{ka_0-\cos\left(a_0+90-b\right)}{k+\sin\left(a_0+90-b\right)}$$

a1 will be a better approximation, then you apply the same formula to find a2 etc.

EDIT: it's supposed to be f ' (a), LaTeX is screwing with me

8. Jun 28, 2011

### kennethgilpin

Ahh, I remember this from school. Presumably it only works if you can find a derivative of the original function.

9. Jun 28, 2011

### Mentallic

Yep, but unless you have other non-elementary functions that you're also dealing with, it shouldn't be a worry.

10. Jun 28, 2011

### PAllen

One caution about Newton's method is that a bad initial choice can diverge. If you are programming this, it should be easy to find open source code for 'safe newton/raphson', where you bound that a root must be in some interval. Then, the code detects a bad guess and uses another method for one iteration, going back to Newton thereafter. As long as you can find some bounds in which a root must be present, such codes are guaranteed convergent and quite fast.

In this case, for example, you can guarantee there is s root between [-pi,+pi].

[EDIT: oh, you are using degrees; make that between [-180,180] ]

Last edited: Jun 28, 2011