0

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
asked Oct 21, 2019 at 5:19
1
  • I couldn't help noticing you broke the naming convention here. c5 and c6 should be named c11111 and c22222, respectively. Commented Oct 21, 2019 at 12:49

1 Answer 1

2

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
1
  • This has nothing to do with Raspberry Pi. Commented Oct 21, 2019 at 18:02

Your Answer

Draft saved
Draft discarded

Sign up or log in

Sign up using Google
Sign up using Email and Password

Post as a guest

Required, but never shown

Post as a guest

Required, but never shown

By clicking "Post Your Answer", you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.