1
$\begingroup$

What function could I use to solve this equation for x:

E^(-x^2) = 1 - Cos[x]

I tried Solve, Reduce, Root... None of them worked.

FindInstance gave me an imaginary answer.

Adding Reals, gave me:

{{x -> Root[{-1 + E^-#1^2 + Cos[#1] &, -6.28318531096301494721675292506}]}}

but this is not the answer I wanted, which would be between 0 and 1.

How would I solve this?

As a side note, WolframAlpha got it.

$\endgroup$
3
  • 1
    $\begingroup$ E.g. Solve[E^(-x^2) == 1 - Cos[x] && 0 <= x <= 1, x] yields {{x -> Root[{1 - E^#1^2 + E^#1^2 Cos[#1] &, 0.94194408148019155746}]}}. See e.g. How do I work with Root objects? $\endgroup$
    – Artes
    Commented Apr 22, 2014 at 22:14
  • 1
    $\begingroup$ The reason Solve has a hard time is that it tries to find all solutions, but there are actually infinitely many of them: two each surrounding $x=2n\pi$ for all $n\in\mathbb Z$. (So WolframAlpha's answer is misleading.) Restricting the domain, as in Artes' comment, helps because then there are only a finite number of solutions. $\endgroup$
    – user484
    Commented Apr 22, 2014 at 22:17
  • 2
    $\begingroup$ Take a look also at How do I solve this equation? and Can Reduce really not solve for x here?. $\endgroup$
    – Artes
    Commented Apr 22, 2014 at 22:24

1 Answer 1

3
$\begingroup$

This?

NSolve[E^(-x^2) == 1 - Cos[x] && 0 < x < 1, x]
(* {{x -> 0.941944}} *)

Or this?

FindRoot[E^(-x^2) - (1 - Cos[x]), {x, 1}]
(* {x -> 0.941944} *)
$\endgroup$

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.