calc =\(a=2,h=1/2,print=TRUE){
b=a+h
f=\(x) (x-a)*(x-b)/(a*b)
f1=\(x) (2*x-a-b)/(a*b)
OQ=\(x) x^2 + f(x)^2
q=optimise(OQ,c(0,a))$minimum
O=0i
Q=q+1i*f(q)
if(print){
curve(f(x),-1,a+2*h,xlab=paste('a =',a,' h =',h),ylab='')
abline(v=0,h=0,lty=3)
seg(O,Q,col=8)
axy(f1(q),Q,-1,a+2*h,col=2,lwd=2)
pta(O)
pta(Q)
legend('center',bty='n',legend=paste('slope =',round(f1(q),3)))
}
f1(q)
}