When setting variable c1, it shows invalid syntax error on c1
def project(k, n):
h = 200
L = 18
M = 70
da = 8
xo = h - L
g = 9.81
V0 = m.sqrt(2 * g * L)
W = M * g
xss = -(W / k) + h - L
wn = m.sqrt(k / M)
dc = 2 * m.sqrt(k * M)
c = (k * n) / wn
ctotal = c + da
dr = ctotal / dc
wd = wn * m.sqrt(1 - dr**2)
Td = (2 * m.pi / (wn * m.sqrt(1 - dr**2))
c1 = xo - xss
c2 = (V0 + dr * wn * (xo - xss)) / wd
c11 = - dr * wn * c1 + c2 * wd
c22 = - dr * wn * c2 - c1 * wd
c111 = - dr * wn * c11 + c22 * wd
c222 = - dr * wn * c22 - c11 * wd
c1111 = - dr * wn * c111 + c222 * wd
c2222 = - dr * wn * c222 - c111 * wd
c5 = - dr * wn * c1111 + c2222 * wd
c6 = - dr * wn * c2222 - c1111 * wd
xRoot = Newton(Td / 4, Td / 2, velo, acc, 1.0e-9, dr, wn, t, c11, c22, wd, c111, c222)
maxX = deflect(dr, wn, xRoot, c1, c2, wd) + Xss
vRoot = Newton(0, Td / 8, acc, DAcc, 1.0e-9, dr, wn, t, c111, c222, wd, c1111, c2222)
maxV = velo(dr, wn, vRoot, c11, c22, wd)
aRoot = Newton(Td / 4, Td / 2, DAcc, D2Acc, 1.0e-9, dr, wn, t, c1111, c2222, wd, c5, c6)
maxA = acc(dr, wn, aRoot, c111, c222, wd)
return xRoot, maxX, vRoot, maxV, aRoot, maxA
Dougie
5,38111 gold badges22 silver badges30 bronze badges
1 Answer 1
When a syntax error is reported, sometime the problem is in the line before.
Td = (2 * m.pi / (wn * m.sqrt(1 - dr**2))
c1 = xo - xss
Look a the first line, there is a missing closing bracket, or alternatively the first opening bracket is unnecessary.
answered Oct 21, 2019 at 5:48
-
This has nothing to do with Raspberry Pi.Ingo– Ingo2019年10月21日 18:02:00 +00:00Commented Oct 21, 2019 at 18:02
lang-py
c5
andc6
should be namedc11111
andc22222
, respectively.