Semester II Reference Guide

Inputting Symbols

For most letters and symbols use: ‘esc’ letter ‘esc’ e.g.

∈(* 'esc' p 'esc'*)

π (* 'esc' p 'esc'*)

For mathematical symbols such as fractions use ‘ctrl’ + symbol, e.g.

(\[Placeholder]/\[Placeholder]) (*'ctrl' + '/'*)

(x^\[Placeholder]) (* 'ctrl' + '6' *)

Sum & Table

Sum

Sum[f[n],{n,min, max}]

Example

Sum[Cos[n*x],{n,1,5}]

Table

The Table command is very similar to the Sum command.

Table[f[n], {n,min,max}]

Example

Table[Cos[n*x],{n,1,5}]

Alternative form of Table

There is an alternative form of the Table command that will be used later in the course. It can either be entered as:

Table[f[n],{n,{(Subscript[n, 1]),(Subscript[n, 2]),(Subscript[n, 3])...(Subscript[n, k])}}]

or by defining a list of values

list={(Subscript[n, 1]),(Subscript[n, 2]),(Subscript[n, 3])...(Subscript[n, k])}

and then typing the code as follows:

Table[f[n],{n,list}]

Examples

Table[Cos[n*x],{n,{1,4,5,7}}]

list1={1,4,5,7}

Table[Cos[n*x],{n,list1}]

Piecewise Functions

A function of the form:  f(x)=({{{, ({{(Subscript[f, 1])(x), (Subscript[a, 1])<x<(Subscript[b, 1])}, {({{(Subscript[f, 2])(x)}, {(Subscript[f, 3])(x)}}), ({{(Subscript[a, 2])<x<(Subscript[b, 2])}, {otherwise}})}})}}) 
can be entered into Mathematica as follows:

Piecewise[{ {(Subscript[f, 1])[x], (Subscript[a, 1])<x<(Subscript[b, 1])},{ (Subscript[f, 2])[x], (Subscript[a, 2])<x<(Subscript[b, 2])} },(Subscript[f, 3])[x]]

Example

f1[x_]:=Piecewise[{{x^2,x<0},{x,0<x<1}},1]

Plot[f1[x],{x,-1.5,1.5}]

Simplify

The following command simplifies an expression:

Simplify[expression]

The following command simplifies an expression with the additional assumption that ‘n’ is an integer.

Simplify[expression, n ∈ Integers]

Be careful to type “Integers” correctly and not “Integer” or “integers”.

Examples

Simplify[(((((Sin[x]))^2)+(((Cos[x]))^2))/(Cot[x]))]

Simplify[Sin[2*π*n], n ∈ Integers]

ListPlot

ListPlot[listname]

Example

list2={1,4,7,8,5,4}

ListPlot[list2]

FindRoot

FindRoot[f[x],{x,guess}]

Example

Plot[(x^2)-1,{x,-2,2}]

FindRoot[(x^2)-1,{x,1.5}]

FindRoot[(x^2)-1,{x,-0.3}]

ReplaceAll

This command can be used to change an instruction of the form {x->3} into 3.

ReplaceAll[x,{x->value}]

Examples

The code can either be entered as:

ReplaceAll[x,{x->3}]

Or we can define the instruction separately as so:

list3={x->3}

ReplaceAll[x,list3]