1

enter image description here

Given this equation for deflection of a beam, I'm asked to plot it but I keep getting this error message:

Here is my code:

import math
import matplotlib.pyplot as plt
import scipy.constants
import numpy as np

p_l = 2.5
E = 50000
I = 30000
L = 600

fsy = 6
fsx = scipy.constants.golden

dx = 0.01
x_max = 100
x = np.arange(0.0, x_max + dx, dx)

v_x = ((p_l)/(E*I*L))*((-x**5)+(2(600**2)*(x**3))-(600**4)*x)

fig = plt.figure(figsize = (fsx, fsy))

plt.plot(x, v_x, color = 'k', linestyle = '-', linewidth = 2.0, marker = '.')

plt.title("Plot of v(x)", fontsize=15)
plt.xlabel(" ($s$)")
plt.ylabel("$y$ ($m$)")
plt.ylim(-105, 105)
plt.legend()
plt.show()

and here is the error message i keep getting:

TypeError                                 Traceback (most recent call last)
<ipython-input-37-4d6b17714a72> in <module>
     18 x = np.arange(0.0, x_max + dx, dx)
     19 
---> 20 v = ((p_l)/(E*I*L))*((-x**5)+(2(600**2)*(x**3))-(600**4)*x)
     21 
     22 fig = plt.figure(figsize = (fsx, fsy))

TypeError: 'int' object is not callable

Please help if you can! Much appreciated

aminography
  • 21,986
  • 13
  • 70
  • 74
  • 1
    Check your brackets - `2(600**2)` is not valid. You likely want `2 * (600 ** 2)` instead. – dspencer Apr 10 '20 at 04:20
  • Does this answer your question? [Why do I keep getting: 'int' object is not callable in Python?](https://stackoverflow.com/questions/27239898/why-do-i-keep-getting-int-object-is-not-callable-in-python). See also https://stackoverflow.com/questions/9767391/typeerror-int-object-is-not-callable. – dspencer Apr 10 '20 at 04:35
  • take a look at here [https://www.w3schools.com/python/] – Nafiseh Daneshian Apr 10 '20 at 12:56

1 Answers1

0

In Python, you need to add the * symbol when doing multiplication. Add that in between the 2 and 600**2. Like shown below!

(2*(600**2)

v_x = ((p_l)/(E*I*L))*((-x**5)+(2*(600**2)*(x**3))-(600**4)*x)

Christopher Moore
  • 15,626
  • 10
  • 42
  • 52