6
$\begingroup$

Sometimes I want to ask mathematica to plot or calculate something without given a certain value for it ..

For example I may want to ask mathematica to integrate $\int{a x} \mathrm{d}x$! How to tell him that $a$ is a constant?

$\endgroup$
13
$\begingroup$

If you don't specify any information about $a$, Mathematica automatically treats it as a constant, this is the default behaviour. For example, if you input "Integrate[$a$ $x$,$x$]", the output will be $a x^2/2$ as expected. Do not forget that in Mathematica, multiplication is a space, so you need to put a space between $a$ and $x$ for the command I gave to work (otherwise it will treat $ax$ as a single variable).

| cite | improve this answer | |
$\endgroup$
5
$\begingroup$

The previous answers provide enough context I believe. It is sometimes also useful to give mathematica information about the type of constants (if it's a real or imaginary number for example). This can be done using the option Assumptions. E.g. Integrate[Exp[a x],{x,0,Infinity},Assumptions->{a<0}]

| cite | improve this answer | |
$\endgroup$
2
$\begingroup$

Shortest through an example:

Dt[a x^2 + b, x, Constants -> {a}]

lets mathematica know that a is a constant here.

| cite | improve this answer | |
$\endgroup$
0
$\begingroup$

The define operator:

a:=7
D[a*t,t]
Precision[a]
b:=7.0
D[b*t,t]
Precision[b]
Out[9]= 7
Out[10]= \[Infinity]
Out[12]= 7.
Out[13]= MachinePrecision

Note that the decimal makes the number a literal while just the number is "infinitely" (symbolically) precise.

| cite | improve this answer | |
$\endgroup$
  • 1
    $\begingroup$ I don't want to give mathematica a value for $a$ .. Just to tell it that it is a constant $\endgroup$ – Osama Gamal Jun 27 '11 at 21:22

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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