Mathematical Applications · BE5B15MAA · Topic 7 of 13
Introduction into Wolfram Mathematica: basic syntax, help, variables, complex numbers, basic plotting
Week 7. Everything in Mathematica is an expression with a head; exact input stays exact, a decimal point makes it approximate.
Key ideas
Expressions and heads
Every object has a head: Head[1] is Integer, Head[1.0] is Real, Head[1/5] is Rational, Head[1+2I] is Complex and Head[f[x]] is f. FullForm shows the structure, for instance x^2+x+10==0 is Equal[Plus[10,x,Power[x,2]],0]. Shift+Enter evaluates a cell, and ClearAll removes the values given to symbols.
Exact and approximate results
Sin[5] stays symbolic while Sin[5.] gives −0.958924; 1/7+2/13 is 27/91 and N[Pi,100] asks for 100 digits. Solve returns exact solutions, for example {x→63/13, y→−2/13}, and cannot solve Cos[x]==x; FindRoot[Cos[x]==x,{x,0}] finds it numerically.
Lists, Part and plots
A list is the basic data structure. list[[k]] picks element k, a negative k counts from the end, list[[a;;b]] takes a range and element 0 of an expression is its head. Plot[f,{x,a,b}] draws functions and accepts options such as PlotStyle and AxesLabel; ListPlot of one-dimensional data uses the index as x, so give pairs {x,y} instead.
In one line: Mathematica evaluates what the kernel sees, not what the notebook shows: look at the head and the FullForm.
Sources
Written by Ucenly. Based on the BE5B15MAA course materials:
- Course card BE5B15MAA (Bílá kniha), p. 1
- Introduction to Wolfram Mathematica (Intro_Wm.nb inside Intro_WM.rar), text extract, p. 1
- Seminar 1 notebook, 21 Feb 2019 (seminar1_21_02_19.nb), text extract, p. 1
- Seminar notebook, state of 28 Mar 2019 (seminar2832019.nb), text extract, p. 1