'ConditionSet' object is not iterable for a in A

Solution 1:

The latest version of SymPy gives a different output: NotImplementedError. Note carefully that by default the domain over which maximum searches is all real numbers. If you plot your function you can see that its actual maximum is as -oo. You should specify Interval(0, oo) as the domain (not that it helps in this case).

The maximum function fails here because of the symbol T. If you aren't going to give values for all symbols (including T) besides the unknown v that you want to solve for then it's better just to make everything be a symbol:

In [49]: from sympy import *
    ...: 
    ...: h, c, kb = symbols('h, c, kb', positive=True)
    ...: v,T = symbols('v T',positive=True)
    ...: f = (2*h*v**3)/((c**2)*(exp((h*v)/(kb*T))-1))
    ...: 
    ...: derivative_f = f.diff(v)
    ...: [sol] = solve(derivative_f, v)

In [50]: sol
Out[50]: 
     ⎛ ⎛    -3⎞    ⎞
T⋅kb⋅⎝W⎝-3⋅ℯ  ⎠ + 3⎠
────────────────────
         h

The answer here is given in terms of the Lambert W function but you can just evalf the numeric part of this expression to see that it's a plain number:


In [51]: sol.evalf()
Out[51]: 
2.82143937212208⋅T⋅kb
─────────────────────
          h