Group Abstract Group Abstract

Message Boards Message Boards

Need help with general Wolfram Language syntax

Posted 1 year ago

Hi guys, in the attached code I'm having a lot of trouble figuring out the error "0.4 is not a valid variable". I also need further help if anyone is willing to assist. Thanks!

r[t_] := {Sin[5 t], t^4, Cos[5 t]} 
v[t_] := D[{Sin[5t],t^4, Cos[5t]}, t]
(*1a*)
ParametricPlot3D[r[t], {t, 0, 2 Pi/5}]
(*1b*)
unitVector = v[0.4]/Norm[v[0.4]]
(*1c*)
tangentLine[t_] := r[0] + unitVector[0.4]
(*integral as notated in the written homework*)
(*Integrate[((7t^5-2)^2+(3t^4+4)^2+(4t^3+3)^2)^(1/2),{t,0,5}]*)
POSTED BY: Rylan Kim
4 Replies
POSTED BY: Michael Rogers

Don't use delayed definition := when the rhs contains D or Integrate that need to act on a symbolic variable. Do immediate definition:

Clear[t];
v[t_] = D[Sin[t], t]
v[1]

compared with

Clear[v];
v[t_] := D[Sin[t], t]
v[1]

When you do delayed definition and call v[1], the variable t is replaced with 1 BEFORE the derivative is evaluated, resulting in D[Sin[1],1], which does not make sense.

An analogy: take the derivative d (x^2)/(d x) in Leibniz notation. You need the value for x=1. What you must not do is to replace x with 1 in the notation: d (1^2)/(d 1)

POSTED BY: Gianluca Gorni
Posted 1 year ago

You have

v[t_] := D[{Sin[5 t], t^4, Cos[5 t]}, t]

Then you have

unitVector = v[0.4]/Norm[v[0.4]]

So, the expression v[0.4] needs to be evaluated. The evaluation engine looks up definitions for v and finds v[t_] := D[{Sin[5 t], t^4, Cos[5 t]}, t], so it uses that definition by replacing t with 0.4. And since 0.4 isn't a valid symbol for the derivative, you get the error.

POSTED BY: Eric Rimbey
Posted 1 year ago

Is it possible that you previously assigned a value of 0.4 to t? If so that will be remembered in cache and that can cause the error message that you see. You can use things like Clear or ClearAll or Unset to get Mathematica to remove an item from cache. If this doesn't work then show what you have tried and what the result is and we can try to help you get this working.

POSTED BY: Bill Nelson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard