0

So basically I have a system of linear equations for springs im trying to solve. stiffSpr is nonlinear and linSpr is linear. But it keeps telling me that its expecting an equation and not true. I can't figure out why.

stiffSpr[k_, a_, x0_] := {x''[t] + k*x[t] + b*Abs[x'[t]]*x'[t] == 0, x[0] == x0, x'[0] == 0}

linSpr[k_, b_, x0_] := {x''[t] + k*x[t] + b*x'[t] == 0, x[0] == x0, x'[0] == 0}

A1 = NDSolve[stiffSpr[2.7, 1.1, 2], x[t], {t, 0, 10}]

B1 = DSolve[linSpr[2.7, 1.1, 2], x[t], t]
march
  • 23,399
  • 2
  • 44
  • 100
  • NDSolve demands that all the variables except the ones being solved for have been assigned some numeric value. So doing something like b=3; or some other constant before your stiffSpr definition will make the error message go away. – Bill Nov 07 '18 at 05:43
  • 1
    This question is a combination of simple and common mistakes: 1. The a_ in stiffSpr should be b_; 2. One or more variables isn't cleared, Clear[x, Derivative] should resolve the problem, for more information check this post: https://mathematica.stackexchange.com/q/46214/1871 – xzczd Dec 07 '18 at 17:09

1 Answers1

0

Did you miss a space" "bewteen k and x[t] for example?

stiffSpr[k_, a_, x0_] := {x''[t] + k x[t] + a Abs[x'[t]]*x'[t] == 0, 
x[0] == x0, x'[0] == 0}
linSpr[k_, b_, x0_] := {x''[t] + k x[t] + b x'[t] == 0, x[0] == x0, 
x'[0] == 0}

A1 = NDSolve[stiffSpr[2.7, 1.1, 2], x[t], {t, 0, 10}]

B1 = DSolve[linSpr[2.7, 1.1, 2], x[t], t]

Then the output for B1 :

{{x[t] -> 2. E^(-0.55 t) (1. Cos[1.54839 t] + 0.355209 Sin[1.54839 t])}}
  • I tried it myself, and it didn't work, and then I even copied it from the website and pasted it in. It didn't work and gave me the same error as before. – Ossumdude Nov 07 '18 at 06:17
  • 2
    @Ossumdude Have you tried quitting the kernel and re-running? This sounds like you've got some lingering definitions that you need to clear. – march Nov 07 '18 at 06:26