# Tangent line, slope and intercept at y=0 from data points

If I have the following data:

https://pastebin.com/ti6pwnPP


Which plotted with ListLinePlot[data] looks like:

Questions:

1) How can I slide a tangent through different points? 2) How can I find the slope at those different points? 3) How can I find the intercept at y=0 from the different tangents (the ones tha apply)?.

I tried using a methodology similar to what was used here: How to get a tangent segment to a manipulated graph appear to be of constant length but I am not sure how to do this with data.

EDIT:

This is the approach I have been trying to do so far:

tts1={};
peak[dataset_, {start_, end_}] := Module[{region, peak},
region = Select[dataset, start <= #[[1]] <= end &];
peak = Interpolation[region];
peakfunction = AppendTo[tts1, peak];
];


Where after using peak[data, {65, 80}], peakfunction gives me the InterpolatingFunction that fits the entire peak.

My problem is when I tried to use the similar approach used in How to get a tangent segment to a manipulated graph appear to be of constant length

Tangent[f_, x_] := Module[{},
Manipulate[
Show[
Plot [f'[p] (x - p) + f[p], {x, p - 1, p + 1},
PlotStyle -> {Thick, Orange},
PlotRange -> {{50, 100}, {-0.1, 1.5}}],
Plot[f[x], {x, 65, 80}, PlotRange -> {{50, 100}, {-0.1, 1.5}},
PlotStyle -> {color}]
], {p, 65, 80,
0.2}, {color, {Purple -> "Purple"}]
]

f[x_]:=peakfunction[x];

Tangent[f,x]


I think in this approach (keep in mind I am a beginner in Mathematica) I cannot use f[x_]:=peakfunction[x] that way.

Since the tangent line to a function is:

$$f(a) + f'(a)(x-a)$$

f = Interpolation[data];
Manipulate[
Plot[{
f[x],
f[a] + f'[a] (x - a)
},
{x, 69, 79},
PlotRange -> Full,
Epilog -> {
Point[{a, f[a]}],
Text["Slope: " <> ToString[f'[a]], Scaled[{0.05, 0.95}], {-1, 1}],
Text["Intercept: " <> ToString[f[a] - a f'[a]], Scaled[{0.05, 0.85}], {-1, 1}]
}
],
{{a, 70}, 69, 79}
]


Interpolation turns data into a function. It may not be as smooth as you had hoped, but I would need to know what kind of smoothing function you'd like to apply if I were to improve it any further.

• MassDefect thank you so much! This is very good. I appreciate your help.
– John
Commented Jun 13, 2020 at 16:39
• @John Sorry for my slow reply. The comment is gone now, but yes, it was supposed to be f not int. Thanks for catching that. Commented Jun 14, 2020 at 4:44