Wolfram Computation Meets Knowledge

When do I use FindRoot instead of NSolve?

Like Solve, NSolve is designed primarily for solving polynomial equations.

In[1]:= NSolve[4 - r^2 == r, r]
Out[1]= {{r -> -2.56155}, {r -> 1.56155}}

The algebraic methods available in NSolve cannot handle general equations with transcendental functions—for example:

In[2]:= NSolve[4 Cos[r] == r, r]
  NSolve::nsmet: This system cannot be solved with the methods available to NSolve.
Out[2]= NSolve[4 Cos[r] == r, r] 

FindRoot uses numerical methods for starting at an initial value for the independent variable and locating a solution:

In[3]:= fr = FindRoot[ 4 Cos[r] == r, {r, 1}]
Out[3]= {r -> 1.25235}  

Verify that the returned value solves the equation:

In[4]:= (4 Cos[r] - r) /. fr // Chop
Out[4]= 0

FindRoot finds one solution per evaluation. To obtain further solutions with FindRoot, initial values need to be chosen sufficiently close to the other root locations:

In[5]:= Plot[ 4 Cos[r] - r, {r, -2 Pi, 2 Pi}]

4Cos[r] - r , 3 roots

In[6]:= FindRoot[ 4 Cos[r] == r, {r, -4}]
Out[6]= {r -> -3.5953}

In[7]:= FindRoot[ 4 Cos[r] == r, {r, -2}]
Out[7]= {r -> -2.13333}

See also the tutorial on numerical equation solving.

설명이 도움이 되었나요?
아니오

하실 말씀이 있습니까?

피드백 감사합니다.

제출하기

지원 문의

청구서, 제품 동기화에 관한 질문에서 기술적인 질문까지 부담없이 문의하세요.

1-800-WOLFRAM (국제 전화는 +1-217-398-0700)

고객 지원

월요일 - 금요일
8am–5pm 중부 표준시

  • 제품 등록 및 동기화
  • 구매 전 정보 및 주문
  • 설치 및 동작

고급 기술지원 (해당 고객을 대상으로)

월요일 - 목요일
8am–7pm 중부 표준시

금요일
8:30–10am & 11am–5pm 중부 표준시

  • 우선적 기술지원
  • Wolfram 전문가들의 제품 지원
  • Wolfram 프로그래밍
  • 고급 설치 지원