0
$\begingroup$

I am new to mathematica and I am having this issue in this piece of code.

x=0.1Sin[[Pi]/8t+[Pi]/4] (* this is my original function*)
v=D[x,t] (* took the 1st derivative and got 0.0392699Cos[pi/4+pi/8t)

Once I got the expression for the 1st derivative, I solved for the equation and got (-6,2) as a solution. The problem starts when I take derivative of v to get an expression for acceleration. a=D[v,t] The above code gives me -6 is not valid variable error. Any kind of help would be greatly appreciated. FWIW,I am doing this in mathematica online.

$\endgroup$
0

1 Answer 1

2
$\begingroup$

Here is one way to be explicit about what is a variable and what is a function:

Clear[x,v]
x[t_] := 0.1 Sin[Pi/8 t + Pi/4];
v[t_] = D[x[t], t]

Now you can get the acceleration by:

D[v[t], t]
$\endgroup$
5
  • $\begingroup$ thank you for the reply. took your advice and defined my functions, everything was good up until acceleration. It either gives me 0 or some kind of pattern error. Is there something I am missing? $\endgroup$ Sep 6, 2018 at 17:23
  • $\begingroup$ When I type D[v[t], t], I get -0.0154213 Sin[[Pi]/4 + ([Pi] t)/8]. If you are getting something different, restart the kernel (Evaluation->Quit Kernel->Local). $\endgroup$
    – bill s
    Sep 6, 2018 at 17:46
  • $\begingroup$ this is a little strange. I can reproduce the solution whenever I skip using the print function for the two solution I got. When I use the print function, Print["(c)solution=", {t = -6, 2} "s"]; as soon as I add the print function I get the error message. Is there a better way to print the two solutions? $\endgroup$ Sep 7, 2018 at 13:55
  • $\begingroup$ I guess you must be using Print incorrectly. But why Print anything? Why not just look at or list the values you want? $\endgroup$
    – bill s
    Sep 7, 2018 at 14:17
  • $\begingroup$ because the prof. wants us to use the Print function to display our answers. This seems to be working for now, print["(c) Solution= ", Solution]. Thank you for all your help. $\endgroup$ Sep 7, 2018 at 14:32

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge that you have read and understand our privacy policy and code of conduct.

Not the answer you're looking for? Browse other questions tagged or ask your own question.