I am running this python code to derive the equation. R(x)=50 * ln(5x + 1)
i tried numpy.log and math.log
from sympy import Symbol, Derivative
import numpy as np
import math
x= Symbol('x')
function = 50*(math.log(5*x+1))
deriv= Derivative(function, x)
deriv.doit()
I am expecting to get the equation after derivative but i am getting the error
---------------------------------------------------------------------------
TypeError Traceback (most recent call last)
<ipython-input-107-e41161e3f329> in <module>()
5 x= Symbol('x')
6
----> 7 function = 50*(math.log(5*x+1))
8
9 deriv= Derivative(function, x)
~/anaconda3/lib/python3.7/site-packages/sympy/core/expr.py in __float__(self)
254 if result.is_number and result.as_real_imag()[1]:
255 raise TypeError("can't convert complex to float")
--> 256 raise TypeError("can't convert expression to float")
257
258 def __complex__(self):
TypeError: can't convert expression to float
Don't mix the math
with sympy
. Use log
from sympy
:
import sympy as sp
x= sp.Symbol('x')
y = 50*(sp.log(5*x+1))
deriv= sp.Derivative(y, x)
deriv.doit()
print(deriv.doit()) #250/(5*x + 1)
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With