I need to make a summation formula currently under the name "num_approx"
I keep getting some errors I cant pinpoint how to fix.
This is my code:
I get the following errors I cannot resolve. Please help.
I keep getting some errors I cant pinpoint how to fix.
This is my code:
import numpy as np import math T = 5777 h = 6.626e-34 #J/s c = 2.998e17 #nm/s k = 1.384e-23 #J/K lambda_nm = 2500 #nm C2nm= h*c/k n = np.arange(1.0,11.0,1.0) x = C2nm/(lambda_nm*T) num_approx= 15/((math.pi)**4) * (exp(- n * x)/n)(x**3 + (3* x**2)/n + (6 * x^2)/(n**2) + (6)/(n**3)) print("C2nm =", C2nm) print("n =", n) print("Numerical approximation is =", num_approx)###########################
I get the following errors I cannot resolve. Please help.
Error:TypeError Traceback (most recent call last)
<ipython-input-13-0fa7a7e31d3e> in <module>
10 n = np.arange(1.0,11.0,1.0)
11 x = C2nm/(lambda_nm*T)
---> 12 num_approx= 15/((math.pi)**4) * (exp(- n * x)/n)(x**3 + (3* x**2)/n + (6 * x^2)/(n**2) + (6)/(n**3))
13
14
~\Anaconda3\lib\site-packages\mpmath\ctx_mp_python.py in f(x, **kwargs)
1001 def f(x, **kwargs):
1002 if type(x) not in ctx.types:
-> 1003 x = ctx.convert(x)
1004 prec, rounding = ctx._prec_rounding
1005 if kwargs:
~\Anaconda3\lib\site-packages\mpmath\ctx_mp_python.py in convert(ctx, x, strings)
646 if isinstance(x, complex):
647 return ctx.make_mpc((from_float(x.real), from_float(x.imag)))
--> 648 if type(x).__module__ == 'numpy': return ctx.npconvert(x)
649 if isinstance(x, numbers.Rational): # e.g. Fraction
650 try: x = rational.mpq(int(x.numerator), int(x.denominator))
~\Anaconda3\lib\site-packages\mpmath\ctx_mp_python.py in npconvert(ctx, x)
679 if isinstance(x, np.complexfloating):
680 return ctx.make_mpc((from_npfloat(x.real), from_npfloat(x.imag)))
--> 681 raise TypeError("cannot create mpf from " + repr(x))
682
683 def isnan(ctx, x):
TypeError: cannot create mpf from array([-0.99381282, -1.98762564, -2.98143845, -3.97525127, -4.96906409,
-5.96287691, -6.95668972, -7.95050254, -8.94431536, -9.93812818])