# Plot a curve with a list of data

I have a list of data in this form {{x1,y1},{x2,y2},...,{xn,yn}}, which can be plotted simply with

test = Get["~\\test.dat"];
ListLinePlot[test, PlotRange -> {{0, 10}, {0.35, 0.85}}, Frame -> True]


The list can be considered a function $$y=y(x)$$. Now, I want to plot a curve of $$f(x)=y(x)+x\frac{dy}{dx}$$.

Because there exists a derivation, I first tried Interpolation to make a function y.

dep = test[[All, 2]]; indep = test[[All, 1]];

y = Interpolation[dep,indep];


Then I construct the function and plot it, but it does not work...

f = dep + indep*D[y,indep]

Plot[f, {indep, 0, 10}, Frame -> True]


My problem should be simple, but I cannot figure out how to fix it. I think the issue may be the Interpolation step because I even cannot plot the function itself using the interpolation.

Plot[y, {indep, 0, 10}, Frame -> True]


data = First@ReadList["C:/test.dat"];
minmax = MinMax[data];
y = Interpolation[data];

p1 = ListPlot[data, PlotRange -> {-0.5, 1.0}];
p2 = Plot[y[x], {x, Splice@minmax}, PlotStyle -> Blue,
PlotRange -> {-0.5, 1.0}];
p3 = Plot[y'[x], {x, Splice@minmax}, PlotStyle -> Darker@Green,
PlotRange -> {-0.5, 1.0}];
p4 = Plot[y[x] + x y'[x], {x, Splice@minmax}, PlotStyle -> Red,
PlotRange -> {-0.5, 1.0}]

Show[p1, p2, p3, p4, GridLines -> Automatic]


EDIT

If you cannot use Splice due to an older version being in use, then use Sequence @@ as shown below:

p4 = Plot[y[x] + x y'[x], {x, Sequence @@ minmax}, PlotStyle -> Red,
PlotRange -> {-0.5, 1.0}];


To find the minimum point:

FindMinimum[y[x] + x y'[x], x]


{0.319033, {x -> 1.1225}}

Result:

• Thanks @Syed, your method basically works, but Splice function is removed after v.10. Could you modify the answer with another function that is available in later versions? Btw, may I ask a further question: is there a method to show also the min. value point of p4 plot by finding where its derivation is zero? I tried NSolve[2*y'[x]+x y''[x]==0,x] but does not work. Thank you! Sep 3, 2022 at 6:32
• I have updated my answer.
– Syed
Sep 3, 2022 at 7:33