This is really a question about manipulating the output of Maximize. I have a function of 2 variables, defined thus:
Pqpcum[r_, b_] = Integrate[2 Pi*x*Pqp[x, b], {x, 0, r}, Assumptions -> {b > 0}]
I want to find the point where the maximum of a certain function, defined below, occurs:
Abs[Pqpcum[x1, b] - Pqpcum[x1, 0]], x1]
The function Maximize returns an array, like this:
In[24]:= Maximize[Abs[Pqpcum[x1, 0.1] - Pqpcum[x1, 0]], x1]
Out[24]= {0.0204023, {x1 -> 1.77787}}
Now I want to plot the location of the maximum, which is 1.77787 in this case, as a function of b. Attempting to get the second element of the array returns an element like this:
{x1 -> 1.777869648006448`}
The above cannot be plotted. I need to do something like this:
Plot[Maximize[Abs[Pqpcum[x1, b] - Pqpcum[x1, 0]], x1][[2]],{b,0,0.2}]
except that the above doesn't return anything, since I have plotted the list. How can I go about doing it? I could discretize the data and manually copy-paste the location of maximum values to do a ListLinePlot, but it would be a pain to do it.
EDIT:
I found my answer- I can use ArgMax instead.
It directly returns the location of the maximum, so the above can be done. But the question still remains- how in general can one manipulate a list that reads like {x1 -> 1.777869648006448} to get only the numeric value 1.777869648006448?
Plot[x1/.Maximize[Abs[Pqpcum[x1, b] - Pqpcum[x1, 0]], x1][[2]],{b,0,0.2}]How can I mark this question as solved? @Alexei - My In[24] is for a specific case where b takes the value 0.1. The general one is dependent on b, and it is the value that I needed to get. – Abhinav Oct 21 '13 at 10:04->and press F1 to find out it's aRule:) – Kuba Oct 21 '13 at 10:08