User Tools

Site Tools


nth_root_of_x

Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revision Previous revision
Next revision
Previous revision
nth_root_of_x [2014/03/31 23:49]
Jay.Tanner.x@PHPScienceLabs.us
nth_root_of_x [2015/06/23 00:01] (current)
Jay.Tanner.x@PHPScienceLabs.us
Line 1: Line 1:
 ~~NOCACHE~~ ~~NOCACHE~~
 ~~DISCUSSION:​off~~ ~~DISCUSSION:​off~~
 +Back to:  **[[Arbitrary-Precision Math]]** \\
 =====Nth Root of X===== =====Nth Root of X=====
-Sometimes we may want to compute a square root or a cube root or a fifth root some other root of a number to some specified degree of precision. The function below will compute the arbitrary-precision Nth root of argument X.  As with all BC math functions, the X argument should be given as a numerical string, between quotes, like "​1.2345"​ or '​1.2345',​ so as not to be misinterpreted as a normal ​floating point value.+Sometimes we may want to compute a square root or a cube root or a fifth root some other root of a number to some specified degree of precision. The function below will compute the arbitrary-precision Nth root of argument X.  As with all BC math functions, the X argument should be given as a numerical string, between quotes, like "​1.2345"​ or '​1.2345',​ so as not to be misinterpreted as a standard double-precision ​floating point value.
 \\ \\
 <​code>​ <​code>​
-A general-purpose root computation function ​is based on a simple iterative algorithm.+A general-purpose, arbitrary-precision,​ Nth root computation 
 +function based on a simple iterative algorithm.
  
 Let: Let:
Line 22: Line 23:
  
 START: START:
-b = (a + X/(a^n)) / n+b = (a + X/(a^n)) / N
  
 If (a == b) to (d) decimals, then finished, (b) is the root value. If (a == b) to (d) decimals, then finished, (b) is the root value.
Line 168: Line 169:
  
  
-   ​function ​bcNth_Root_Of_X ​($N, $X, $NumDecimals=16)+   ​function ​bcNth_Root_of_X ​($N, $X, $NumDecimals=16)
 { {
    $a = sprintf("​%1.16f",​ pow($X, 1/$N)); // Compute first approximation    $a = sprintf("​%1.16f",​ pow($X, 1/$N)); // Compute first approximation
nth_root_of_x.1396324158.txt.gz · Last modified: 2014/03/31 23:49 by Jay.Tanner.x@PHPScienceLabs.us