I am little bit confused about how to calculate δβ/δρ value if I have set of values like this.

I have the values of β and ρ like this.

β          ρ

0,324     0,687
0,322     0,695
0,319     0,721
0,317     0,759
0,316     0,798


β={0.324, 0.322, 0.319, 0.317, 0.316};
ρ={0.687, 0.695, 0.721, 0.759, 0.798};

from the above set of values I would need to calculate δβ/δρ.

Can anyone explain me how to do it with Mathematica?

  • $\begingroup$ This is a Mathematica related site so people can tell you how to do it in Mathematica not "in microsoft excel or normal method"... $\endgroup$ – PlatoManiac Jun 28 '13 at 13:51
  • 1
    $\begingroup$ @Öskå I'm not convinced that your edit (specifically, where you changed it from asking for an Excel solution to a Mathematica one) was a good idea. If the OP isn't interested in Mathematica, I'd argue that it's better to close the question as off topic than to change it so that people end up answering a question that nobody actually asked. This ends up being a waste of time for both the OP and the answerers. $\endgroup$ – Oleksandr R. Jul 1 '13 at 18:32
  • $\begingroup$ I just assumed that "or other method" meant "or other software" since he just talked about Excel. And some new users might find it useful in the future. $\endgroup$ – Öskå Jul 2 '13 at 10:49

How about using the basic definition.

δβ/δρ = (β2-β1)/(ρ2-ρ1)

Since you have 5 data points,

β = {0.324, 0.322, 0.319, 0.317, 0.316};
ρ = {0.687, 0.695, 0.721, 0.759, 0.798};
ndata = 5;
grad = Table[(β[[i + 1]] - β[[i]])/(ρ[[i + 1]] - ρ[[i]]), {i, 1, ndata - 1}];
(* # of data for δβ/δρ will be ndata-1 *)
ListLinePlot[{Table[{ρ[[i]],β[[i]]},{i,1,ndata}],Table[{ρ[[i]],grad[[i]]},{i,1,ndata-1}]}, AxesLabel -> {"ρ", "β, δβ/δρ"}]


Further simplification

As Öskå pointed out it can be done even more simply.

β = {0.324, 0.322, 0.319, 0.317, 0.316};
ρ = {0.687, 0.695, 0.721, 0.759, 0.798};
grad = Differences[β]/Differences[ρ];
ndatabeta=Length[β]; ndatagrad=Length[grad];

Now you can use ndatabeta and ndatagrad as the number of data for your individual ListLinePlot.

| improve this answer | |
  • 3
    $\begingroup$ Or simply grad=Differences@β/Differences@ρ $\endgroup$ – Öskå Jun 28 '13 at 14:18
  • $\begingroup$ Thanks @Öskå. Looks like I am yet to overcome my Fortran-gia. $\endgroup$ – Sumit Jun 28 '13 at 14:25
  • $\begingroup$ @Sumit. Something seems to be a problem here. Based on the data shouldn't the magnitude of the slopes be decreasing? $\endgroup$ – Suba Thomas Jul 1 '13 at 14:34
  • $\begingroup$ @Sumit. I see you have used $\beta$ on the x-axis. I think it would be more natural to use $\rho$. Only the slopes in this answer appeared to have a different trend, and that had thrown me off. $\endgroup$ – Suba Thomas Jul 1 '13 at 14:39
  • $\begingroup$ Thanks @SubaThomas for pointing out. I have corrected that. It is just a result of my tendency to consider the first column as x. $\endgroup$ – Sumit Jul 1 '13 at 19:43

You can use Interpolation that will give β=fun[ρ]

fun = Interpolation[Transpose[{ρ, β}]];
Plot[Evaluate@{fun[t], fun'[t]}, {t, First@ρ, Last@ρ}, 
Frame -> True, Axes -> None]

enter image description here

The values of δβ/δρ you can find using fun'[t]

fun'[#] & /@ ρ

{-0.292927, -0.20972, -0.049016, -0.115988, -0.030338}

| improve this answer | |

enter image description here This can be accomplished just using Differences and / which will act componentwise. The points and the slopes can be plotted.

data=Thread[{\[Rho], \[Beta]}];
slopes=Thread[{Mean@# & /@ Partition[\[Rho], 2, 1], grad}];
ListPlot[{data,slopes},Joined -> True, 
Epilog -> {{Red, Point[data]},{Black,Point[slopes]}}]
| improve this answer | |

Yet another way to get the slopes.

D[Interpolation[\[Beta], t], t]/D[Interpolation[\[Rho], t], t];
Plot[%, {t, 2, 5}]

enter image description here

The values seem to jive with what is expected from the plot of $\beta$ and $\rho$. The negative slopes should gradually decrease in magnitude.

ListLinePlot[Thread[{\[Rho], \[Beta]}]]

enter image description here

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.