# Why I get the “Set::write: ”Tag Times in is Protected." error?

Why I get the error below with this code:

Needs["VectorAnalysis"]

ρ = 1000;
g = 9.80665;
μ = 0.001;
p[x_, y_, z_, t_] = {x^2, Sqrt[y], -z, t^3};
f[x_, y_, z_, t_] = {-x^2, Sqrt[y]/2, z, t^2};

ρ Dt[v, t] = -Gradient[p] + μ Laplacian[v] + f


## Error:

Set::write: "Tag Times in 1000\ Dt[v,t] is Protected."

-
Are you trying to solve the Navier Stokes's equation? IF so, you should look at NDSolve... If you are just trying to get rid of the error, switching = with == in the final line helps... check ref/character/Equal in Mathematica Help. – drN Oct 10 '12 at 19:36
– Mr.Wizard Feb 3 at 6:56

Any time you try to execute a command of the form a*b=c, you'll generate this error:

Of course, that's exactly what you've done in your last line:

ρ Dt[v, t] = -Gradient[p] + μ Laplacian[v] + f


We can see the issue more clearly if we examine the left side of the equation in FullForm

FullForm[a*b]
(* Out: Times[a,b] *)


Furthermore, Times is protected.

Attributes[Times]
(* Out: {Flat, Listable, NumericFunction, OneIdentity, Orderless, Protected} *)


Thus, you're trying to set the value of a protected symbol. As rm-rf points out, it's not just about removing the ρ, as otherwise you're trying to set the value of Dt.

Perhaps more to the point - if you want to represent an equation that you want to solve, you should type:

ρ Dt[v, t] == -Gradient[p] + μ Laplacian[v] + f


Note the double equals sign. This tests for equality, rather than setting a value - which is what you generally want when solving an equation.

-
Could you explain a bit more about the why? OP clearly has no clue why it happened, and if he merely takes this suggestion and removes the ρ to not make it of the form a*b=c, then he'll get a Tag Dt is Protected` error... back to square 1 :) – R. M. Oct 10 '12 at 19:49