[XSL-LIST Mailing List Archive Home] [By Thread] [By Date] [Recent Entries] [Reply To This Message]

Re: mathematical functions - specifically sqroot

Subject: Re: mathematical functions - specifically sqroot
From: Dimitre Novatchev <dnovatchev@xxxxxxxxx>
Date: Tue, 3 Dec 2002 14:15:44 -0800 (PST)
different mathematical functions
--- bix xslt  wrote:
 
> Attempting to resolve the following pseudo code:
> 
> N = number of children
> sqrt = sqRoot(N)
> 
> if (sqrt - (int)sqrt > 0)
>    w = (int)sqrt
>    h = w + 1
> else
>    w = sqrt
>    h = w
> 
> 
> I came across the following xslt script.  Is there a simpler way that
> I
> 
> might be able to implement this?  Currently, I am unable to download
> any 
> additional software off the internet onto my PC.  Consequently, I am
> also 
> unable to get the xalan, xerces, and saxon programs.  I am relying
> entirely 
> on MSXML2.0 at this point as I have IE 5.0. However, I am attempting
> to
> 
> develop for MSXML3.0 (or whichever version ships with IE 6.x) for an
> upgrade 
> my group will receive in May 2003.
> 
> Thanks in advance,
> Bix

[template skipped -- can be found at:
http://fxsl.sourceforge.net/articles/FuncProg/6.html#Square_root]


Hi Bix,
Let me start with the fact that MSXML2 does not implement XSLT 1.0 but
a different language -- therefore the chances of it understanding any
XSLT template (including templates that calculate sqrt) are close to
zero.

The template you listed is really more complex than it could be. It
uses "generators" that may be used to do processing in a similar way to
the processing of ***infinite*** lists, which is possible in languages
with lazy evaluation.

The same library (FXSL) contains the more generic "pow" function, which
can be used to calculate sqrt (a special case when the value of pPower
is 1/2).

http://fxsl.sourceforge.net/articles/xslCalculator/The%20FXSL%20Calculator.html#3._The_Exponential_and_Logarithmic_Functions


Or, one can use two different ways to solve the equation
x^2 - a = 0

which will produce sqrt(a):

http://fxsl.sourceforge.net/articles/xslCalculator/The%20FXSL%20Calculator.html#4._Solving_Equations_of_One_Real_Variable


Neither of these looks particularly simple, however these templates are
called in the most simple and shortest way possible. The end user need
not be concerned how they work and which numerical method they
implement.

This said, you may find the sqrt template of Nate Austin a little bit
simpler:

http://sources.redhat.com/ml/xsl-list/2001-08/msg00739.html

Even in this case understanding the logic requires understanding the
underlying numerical method.




=====
Cheers,

Dimitre Novatchev.
http://fxsl.sourceforge.net/ -- the home of FXSL

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com

 XSL-List info and archive:  http://www.mulberrytech.com/xsl/xsl-list


Current Thread

PURCHASE STYLUS STUDIO ONLINE TODAY!

Purchasing Stylus Studio from our online shop is Easy, Secure and Value Priced!

Buy Stylus Studio Now

Download The World's Best XML IDE!

Accelerate XML development with our award-winning XML IDE - Download a free trial today!

Don't miss another message! Subscribe to this list today.
Email
First Name
Last Name
Company
Subscribe in XML format
RSS 2.0
Atom 0.3
Site Map | Privacy Policy | Terms of Use | Trademarks
Free Stylus Studio XML Training:
W3C Member
Stylus Studio® and DataDirect XQuery ™are products from DataDirect Technologies, is a registered trademark of Progress Software Corporation, in the U.S. and other countries. © 2004-2013 All Rights Reserved.