1
$\begingroup$

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)?

$\endgroup$
5
  • 1
    $\begingroup$ For basics see this tutorial. In particular, = is an assignment. $\endgroup$
    – user293787
    Oct 31, 2022 at 11:54
  • $\begingroup$ Welcome to the Mathematica Stack Exchange. Please include Mathematica code that you have tried so far. $\endgroup$
    – Syed
    Oct 31, 2022 at 12:51
  • $\begingroup$ @Syed , I am yet to try any code that isn't the one I wrote above. $\endgroup$ Oct 31, 2022 at 13:27
  • 1
    $\begingroup$ You didn't define nsam so far! $\endgroup$ Oct 31, 2022 at 14:12
  • $\begingroup$ 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. $\endgroup$ Oct 31, 2022 at 14:42

1 Answer 1

4
$\begingroup$

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?

$\endgroup$
4
  • $\begingroup$ 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? $\endgroup$ Oct 31, 2022 at 15:47
  • 2
    $\begingroup$ 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}] $\endgroup$
    – Bob Hanlon
    Oct 31, 2022 at 17:03
  • $\begingroup$ Thank you so much, this was exactly what I was looking for. $\endgroup$ Nov 1, 2022 at 8:50
  • $\begingroup$ @user7077252 You'e welcome! $\endgroup$ Nov 1, 2022 at 9:09

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.