# Math Help - Solving trig equations

1. ## Solving trig equations

Hi,

It's been a number of years since I've had to use my high-school trig, so I'm actually embarrassed I have to ask this. It looks very simple but I've been staring at it for over a week and am getting nowhere.

I am trying to write some generic routines for some parametric 3D printer models and have simplified the problem to the following equations:
y = a / sin x
y = b - (c / tan x)

I want to find y for a set of known parameters a, b and c (x is the same for both, but unknown).

If I plot these two functions on a graph then I can see exactly one solution for the interval in which I am interested: (0 < x < 90degrees)

I don't know if it's because I've forgotten all my trig identities or just the simple art of solving simultaneous equations but all my attempts to reduce/solve for x have resulted in a mild headache...

Am I missing something obvious?

TIA

2. ## Re: Solving trig equations

Setting these two equal, you can write

$\dfrac{a}{\sin x} = b - \dfrac{c}{\tan x} = b - \dfrac{c\cos x}{\sin x}$.

Multiplying both sides of the equation by $\sin x$ you get:

$a = b\sin x - c\cos x$

Next, going back to the first equation and rewriting, you get

$\sin x = \dfrac{a}{y} = \dfrac{\text{opp}}{\text{hyp}}$

So, $\cos x = \dfrac{\text{adj}}{\text{hyp}} = \dfrac{\sqrt{y^2-a^2}}{y}$ (I applied the Pythagorean Theorem to find the length of the adjacent side).

Plugging in:

$a = \dfrac{ab}{y} + \dfrac{c\sqrt{y^2-a^2}}{y}$

Simplifying:

$ay - ab = c\sqrt{y^2-a^2}$

Squaring both sides:

$a^2y^2-2a^2by + a^2b^2 = c^2y^2-c^2a^2$

Now, you can get everything to one side of the equation:

$(a^2-c^2)y^2 - 2a^2by + a^2(b^2+c^2) = 0$

This gives you a quadratic equation. So, solving for $y$ and simplifying a bit, you get:

$y = \dfrac{a^2b \pm ac\sqrt{b^2 + 1 - a^2}}{(a^2-c^2)}$

3. ## Re: Solving trig equations

That's fantastic, thanks very much - sorry for the late reply, I was getting spurious results so I had to work through your example and found (what I think might be) a typo, plus potentially an over-simplification at the last step.

I think the typo is that this line:

$a = \dfrac{ab}{y} + \dfrac{c\sqrt{y^2-a^2}}{y}$

$a = \dfrac{ab}{y} - \dfrac{c\sqrt{y^2-a^2}}{y}$ (note the sign)

The expanded quadratic further down your example doesn't incorporate this typo so I'm guessing you just copied it out wrong when posting here.

I couldn't however arrive at the same simplified solution in your last line. Given that I'm implementing this in a 3D modelling pre-processing tool, it doesn't really matter if I use the un-simplified version though as I can swallow the fact that it'll be computationally more expensive.

If I plug my coefficients into the quadratic formula thus:

$a = a^2-c^2$

$b = 2a^2b$

$c = a^2(b^2+c^2)$

Then I get:

$y = \dfrac{-2a^2b \pm \sqrt{(2a^2b)^2 - 4(a^2-c^2)(a^2(b^2+c^2))}}{2(a^2-c^2)}$

Maybe curiosity will get the better of me someday and I'll come back to look at this...

Thanks again!

PS - the way this equation syntax works is great! I wish MSWord had something like this!

4. ## Re: Solving trig equations

The reason the typo didn't matter is because the fourth equation from the bottom (in my post) should have a negative sign on the RHS. Then in the third equation, I squared both sides (which gets rid of the negative sign).

You have an error. The quadratic is:

$(a^2-c^2)y^2 + (-2a^2b)y + (a^2(b^2+c^2)) = 0$

So the coefficient of $y$ is $-2a^2b$. You missed a minus sign.

To get to the simplified version, let's expand what is inside the square root, and on line 3 use associativity and commutativity to move terms around and add parentheses:

\begin{align*}(2a^2b)^2 - 4(a^2-c^2)(a^2(b^2+c^2)) & = 4a^4b^2 - (4a^2 - 4c^2)(a^2b^2 + a^2c^2) \\ & = 4a^4b^2 - 4a^4b^2 - 4a^4c^2 + 4a^2b^2c^2 + 4a^2c^4 \\ & = (4a^4b^2 - 4a^4b^2) + (4a^2b^2c^2 + 4a^2c^4 - 4a^4c^2) \\ & = 0 + 4a^2c^2(b^2 + c^2 - a^2) \\ & = 4a^2c^2(b^2+c^2-a^2)\end{align*}

Taking the square root, you get $2ac\sqrt{b^2+c^2-a^2}$ (so you were right, my simplified solution was not correct).

Then, the formula becomes:

$y = \dfrac{2a^2b \pm 2ac\sqrt{b^2+c^2-a^2}}{2(a^2-c^2)} = \dfrac{a^2b \pm ac\sqrt{b^2+c^2-a^2}}{a^2-c^2}$

Finally, MS Word does have something like this equation syntax. If you open the Equation Editor in MS Word, it accepts most LaTex-like syntax (with some minor differences). So, as you type, it replaces things like \alpha with the Greek letter. After you finish a character sequence, pressing the spacebar will cause the editor to evaluate any code you just typed.

PS - The simplified quadratic makes it easier to check that you can find real solutions for $y$. You can find real solutions if and only if $b^2+c^2-a^2 \ge 0$. So, adding an error checker to make sure that condition is met could handle any unexpected outcomes.

5. ## Re: Solving trig equations

Thank you very much for explaining it. I actually re-stated my problem better so that it was more easily applied within the context that I wanted to use it, and your explanation made it very easy to apply the steps to my new starting expressions.

I did discover one thing though; obviously I cannot divide by zero so the expression under the line

$$a^2 - c^2$$

gives me another way to check my parameters before attempting to find a solution. The odd thing however is that the case where a = c does in fact have a solution in my scenario, just not solvable using this method (if I substitute my values into the equations and plot the two graphs then they intersect in exactly one place).

It's not a problem right now, but it's a curiosity.

6. ## Re: Solving trig equations

Well, if $a^2-c^2=0$, then $c = \pm a$.

If $a=c=0$, then from the first equation $y = \dfrac{a}{\sin x} = \dfrac{0}{\sin x}$, you know $y = 0$ for all $x$ (this already gives you the solution for $y$).

If $a \neq 0$, then we can replace $c$ by $\pm a$:

$a = \dfrac{ab}{y} - \dfrac{c\sqrt{y^2-a^2}}{y} = \dfrac{ab}{y} - \dfrac{\pm a\sqrt{y^2-a^2}}{y}$

Since $a \neq 0$, we can divide both sides by $a$:

$1 = \dfrac{b}{y} \pm \dfrac{\sqrt{y^2-a^2}}{y}$

Multiplying both sides by $y$ gives:

$y = b \pm \sqrt{y^2-a^2}$

Next, subtract $b$ from both sides:

$y - b = \pm \sqrt{y^2-a^2}$

Square both sides:

$y^2-2by + b^2 = y^2-a^2$

Now, solving for $y$ is much easier:

$2by - b^2 = a^2$

$y = \dfrac{a^2+b^2}{2b}$

So, if $c = \pm a \neq 0$, this is the formula for $y$.