EXSLT - math:sqrt - EXSLT Function Implementation

Supported Version: 1
XML Definition: math.sqrt.xml
Source: math.sqrt.function.xsl

Source

<func:function name="math:sqrt">
<!--  The number you want to find the square root of  -->
   <xsl:param name="number"
              select="0" />
<!--  The current 'try'.  This is used internally.  -->
   <xsl:param name="try"
              select="1" />
<!--  The current iteration, checked against maxiter to limit loop count  -->
   <xsl:param name="iter"
              select="1" />
<!--  Set this up to ensure against infinite loops  -->
   <xsl:param name="maxiter"
              select="10" />
<!--  This template was written by Nate Austin using Sir Isaac Newton's
       method of finding roots  -->
   <xsl:choose>
      <xsl:when test="$try * $try = $number or $iter > $maxiter">
         <func:result select="$try" />
      </xsl:when>
      <xsl:otherwise>
         <func:result select="math:sqrt($number,                                      $try - (($try * $try - $number) div (2 * $try)),                                      $iter + 1, $maxiter)" />
      </xsl:otherwise>
   </xsl:choose>
</func:function>

Change History

Submitted: 2001-08-15
Creator: Nate Austin

http://www.exslt.org/math/functions/sqrt/math.sqrt.function.xsl.html last modified 2001-08-15