Mathematica 9 is now available
 Documentation / Mathematica / Built-in Functions / Programming / Tests  /
SameTest

  • SameTest is an option for functions like FixedPoint that specifies the comparison function to apply to pairs of results to determine whether they should be considered the same.
  • The default is usually SameTest -> Equal.
  • Settings for SameTest must be functions that take two arguments, and return True or False.
  • See the Mathematica book: Section 2.2.2.
  • See also: Throw.

    Further Examples

    Here is an implementation of Newton's method for finding the square root of starting with an initial guess of x.

    In[1]:=

    Iterating newtonsqrt2 will give better and better approximations to the square root of .

    In[2]:=

    Out[2]=

    You can use the SameTest option to FixedPointList to specify the stopping condition.

    In[3]:=

    In[4]:=

    Out[4]=



    Any questions about topics on this page? Click here to get an individual response.Buy NowMore Information
    THIS IS DOCUMENTATION FOR AN OBSOLETE PRODUCT.
    SEE THE DOCUMENTATION CENTER FOR THE LATEST INFORMATION.