I fitted my stress-strain data with cubic fits as shown in the figure below and added the corresponding straight lines (dashed and same color). The problem is I put these straight lines at my own discretion by means of visual inspection. So of course if someone else tries to add these tangent straight lines, that would differ. I am wondering if there is a way to put tangent lines in a deterministic way allowing the "reproduceability". Thanks.

**Contents**hide

#### Best Answer

Let me talk about the general case:

You have a fitted curve ($hat{g}(x)$), and you want to draw a tangent line at some known point, $x^*$?

The slope at $x^*$ is $b=frac{d}{dx}hat{g}(x)|_{x=x^*} = hat{g}'(x^*)$.

The value of the function at $x^*$ is $y^* = hat{g}(x^*)$.

So you want a line through the point $(x^*,y^*)$ with slope $b$.

That is, $frac{y-y^*}{x-x^*}=b$. Rearranging, $y=y^*+b(x-x^*)=(y^*-bx^*)+bx=a+bx$.

That is, the line has slope $b=hat{g}'(x^*)$ and intercept $a=(y^*-bx^*)=hat{g}(x^*)-hat{g}'(x^*)x^*$.

The problem is figuring out what $x$-value you want to draw the tangent line *at*, rather than drawing the tangent line itself.

The point at which a cubic is "linear" (the point of inflexion) occurs when the second derivative is zero. One can only presume that's where you want to draw your tangent.

So you work out the second derivative of the fitted cubic (which is linear) and solve to find the $x$ at which it's zero.

So if the fitted cubic is of the form $a + bx + cx^2+dx^3$, its second derivative is $2c+6dx$ which is zero when $x=-frac{c}{3d}$.

### Similar Posts:

- Solved – How to interpret this Residuals vs Fitted plot for multiple regression
- Solved – Linear model fit seems off in R
- Solved – Proper terminology for what happens at knots in a cubic spline function
- Solved – Convex vs. concave curve – measurement or index
- Solved – Why the change in output of a sigmoid neuron is a linear function of change in weights and change in bias