1
$\begingroup$

So, I think the problem that Im having is simple but, still, Im not sure on how to do it. I have an equation with no analitical solution:

$a_1 \sin \left(2 \theta \right)+a_2 \sin \left(2 \phi\right)+a_3 \cos \left(2 \theta\right)+a_4 \cos \left(2 \phi\right)=a_5$

where $a_i$ are just numbers which are not relevant to the discussion. This equation has numerical solutions, what I need is a list $\{\theta,\phi\}$ that satisfy this equation. What would be the best way to do this? Any help will be greatly appreciated.

$\endgroup$
3
  • 1
    $\begingroup$ There are infinitely many solutions, aren't there? (Even over the finite interval $[0, \pi]$ -- one equation, two unknowns.) $\endgroup$
    – Michael E2
    Commented Aug 4, 2014 at 20:11
  • $\begingroup$ Yes, that's right! $\endgroup$
    – MaxMorris
    Commented Aug 4, 2014 at 20:36
  • $\begingroup$ So what sort of list do you want? (A complete list of numbers is impossible.) $\endgroup$
    – Michael E2
    Commented Aug 4, 2014 at 20:39

1 Answer 1

5
$\begingroup$

What have you tried so far?

You can use Solve to solve for θ.

Solve[a1 Sin[2θ] + a2 Sin[2ϕ] + a3 Cos[2θ] + a4 Cos[2ϕ] == a5, θ] /. _C -> 0

Since your equation have periods π, you can just let ϕ run between 0 and π, and add arbitrary multiples of π to the solutions.

Another way

You can plot it using ContourPlot. I used bounds 0 < θ < π and 0 < ϕ < π since those are the periods.

With[{a1 = 1, a2 = 2, a3 = 2, a4 = 3, a5 = 4},
  ContourPlot[a1 Sin[2θ] + a2 Sin[2ϕ] + a3 Cos[2θ] + a4 Cos[2ϕ] == a5, {θ, 0, π}, {ϕ, 0, π}]
]

enter image description here

You can extract the points it found too.

With[{a1 = 1, a2 = 2, a3 = 2, a4 = 3, a5 = 4},
  Cases[
    ContourPlot[a1 Sin[2θ] + a2 Sin[2ϕ] + a3 Cos[2θ] + a4 Cos[2ϕ] == a5, {θ, 0, π}, {ϕ, 0, π}],
  {_Real, _Real}, Infinity]
]

(* {{0.785398,0.},{0.835369,0.0560999},{0.838041,0.0595571},
   {0.841498,0.0646637},{0.874146,0.1122},{0.8826,0.127197},
   {0.897598,0.158172},{0.902625,0.1683}, <<212>>, 
   {0.113599,2.91579},{0.1122,2.91602},{0.111224,2.91622},
   {0.106423,2.91719},{0.0560999,2.92813},{0.0413688,2.93192},
   {0.0206391,2.93783},{0.,2.94422}} *)

You can find more points this way by increasing MaxRecursion.

$\endgroup$
1
  • $\begingroup$ Thanks! That's exactly what I needed! Greatly appreciated! $\endgroup$
    – MaxMorris
    Commented Aug 4, 2014 at 20:37

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.