I have a curve produced by the code below in R/Sweave:
\documentclass[a4paper,12pt]{article}
\usepackage{Sweave} %%%%%%
\SweaveOpts{eps=TRUE}
\begin{document}
<<echo=FALSE, results=hide>>=
test.frame<-data.frame(ratio= c(0.0, 144.321, 159.407, 178.413, 202.557), value= c(0, 0.84, 0.8925, 0.945, 0.9975))
@
<<echo=FALSE,results=hide,eval=TRUE>>=
postscript('doudou.eps',
width=7, height=6,
colormodel="cmyk",
family = "ComputerModern",
horizontal = FALSE,
onefile=FALSE,
paper = "special",
encoding = "TeXtext.enc",
pagecentre=FALSE)
with(test.frame,plot(ratio, value, ylab= "Hello",
xlab="Wonderful",
type="o",
bty="o",
lty="solid",
lwd=3,
pch=1,
xaxp=c(0, 200, 4),
xlim=c(0,200),
yaxt = "n",
main=" My curve"))
axis(2,seq(0,1, by=0.5), las=2,cex=3,cex.lab=2,cex.axis=1.5,cex.main=2)
dev.off()
@
\begin{figure}[htbp]
\begin{center}
\includegraphics[width=0.8\textwidth]{doudou.eps}
\end{figure}
\end{document}
The curve has a x = +\sqrt(y) behaviour. I need to draw the maximum slope from the first point of the curve that is tangent to the initial curve slope. How to calculate the parameters with R so that I get the equation of the line?
An approximate solution is to find a best fit line but then the initial point (0, 0) of the dataset does not form part of the fitted line (we get a y-intercept other than zero).
Thanks a lot…
Your graph has five points: one at 0 and four between 144 and 203, so I don’t think you can say much about behaviour near 0.
You can get the slope of the first segment with
Or you can put a line through all the points restricted to going through the origin with
Or you can take your square-root function, which I think (but am not sure) you might intend to be
but in this case, note that the gradient of the tangent of
y = 0.07 sqrt(x)is infinite at 0.