1
$\begingroup$

I need help solving this equation

$$2- 12 sin(3 x) - 6 x = 0$$

using FindRoot, but it does not seem to work.

For example,

NFindRoot[2 - 12 sin[3 x] - 6 x == 0, x].

I also need help with plotting of a different task.

I have

Arean = Solve[{A == xy, x^2 + y^2 == (2 r)^2, r == 3}, {A, y, r}]

and I need to plot it but the line doesn't show up.

I tried

Plot[A /. Last[Arean], {x, 0, 4}, AxesLabel -> {"x", "A"}, 
 PlotStyle -> Green]
$\endgroup$
2
  • 1
    $\begingroup$ FindRoot needs a starting search point. Also it is Sin not sin. Try FindRoot[2 - 12 Sin[3 x] - 6 x == 0, {x, 0}] and you get a root. If you plot it, you see where approximatly the roots are. Plot[2 - 12 Sin[3 x] - 6 x, {x, -3, 3}] $\endgroup$
    – Nasser
    Apr 26 at 8:02
  • $\begingroup$ I suggest that you ask two different questions since they are so different in spirit. I believe that this is the general approach here $\endgroup$ Apr 26 at 8:03
4
$\begingroup$

Regarding the first part of your post, there are a number of mistakes. If you try

FindRoot[2 - 12 Sin[3 x] - 6 x == 0, {x, 1}]

you can get an answer.

The mistakes were that you should have used Sin instead of sin and the proper way to write the command is FindRoot

For the second question:

There is a mistake in your code and this is why the plot is not showing. You did not leave a space between the variables x and y

Try the following

Arean = Solve[{A == x y, x^2 + y^2 == (2 r)^2, r == 3}, {A, y, r}]

Plot[A /. Last[Arean], {x, 0, 4}, AxesLabel -> {"x", "A"}, 
 PlotStyle -> Green]
$\endgroup$
2
$\begingroup$

for the first part, you can first find the solutions

sol = Flatten[
  Table[FindRoot[2 - 12 Sin[3 x] - 6 x == 0, {x, i}], {i, -2, 2}]]
{x->-1.6325,x->-1.39504,x->0.047759,x->1.19582,x->1.81603}

and then you can check these solutions as follows

  ContourPlot[{2 - 12 Sin[3 x] - 6 x == y, y == 0}, {x, -3, 3}, {y, -1, 
      1}, Epilog -> {Red, AbsolutePointSize[5], 
       Point[Table[{sol[[i, 2]], 0}, {i, 5}]]}]  

enter image description here

the solutions are the red dots.

$\endgroup$
2
$\begingroup$

You can also use Solve or NSolve.

NSolve[2 - 12 Sin[3 x] - 6 x == 0, x, Reals]

{{x -> -1.6325}, {x -> -1.39504}, {x -> 0.047759}, {x -> 1.19582}, {x -> 1.81603}}

Plot[2 - 12 Sin[3 x] - 6 x, {x, -6, 6}, MeshFunctions -> {#2 &}, 
 Mesh -> {{0}}, MeshStyle -> Red]

enter image description here

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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