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.
P0 = 0.1;
K = 1000;
Quiet[sol = Solve[{K*P*L == PL, P0 == P + PL, r*P0 == L + PL}, {P, L,PL}][[1]]];
complex = PL /. sol;
Plot[complex, {r, 0.1, 2}]

How can I make the solution into a function of parameter r in order to get the derivative of the solution, D[complex[r],r]?

share|improve this question
    
Are you just trying to take the derivative of complex? If so D[complex,r] is what you are looking for –  David Slater Nov 6 '12 at 19:33
    
Welcome to Mathematica.SE! I suggest the following: 1) As you receive help, try to give it too, by answering questions in your area of expertise. 2)Read the FAQs! 3) When you see good Q&A, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. ALSO, remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign` –  chris Nov 6 '12 at 20:38
add comment

2 Answers

You can do it nicely by defining a function complex

Clear[complex];
complex[x_] := PL /. sol /. r -> x;
Plot[{complex[r], Hold[Evaluate@D[complex[r], r]]} // Release, {r,0.1, 2}]

enter image description here

Otherwise as mentioned in the comment your definition of complex can also be used!

Clear[complex];
complex = PL /. sol;
Plot[{complex, Hold[Evaluate@D[complex, r]]} // Release, {r, 0.1, 2}]

In the mean time don't forget to notice the Hold issue with the Plot command. To perform symbolic operations (e.g Differentiation) inside Plot you need to use Hold as Plot replaces the function variable with numeric arguments and thus can result into wrong result for the inner symbolic operation.

share|improve this answer
add comment

Using your definitions, you can simply write:

Plot[Evaluate@{complex, D[complex, r]}, {r, 0.1, 2}]

The Evaluate makes sure that D[complex, r] gets evaluated and the expression for the derivative is passed to Plot.

share|improve this answer
add comment

Your Answer

 
discard

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