If you're really used to traditional math notation, you can also enter and evaluate your derivatives and integrals in TraditionalForm
. I'll illustrate this without assuming any special stylesheet settings, starting from a default notebook (this is the version 8 default, not version 9 which I dislike). It's a step-by step walkthrough, so I'll use screen shots and menu commands instead of keyboard shortcuts (the latter make it much more streamlined but harder to explain):
Let's say you want to know the derivative of $\cos(x)$.
- Start a new numbered display equation (
Format > Style > DisplayFormulaNumbered
)
- Convert the cell to
TraditionalForm
(Cell > Convert To > TraditionalForm
)
- The
Null
can be highlighted and overwritten with our intended derivative, using Escpd
Esc for the $\partial$ symbol, and the traditional notation for $\sin(x)$ with lower case and round parentheses:
- Make a fraction by highlighting the numerator and pressing Ctrl-
/
, followed by the denominator:
- Now to evaluate this completely traditional looking input, highlight it and select the menu item
Evaluation > Evaluate in Place
:
Similarly, you can enter integrals by doing this:
where I entered the differential as Escdd
Esc and the integral as Escint
Esc.
Some people prefer to set up style sheets in which the TraditionalForm
setting for displayed equations is already pre-defined, but I wanted to use the bare-bones starting point.
Edit: Programming with TraditionalForm
While I'm discussing "natural" math input, it may be worth mentioning that you can combine the above formatting with standard input format, too.
Usually, the following won't work at all:
However, if I input the function body in a TraditionalForm
equation as shown above and then copy it into the function, it gets wrapped by a FormBox
which is invisible but makes the following evaluatable:
OK, with the mix of brackets, this looks very wrong from a programming perspective, but I could imagine situations where this is preferable because of its "natural" readability. Here is the proof that it works:
dOperator[Sin[x]]
(* ==> Cos[x] Sin[x] *)
To create a FormBox
in an Input
cell to allow you to enter TraditionalForm
math, a quick way is to type a single letter, highlight it and press Shift-Cmd-T
. Then replace the letter with the desired formula.
esc
-dd
-esc
x
for the infinitesimal $d x$. For simple derivatives, use'
. For example:Sin'[x]
. However, I would strongly urge you to not use such typesetting shortcuts for programming purposes. They're ok for text/taking notes, etc., but I don't think it improves your speed of programming or ease of understanding the code. It certainly does make bugs and misplaced boxes hard to find/fix... $\endgroup$