ROOT
ROOT low, high, segs, maxerr, BYREF result, BYREF errcode USE expr
Roots of f(x).
ROOT will find the first x-intercept of the given function ( where
f(x) = 0 ) in the interval [low
, high
]
low
: the lower limithigh
: the upper limitsegs
: the number of segments (spaces)maxerr
: tolerance (IF ABS(f(x)) < maxerr THEN OK)errcode
: 0 for success; otherwise calculation errorresult
: the resultexpr
: the given function
Example 1
def f1(x) = x - 2
' Theory: x - 2 = 0 -> x = 2
ROOT 0, 5, 500, 0.001, result, errcode USE f1(x)
if(errcode) then
print("No root found")
else
print "Root at "; result
endif
' Output: Root at 1.99951171875
Example 2
def f2(x) = x^2 - 2
' Theory: x^2 - 2 = 0 -> x^2 = 2 -> x = +/-sqr(2) = +/-1.41
ROOT -1, 2, 500, 0.001, result, errcode USE f2(x)
if(errcode) then
print("No root found")
else
print "Root at "; result
endif
' Output: Root at 1.4140625
Code samples using ROOT
Math
ABS
ABSMAX
ABSMIN
ACOS
ACOSH
ACOT
ACOTH
ACSC
ACSCH
ASEC
ASECH
ASIN
ASINH
ATAN
ATAN2
ATANH
ATN
CEIL
COS
COSH
COT
COTH
CSC
CSCH
DEG
DERIV
DETERM
DIFFEQN
EXP
EXPRSEQ
FIX
FLOOR
FRAC
INT
INTERSECT
INVERSE
LINEQN
LOG
LOG10
M3APPLY
M3IDENT
M3ROTATE
M3SCALE
M3TRANS
MAX
MIN
POLYAREA
POLYCENT
POLYEXT
POW
PTDISTLN
PTDISTSEG
PTSIGN
RAD
RND
ROOT
ROUND
SEC
SECH
SEGCOS
SEGLEN
SEGSIN
SEQ
SGN
SIN
SINH
SQR
STATMEAN
STATMEANDEV
STATMEDIAN
STATSPREADP
STATSPREADS
STATSTD
SUM
SUMSQ
TAN
TANH
TRANSPOSE
If there is insufficient information on this page and you wish learn more about ROOT,
please send an email to smallbasic@gmail.com. You can help to improve information about
ROOT by submitting a pull request,
click View Source for details. Note, an offline language reference text file is also available - see the Download section.