Take the 2-minute tour ×
Mathematica Stack Exchange is a question and answer site for users of Mathematica. It's 100% free, no registration required.

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

aka:

β={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?

share|improve this question
    
This is a Mathematica related site so people can tell you how to do it in Mathematica not "in microsoft excel or normal method"... –  PlatoManiac Jun 28 '13 at 13:51
1  
@Ö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. –  Oleksandr R. Jul 1 '13 at 18:32
    
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. –  Öskå Jul 2 '13 at 10:49
add comment

4 Answers 4

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 -> {"ρ", "β, δβ/δρ"}]

grad

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];
ListLinePlot[{Table[{ρ[[i]],β[[i]]},{i,1,ndatabeta}],Table[{ρ[[i]],grad[[i]]},{i,1,ndatagrad}]}]

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

share|improve this answer
3  
Or simply grad=Differences@β/Differences@ρ –  Öskå Jun 28 '13 at 14:18
    
Thanks @Öskå. Looks like I am yet to overcome my Fortran-gia. –  Sumit Jun 28 '13 at 14:25
    
@Sumit. Something seems to be a problem here. Based on the data shouldn't the magnitude of the slopes be decreasing? –  Suba Thomas Jul 1 '13 at 14:34
    
@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. –  Suba Thomas Jul 1 '13 at 14:39
    
Thanks @SubaThomas for pointing out. I have corrected that. It is just a result of my tendency to consider the first column as x. –  Sumit Jul 1 '13 at 19:43
add comment

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}

share|improve this answer
add comment

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

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

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

share|improve this answer
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

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