1
I’m trying to plot a chart of an integral I solved, but it’s giving error :
from sympy import *
from sympy.plotting import *
%matplotlib inline
r=Symbol('r')
e=Symbol('e')
r=(1,10,100)
k=((rho)/(E*r**2))*(-e**(-r)*r**(2)-2e**(-r)*r-2e**(-r)+2)
k(r)
plot.title('comportamento do campo')
plot.xlabel('raio da esfera')
plot.ylabel('campo eletrico')
plot(r,k(r))
the error that gives is:
File "<ipython-input-65-70ed324ef8d6>", line 1
k=((rho)/(E*r**2))*(-e**(-r)*r**(2)-2e**(-r)*r-2e**(-r)+2)
^
SyntaxError: invalid syntax
Classic error, Operator = XOR = Sets each bit to 1 if only one of two bits is 1, you are not working with bits, why are you using that operator? The error next is consequence of that there.
– FourZeroFive
Camila, your
e
is the Euler constant? and I think you should use the specific Plot of thesympy
to plot your graph, since the expression is analytical. otherwise, your expression is using the^
instead of the**
for power, then the correct expression would bek = (r/E*r**2)*-np.e**-r*r**2*-2*np.e**-r*r-2*np.e**-r+2
the graph will still have some problems to plot, but I can help you if you give more details of these variables– Giovana Morais
I solved an integral, po/Er 2 integral of r 2.e -r, then the result gave this expression I put, I wanted to plot her chart
– Camila Galvão
I edited the code for the modifications I made
– Camila Galvão