NthRoot ( )

Function stats

Average user rating
29
215
9999
Support
FileMaker 7.0 +
Date posted
13 April 2009
Version
1
Recursive function
No

Author Info
 Genx

14 functions

Average Rating 4.1

author_avatar



 

Function overview

Prototype

NthRoot  ( num;   n )


Parameters

num  The number you want to take the root of


n  The root you're after.


Description

I'm sorry for this function, I really am but it's lack of existence seems moronic especially with the existence of the sqrt function. Plus it's not necessarily all that obvious to some people.

Examples

Sample input

NthRoot(27;3)


Sample output

3

 

Function code

num^(1/n)

// ===================================
/*

    This function is published on FileMaker Custom Functions
    to check for updates and provide feedback and bug reports
    please visit http://www.fmfunctions.com/fid/215

    Prototype: NthRoot( num; n )
    Function Author: Genx (http://www.fmfunctions.com/mid/29)
    Last updated: 13 April 2009
    Version: 1

*/
// ===================================

 

Comments

Daniele Raybaudi
15 April 2009



Hi Genx ;)

what if n is negative ?
what if num is negative ?
  General comment
Genx
15 April 2009



Hey Daniele,

Unless my algebra knowledge is way off [and it could be :p], it doesn't matter if n is negative or not. As for the negative number... FileMaker will automatically return a "?" whenever you try to take the fractional exponent of a negative number because it can't calculate it which would be the expected result in any case....

BUT, we could correct for this because technically, provided that number is an odd whole number simply taking the relevant root of the absolute value of that number and making it a negative would technically give you a correct number, but people don't generally correct for that do they?
(Edited by Genx on 15/04/09 )
  General comment
Daniele Raybaudi
18 April 2009



See these examples:

10 ^ 3 = 1000 ; NthRoot( 1000 ; 3 ) = 10 ( correct )
10 ^ - 3 = .001 ; NthRoot( .001 ; - 3 ) = 10 ( correct )
- 10 ^ 3 = - 1000 ; NthRoot( - 1000 ; 3 ) = ?
- 10 ^ - 3 = - .001 ; NthRoot( - .001 ; - 3 ) = ?
  General comment
Genx
19 April 2009



Right, so what you're saying is that this function should spit out -10 instead of question for the second two examples. What happens when the exponent isn't a whole number or a basic fraction though? E.g. -10^0.25231

Do we just ignore in that case?
(Edited by Genx on 19/04/09 )
  General comment

 

 


Login or register to comment

Create a new account with fmcustomfunctions.com or login to post a comment.

 

 

 

Top Tags

Text Parsing  (24)
List  (19)
XML  (15)
Format  (14)
Date  (14)
Debug  (12)
Layout  (11)
Variables  (10)
Filter  (9)
ValueIterator  (6)
Layout Objects  (6)
Number  (5)
Recursive  (5)
Dev  (5)
Interface  (5)
Text  (5)