You may want to use RandSeed to reset or initialize the random sequence. Also note that the
randNorm() function returns normally distributed random numbers.
[6.21] Evaluating polynomials
You don't need to explicitly calculate a polynomial like this:
2*x^3 + 3*x^2 + 4*x - 7 → result
Instead, TI BASIC has a polyEval() function that uses less ROM space:
polyEval({2,3,4,-7},x) → result
I don't have any specific timing results, but this method is very fast. You can use this method whenever
you have a sequence of powers of any function. Some examples:
use
polyEval({4,-6,8,-3},1/x)
4
x
3
−
6
x
2
+
8
x
− 3
use polyEval({4,-6,8,-3},1/ln(x))
4
[
ln
(
x
)]
3
−
6
[
ln
(
x
)]
2
+
8
ln
(
x
)
− 3
4[sin(x)]
3
- 6[sin(x)]
2
- 3 use polyEval({4,-6,0,-3},sin(x))
[6.22] Linear Interpolation
Linear interpolation is the least sophisticated, least accurate interpolation method. However, it has the
advantages that it is fast, and often accurate enough if the table values are closely spaced. Given a
table of function values like this:
y2x2
yx
y1x1
where x1, y1, x2 and y2 are given, the problem is to estimate y for some value of x. In general,
y = y1 +
(
y2 − y1
)
x−x1
x2−x1
which can be derived by finding the equation for the line that passes through (x1,y1) and (x2,y2).
If you interpolate often, it is worth defining this as a function. At the command line:
define interp(xx1,yy1,xx2,yy2,x)=yy1+(yy2-yy1)*((x-xx1)/(xx2-xx1))
or in the program editor:
interp(xx1,yy1,xx2,yy2,x)
Func
©Linear interpolation
yy1+(yy2-yy1)*((x-xx1)/(xx2-xx1))
EndFunc
6 - 24