0
$\begingroup$

This question already has an answer here:

Many times I have a Mathematica code like this

v[t_] = {Subscript[v, 1][t], Subscript[v, 2][t], Subscript[v, 3][t]}
B = {Subscript[b, 1], Subscript[b, 2], Subscript[b, 3]}
elc = {Subscript[e, 1], Subscript[e, 2], Subscript[e, 3]}
A = q/c {{0, Subscript[b, 3], -Subscript[b, 2]}, {-Subscript[b, 3], 0,
     Subscript[b, 1]}, {Subscript[b, 2], -Subscript[b, 1], 0}}

system = v'[t] == 1/m ( A.v[t]+q elc)
sol = DSolve[system, {Subscript[v, 1], Subscript[v, 2], Subscript[v, 3]}, t]

Note $q,c,B,elc.m$ are all constants (or their components are). I would like to know how to declare symbolic constants globally and locally (such as when solving a ode). As I would like to both be able to declare all my constants at once and locally. (I believe that the above linear ode system gives a very complex answer without declaring constants, if I am wrong please correct me and also answer my question).

$\endgroup$

marked as duplicate by Feyre, happy fish, MarcoB, m_goldberg, Community Nov 10 '16 at 17:04

This question has been asked before and already has an answer. If those answers do not fully address your question, please ask a new question.

  • 2
    $\begingroup$ All parameters you directly use in Mma are global and do not need any special declaration. To create local constants you may use scoping constructs, such as Block, Module and With. Have a look at the Help. $\endgroup$ – Alexei Boulbitch Nov 10 '16 at 8:12
  • $\begingroup$ @AlexeiBoulbitch Could you give some examples of how to use with. Looking at the documentation is what made me first ask the question. $\endgroup$ – AzJ Nov 10 '16 at 16:27
  • $\begingroup$ Agreed I will close this question $\endgroup$ – AzJ Nov 10 '16 at 17:04