If I have the following data:
and the following code:
peakpositions1 = RankedMax[FindPeaks[data[[All, 2]]][[All, 2]],
3];(*Finds peak position of first peak in y*)
xval1 = Select[data, #[[2]] == peakpositions1 &][[All, 1]][[
1]];(*Finds peak position of second peak in x*)
peakpositions2 =
Max[FindPeaks[data[[All, 2]]][[All,
2]]];(*Finds peak position of second peak in y*)
xval2 = Select[data, #[[2]] == peakpositions2 &][[All, 1]][[
1]];(*Finds peak position of second peak in x*)
finalpeak1 = {xval1, peakpositions1};
finalpeak2 = {xval2, peakpositions2};
start = 40;
end = 95;
region = Select[data, start <= #[[1]] <= end &];
peak = Interpolation[region];
f = peak;
aspect = 2/3;
l = 50;
a = 3;
b = 70;
Manipulate[m := l/Sqrt[a^2 + aspect^2 b^2 f'[p]^2];
Show[Plot[f'[p] (x - p) + f[p], {x, p - m, p + m},
PlotStyle -> {Thick, Orange}, PlotRange -> {{60, 95}, {-0.5, All}},
AspectRatio -> aspect], ListPlot[{finalpeak1}, PlotStyle -> Red],
ListPlot[{finalpeak2}, PlotStyle -> Red],
Plot[f[x], {x, 65, 95}, PlotRange -> {{60, 95}, {-0.5, All}},
PlotStyle -> {Blue}],
Epilog -> {Point[{p, f[p]}],
Text["Slope: " <> ToString[f'[p]], Scaled[{0.05, 0.95}], {-1, 1}],
Text["Intecept: " <> ToString[-(f[p] - p*f'[p])/f'[p]],
Scaled[{0.05, 0.85}], {-1, 1}]}], {p, 65, 95, 0.05}]
which gives a manipulable sliding tangent around my data that shows the following:
1)the slope of the tangent 2)the x-intercept 3) the peak position of the two peaks of interest (in red)
such as in the picture below:
My question is:
1) How can I automatically get the intercept at x when the tangent intercepts the peak of both curves (red dots in the figure) and at the same time the slope is maximum?. I only need this for when the tangent is located from the left side of the curve or peak. For example visually it seems that the maximum slope that intercepts the peak is 0.267636 and the x-intercept is 71.3824 (as in the picture 1) for the first peak. For the second peak the maximum slope that intercepts the peak seems to be 5.03089 and the x-intercept 88.2961 such as the picture below:
This does not have to be with Manipulate. The only reason I used Manipulate is so that the question is more clear.
BONUS: This question is an attempt to solve a question I posted here: Find onset and peak temperatures , which has a bounty of 50 points. If you post your answer here and also in the link I will give you also the bounty of the link.
I appreciate in advanced your help.

