Mathematica How to solve Solve x-2cosx=0 in mathematica

  • Thread starter Thread starter TitoSmooth
  • Start date Start date
  • Tags Tags
    Mathematica
AI Thread Summary
The discussion centers on solving the equation x - 2 cos[x] == 0 in Mathematica. The original poster encountered an error when using the Solve function with curly braces around the variable x. Participants suggest using the FindRoot function instead, which is suited for numerical solutions, as the equation is transcendental and lacks an exact solution. The correct syntax includes using an uppercase 'C' for the cosine function, as in Cos[x]. The initial guess for the FindRoot function is also emphasized, with a recommendation to start at x = 0.
TitoSmooth
Messages
158
Reaction score
6
Solve[x - 2 cos[x] == 0, {x}]


this is my imput but i get an error. What is the command to solve trig functions in mathematica

thanks. I searched online but no avail.
 
Physics news on Phys.org
Have you tried it without the curly braces on the x at the end?
 
Mugged said:
Have you tried it without the curly braces on the x at the end?
yes I get an error code.
 
Ok you probably should try the find root function.

FindRoot[x == 2Cos[x], {x,0}]

the 0 is an initial starting point in the numerical solver. I haven't used mathematica in a while but the problem might be that the solve function looks for an exact solution while your equation is transcendental...so no exact solution exists. mathematica's findroot or nsolve functions should work to numerically solve your equation.

Post back your result.
 
Last edited:
Yes, follow Mugged's advice and use FindRoot. You also have to use an uppercase C: Cos[x]
 

Similar threads

Replies
4
Views
3K
Replies
1
Views
2K
Replies
1
Views
2K
Replies
5
Views
3K
Replies
19
Views
2K
Back
Top