I have the relation λ=c/f, respectively f=c/λ and a simple function n[λ_]:=λ²+1. I'd like to differentiate the function with respect to f, then plot it as a function of λ again. For this, I can define the function


I can now compute

D[n[c/f], f]

To get that as a function of λ, I tried

nplot[f_]:=D[n[c/f], f]

(which does not work) and then


Is there no elegant way to switch between λ and f in plotting and computing - such, that I could just say




You could define an UpValues for λ to encapsulate your known relation:

SetAttributes[c, Constant]
Dt[f == c/λ, f]

1 == -c Dt[λ, f]/λ^2

Hence, we can define:

λ /: Dt[λ, f] = -λ^2/c



n[λ_] := λ^2+1

Dt[n[λ], f]

-2 λ^3/c

which is the requested derivative of n[λ] with respect to f in terms of λ.

  • $\begingroup$ Ah, that's neat. How would I then quickly plot n[λ] and Dt[n[λ],f]] as a function of f? For the first, I could just use Plot[n[c/λ],{λ,a,b}], but then I again have to give the range in terms of λ, not f. $\endgroup$ – Wasserwaage Oct 10 '18 at 7:04

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.