Hello,
I'm trying to plot this function with using this values:

``````Rh = 9.8
H0 = 0.063

def Thickness_H(H0, r, Rh):
return float(H0)*np.exp(float(r)/float(Rh))

r = np.linspace(0,1, 10)
x =Thickness_H(H0, r, Rh)
plt.plot(r, x)
plt.show()
``````

I'm trying to defind r like what i know but this dose not work, I'm getting this error:
only length-1 arrays can be converted to Python scalars.

Thank you

Try to remove all the calls to `float()`. They are not necessary, and numpy uses its own float type.

I don't understand your question. If you write `return H0*np.exp(r/Rh)`, the code works and draws a curve, which is almost a straight line (I suppose it is because `1/Rh` is small).

Yes but when `u` is close enough to 0, exp(u) is close to `1 + u`.

## All 6 Replies

Try to remove all the calls to `float()`. They are not necessary, and numpy uses its own float type.

Okay, what about the plot how can I defined r

I don't understand your question. If you write `return H0*np.exp(r/Rh)`, the code works and draws a curve, which is almost a straight line (I suppose it is because `1/Rh` is small).

I want to plot this function

H0*np.exp(r/Rh)
I definded it, then I want to plot it, r is different values ? yes you are right I will get exponential curve?

Yes but when `u` is close enough to 0, exp(u) is close to `1 + u`.

Thank you very much