# Solving a trigonometric equation with one parameter

I have the following equation:

2 a^2 k^2 Sin[b k] - 6 a (k Cos[b k] - Sin[b k]/b) == 0


I set the value of b to 1, and I want to plot the value of k as it ranges over 0.01 to 6.0 in increments of 0.01.

When the above equation becomes zero for some value of a, I want to print the value of k. Later I will plot k as a function of ratio a/b.

This is a general question, but I am struggling with the logic can to solve this.

Do I put it in a loop?

xxx = 2 a^2 k^2 Sin[b k] - 6 a (k Cos[b k] - Sin[b k]/b)
b = 1;
Do[If[xxx == 0, {Print[k], Print[a]}, Continue[]], {a, 0.01, 6, 0.01}]


Thanks

• Please have a look at Table, possibly together with FindRoot or Solve. – Yves Klett Aug 3 '14 at 8:57

Setting b = 1 from the start, your equation can be rewritten as

(3 k)/(3 + a k^2) == Tan[k]


This has multiple solutions for k for any given value of a. Here's e.g. the plot of the LHS and the RHS for a = 1; the intersections are the solutions:

Plot[
{ (3 k)/(3 + k^2), Tan[k] },
{k, -10, 10},
Exclusions -> Tan[k] == 0, PlotPoints -> 500
]


Assuming you want the smallest solutions for k > 0, we can follow the logic from this answer by Artes and throw in @Yves Klett's suggestion, to obtain

solutions = Table[
{a, Min[ k /. NSolve[(3 k)/(3 + a k^2) == Tan[k] && 0 < k < 10, k] ]},
{a, 1/100, 6, 1/100}
]

ListLinePlot[solutions]


Note that the range of Table is given in rationals rather than decimals; this is to prevent Solve from giving warning messages.

• I got this error: Solve was unable to solve the system with inexact coefficients. The answer was obtained by solving a corresponding exact system and numericizing the result, which I used Quiet to hide it. Should I be concerned about that? – seismatica Aug 3 '14 at 10:04
• @seismatica Good point, I forgot to mention that. No, you shouldn't: mathematica.stackexchange.com/q/6055/5485 . I've updated my answer; thanks for mentioning this! – Teake Nutma Aug 3 '14 at 10:15
• Why call Rationalize? Why not solutions = Table[{N[a], Min[k /. NSolve[(3 k)/(3 + a k^2) == Tan[k] && 0 < k < 10, k]]}, {a, 1/100, 6, 1/100}] instead? – m_goldberg Aug 3 '14 at 14:34
• @m_goldberg I agree, that's nicer -- I've updated the answer accordingly. – Teake Nutma Aug 3 '14 at 16:00