Hands-on Start to Mathematica

Basic Input

10!

717/3

718/3

718.0/3

N[718/3]

N[718/3,5]

a=5

3a+1

b=7

3b+1

Clear[a,b]

Expand[(a+5)(a+9)]

Algebra Examples

Solve[2x-7==0,x]

3x+5

NSolve[2x-7==0,x]

Solve[{2x-7==0,3x-2y==0},{x,y}]

Solve[a*x^2+b*x+c==0,x]

Solve[a (x^2)+b x+c==0,x]

Graphics examples

Below, you will see some examples of making graphics in Mathematica:

Plot[2x-7,{x,-10,10}]

Plot[Sin[x]/x,{x,-Pi,Pi}]

Plot[((Sin[x])/x),{x,-π,π}]

Plot3D[Sin[x y],{x,-3,3},{y,-3,3}]

Table[(i^2),{i,1,5}]

Total[%]

Mean[%28]

ListPlot[Table[(i^2),{i,1,5}]]

data1=Table[(i^2),{i,1,10}];

ListPlot[data1]

Integrate[Sin[x],x]

∫Sin[x]\[DifferentialD]x

mat1={{1,3,-2},{2,5,0},{-3,-5,7}};

Det[mat1]

Clear[mat1]

Rules of the Wolfram Language

1. capital letter to start all function names
2. function arguments are enclosed by square brackets [ ]
3. lists (or ranges or domains) are enclosed by curly braces { }
4. shift-return to do the calculation

Plot[((Sin[x])/x),{x,-10,10}]

Suggestions Bar
After doing a computation, the suggestion bar will suggest other computations you may want to do with the output.  At the end of this, you could then “roll-up” to look at this as a daisy-chained operation (which was done below).

(x^2)-10

N[Solve[Factor[∫((x^2)-10)\[DifferentialD]x]==0,x]]

Compound Expressions

h=20-18+12
(2^h)+(3^h)

j=20+18-12;(2^j)+(3^j)

Defining Functions

f[x_]:=(x^2)

f[2]

f[π]

f[1.2345]

f[{1,2,3,4,5}]

g[x_,y_]:=(x^y)

g[10,10]

Working with units

10 (m/s)* 5 s

LinguisticAssistant+LinguisticAssistant

N[%]

Quantity[2,"Feet"]+Quantity[3,"Meters"]

Quantity[5,"Miles"]+Quantity[3,"Kilometers"]

N[%]

UnitConvert[%,"Feet"]

UnitConvert[Quantity[36242.51968503938`,"Feet"],"miles"]

Creating Interactive Models

Plot[Sin[x],{x,0,2π}]

Manipulate[Plot[Sin[k x],{x,0,2π}],{k,1,5}]

Manipulate[Plot[Sin[k x+ϕ],{x,0,2π}],{k,1,5},{ϕ,1,10}]

Manipulate[Plot[function[k x+ϕ],{x,0,2π}],{k,1,5},{ϕ,1,10},{function,{Sin,Cos,Tan}}]

Manipulate[Plot[function[k x+ϕ],{x,0,2π}],{k,1,5},{ϕ,1,10},{function,{Sin,Cos,Tan,Sec,Csc,Cot}}]

Manipulate[Expand[(((y+z))^n)],{n,2,100,1}]

Options[Plot]

Manipulate[Plot[amplitude Sin[k x],{x,0,2π},PlotRange->{-10,10}],{k,1,5},{amplitude,1,10}]

Working with Data

$ImportFormats

Import["ExampleData/numberdata.csv"]

Import["ExampleData/spikey.dxf"]

data2=Import["ExampleData/population.xls",{"Data",1}]

Dimensions[data2]

data3=Import["ExampleData/USConstitution.txt"];

Dimensions[data3]

data3=Import["ExampleData/USConstitution.txt","Data"];

Dimensions[Data3]

data4=Import["ExampleData/ocelot.jpg"]

ImageReflect[data4,Left]

Blur[%104,9.3]

data5=Import["https://www.handsonstart.com/ExampleDataScores.txt"]

Dimensions[data5]

data5=Import["https://www.handsonstart.com/ExampleDataScores.txt","Data"]

Dimensions[data5]

Part[data5,1]

data5[[1]]

data5[[1,3]]

data5[[3,All]]

data5[[All,3]]

Mean[%]

N[%]

data6=Import["ExampleData/50states.txt","Data"];

data6[[1]]

First[data6]

data7=SemanticImport["ExampleData/50states.txt"];
First[data7]

AdministrativeDivisionData[(Entity["Alabama, United States", Entity["AdministrativeDivision",{"Alabama","UnitedStates"}], "Entity[\"AdministrativeDivision\", {\"Alabama\", \"UnitedStates\"}]", "administrative division"]),"Population"]

Help Documentation