x=c(0,0.05,0.236,0.382,0.5,0.618,0.786,0.886,1)

x

f<-function(s){5*s*(s+1)}

y=f(x);y
z=y
z[1]=1
z[3]=1.25
z[4]=2.5 
z[6]=5
z[10]=10

curve(f,0,1.1)
points(x[c(1,3,4,6,9)],z[c(1,3,4,6,9)])

# Least square fit fb(s)=a+bs+cs^2.
xx=x[c(1,3,4,6,9)]
zz=z[c(1,3,4,6,9)]
A=matrix(1,5,3)
A[,2]=xx
A[,3]=xx^2

A

b=solve(t(A)%*%A,t(A)%*%zz);
b

fb<-function(s){b[1]+b[2]*s+b[3]*s^2} # approximation 
curve(fb,0,1.1)
points(x[c(1,3,4,6,9)],z[c(1,3,4,6,9)])

print("Start X")
print(x)
print("Start Y")
print(y)
print("Start Z")
print(z)
print("Approximation")
print(fb(x))

Embed on website

To embed this project on your website, copy the following code and paste it into your website's HTML: