# -*- coding: utf-8 -*-
import matplotlib.pyplot as plt
import numpy as np
import math
#task 2e
x = np.linspace(-0.0001,0.1,50)
#constants
e0=8.85*10 ** (-12)
r0=3 * 10 ** (-3)
Q=2 * 10** (-9)
Q2=10 * 10*(-9)
r2=5*10**(-3)
v=(Q/((4*math.pi*e0)*(math.sqrt((x**2+r0**2)))))
v2=v+(Q2/((4*math.pi*e0)*(math.sqrt(((x-2)**2+r2**2)))))
plt.plot(x, v)
plt.plot(x, v2)
plt.xlabel("Meter")
plt.ylabel("V1/2(x)")
Running this code gives the following TypeError:
TypeError: only length-1 arrays can be converted to Python scalars On 21 v=(Q/((4*math.pi*e0)(math.sqrt((x*2+r0**2)))))