Mathematica Stack Exchange is a question and answer site for users of Mathematica. Join them; it only takes a minute:

Sign up
Here's how it works:
  1. Anybody can ask a question
  2. Anybody can answer
  3. The best answers are voted up and rise to the top

I am trying to numerically find the root of a function that looks a bit like: 1/x - (SchurDecomposition[A[x]][[2]])[[1]], where A is some matrix using the syntax

FindRoot[f[x], {x,3}], 


f[x_?NumericQ] = 1/x - (SchurDecomposition[A[x]][[2]])[[1]]

However when I monitor the values of x evaluated using the option StepMonitor :> Print[x], the first value that appears is far away (e.g. 6) from my specified start point (i.e. 3). Does anybody understand why it is doing this? This is an issue since the value being used (in my example 6) lies far away from the attractor basin of the function and hence FindRoot is giving me a wrong result. The initial starting value (in my example 3) lies very close to the root as I can see by plotting the function. In practice my numbers are a bit different and the function to calculate the matrix A quite complicated, however these have been extensively verified and I am sure they are working correctly.

Thanks for your help.

share|improve this question
Please try to format your code, jut indent the code lines with 4 spaces. It will make it easier to read and more likely that people will help you. – s0rce Mar 11 '13 at 15:24
I don't know this for sure, but I have always suspected that FindRoot does what any good general-purpose root finder will do: it begins by attempting to bracket a root, any root. (One method is to search to the left and right of a starting point, doubling the step size at each stage, until the function attains values of opposite signs.) You can control this by specifying a bracket yourself via the option Method -> "Brent": see the help page. – whuber Mar 11 '13 at 15:40
You could constrain the search range using FindRoot[lhs==rhs,{x,Subscript[x, start],Subscript[x, min],Subscript[x, max]}] searches for a solution, stopping the search if x ever gets outside the range Subscript[x, min] to Subscript[x, max]. – Stephen Luttrell Mar 11 '13 at 15:43
What is 3 - f[3]/f'[3] (the first step in Newton's Method)? Without A no one can really test your code. – Michael E2 Mar 11 '13 at 15:46
For what it's worth I have managed to get this work, albeit it with a workaround. Essentially I first define an interpolating function for the SchurDecomposition term and then use this in the definition of f[x] instead. – Matthew Mar 11 '13 at 16:53

Your Answer


By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.