Larger Calculations

Once we are comfortable with the basic calculator syntax, we can use computers for calculations.

Computers allow much more power, speed, and scope than our calculators.

Computing platforms

  • You are likely most familiar with a calculator

  • You enter a series of commands

  • When you press enter or equals, they are sent to a small computer for evaluation

  • The results are printed for you

  • There are many computer programs that do similar things and allow much more power and flexibility

  • Other platforms are Mathematica and spreadsheets

Computing languages

  • Computing languages allow us to instruct the computer to do things

  • As our models and computations become more complex, we will want to do things besides addition and multiplication

  • Using a computing program (Excel) or language (Python) helps us achieve that

Types

The computer uses ones and zeros to represent all data. Anything stored on the computer, a poem, a photo, or a number, is represented using ones and zeros. In order to correctly interpret the ones and zeros the computer needs to know what you are storing.

Integers

These are the counting numbers. No fractions, no decimals.

Floats

These are numbers with a fractional part.

Floating Point Example Link

Strings

This is how the computer stores words.

ASCII Example Link

Variables

To make the details of a computation more clear, we can use readable names for our numbers and then use the names in the calculation.

This makes it possible to more easily communicate the details of our calculation to others.

power = 100
time = 30
energy = power * time

This makes the intention of the calculation more clear to the reader.

In our language (python) the computer decides how to interpret each variable by what you put inside it.

Functions

You have often used functions on your calculator and you have encountered the idea in your math classes.

A function takes a number or numbers as an input and provides a number or numbers as an output.

You have probably used sine or cosine functions on your calculator.

You may want to make your own function for a calculation that you do frequently. The syntax for this often varies but the idea is usually the same.

m = 1
b = 10
f(x) = m * x + b
f(5) => 15

LaTeX

  • This is a word processor especially for math

  • By placing dollar signs ($) around some text, it is sent to LaTeX to be interpreted

  • You can use this to write fractions and many other mathematical symbols

  • You can find some symbols at this link

For example

\frac{1}{2}

will turn into

12\frac{1}{2}

Last updated