#
# Initialise, and load the statistics package
#
restart;
with(Statistics):#
# Set up data and do the power fit
#
X:= Vector([2, 3, 6, 10, 14]):
Y:= Vector([2.5, 2.9, 3.7, 4.5, 5.1]):
sol:= PowerFit(X, Y, x);#
# First method to compute the value of sol for a
# few supplied values of x
#
eval(sol, x=17);
eval(sol, x=18);
eval(sol, x=100);#
# Second method to compute the value of sol. Convert
# the expression sol to a function which can then be
# applied to any given argument: apply it to a few
# argument values
#
f:= unapply( sol, x);
f(17);
f(18);
f(100);#
# How would *experienced* users do this - well
# probably just merge a few of the above statements
#
restart:
with(Statistics):
X:= Vector( [2, 3, 6, 10, 14 ] ):
Y:= Vector( [2.5, 2.9, 3.7, 4.5, 5.1] ):
f:= unapply( PowerFit(X, Y, x), x);
f(17);
f(18);
f(100);