# How do I introduce a second equation to solve a first equation?

I have the following equation

$$\tag{1} M =\frac{n_{1}\cos \theta_1 - n_{2}\cos \theta_2 }{n_{1}\cos \theta_1 + n_{2}\cos \theta_2} \times \frac{n_{1}\cos \theta_1 - n_{3}\cos \theta_3 }{n_{1}\cos \theta_1 + n_{3}\cos \theta_3}$$

and I know that Snell's law means that:

$$\tag{2} n_{1}\sin \theta_1 = n_{2}\sin \theta_2 = n_{3}\sin \theta_3$$

I am trying to solve this equation for $$n_{1}$$, but how do I put both these equations as inputs to simplify eq 1?

This is my first time using Mathematica and I tried to solve (1) by doing

Solve[ ...... == M , n_{1}]


But I don't know how to introduce eq. 2 into this system.

Update

I introduced equation (2) into the command according to what was suggested below in the following link.

Solve[ {...... == M , n_{1}*sin(\theta_1)==n_{2}*sin(\theta_2)==n_{3}*sin(\theta_3)}, n_{1}]


But can I do that? Can I add two equalities into a single equation of 3 parts as shown in equation (2)?

• For basics see this tutorial. In particular, = is an assignment. Oct 31, 2022 at 11:54
• Welcome to the Mathematica Stack Exchange. Please include Mathematica code that you have tried so far.
– Syed
Oct 31, 2022 at 12:51
• @Syed , I am yet to try any code that isn't the one I wrote above. Oct 31, 2022 at 13:27
• You didn't define nsam so far! Oct 31, 2022 at 14:12
• My bad, it should have been $n_1$. I hope this makes more sense. I will update on things I have done, but that still do not work. Oct 31, 2022 at 14:42

Perhaps

Solve[{ M == (n1 Cos[\[Theta]1] - n2 Cos[\[Theta]2])/(n1 Cos[\[Theta]1] + n2 Cos[\[Theta]2]) (n1 Cos[\[Theta]1] - n3 Cos[\[Theta]3])/(n1 Cos[\[Theta]1] + n3 Cos[\[Theta]3]),
n1 Sin[\[Theta]1] == n2 Sin[\[Theta]2],
n2 Sin[\[Theta]2] == n3 Sin[\[Theta]3] }
,{n1, n2, M}]

(*{{n1 -> n3 Csc[\[Theta]1] Sin[\[Theta]3],
n2 -> n3 Csc[\[Theta]2] Sin[\[Theta]3],
M -> ((Cos[\[Theta]2] Sin[\[Theta]1] -Cos[\[Theta]1] Sin[\[Theta]2]) (Cos[\[Theta]3] Sin[\[Theta]1] -Cos[\[Theta]1] Sin[\[Theta]3]))/((Cos[\[Theta]2] Sin[\[Theta]1] \+ Cos[\[Theta]1] Sin[\[Theta]2]) (Cos[\[Theta]3]Sin[\[Theta]1] +Cos[\[Theta]1] Sin[\[Theta]3]))}}*)


is what you're looking for?

• I believe so (the programme keeps on crashing on my computer so I can't be certain) but why did you select all three $n_1, n_2, M$ as the variables? I only want $n_1$ on the left side. Is that so I could see the 3 different answers obtained? Oct 31, 2022 at 15:47
• There are three equations so you must specify three unknowns. You can designate one or more of the unknowns to be solved for and the rest to be eliminated. To get only n1 and eliminate {n2, M}, use Solve[eqns, n1, {n2, M}] Oct 31, 2022 at 17:03
• Thank you so much, this was exactly what I was looking for. Nov 1, 2022 at 8:50
• @user7077252 You'e welcome! Nov 1, 2022 at 9:09