MAT 370: Introduction and What to Expect

Dr. Gilbert

December 24, 2025

What Are We Here For?



▶ Video excerpted from Dr. Jeffrey Chasnov’s Numerical Methods for Engineers playlist on YouTube.

Contexts We’ll Encounter

What Are We Here For?

What Are We Here For?

What Are We Here For?

What Are We Here For?

What Are We Here For?

What Are We Here For?

Syllabus

Major Highlights from the Syllabus: I’ll ask you to read the syllabus, but the most important items are on the following slides.

Instructor and Office Hours

  • Instructor: Dr. Adam Gilbert

    • e-mail address: a.gilbert1@snhu.edu

    • Office: Robert Frost Hall, Room 311

    • Office Hours (please visit!):

      • Wednesdays 1:00pm - 2:00pm
      • Thursdays 9:00am - 11:00am
      • Fridays 9:00am - 11:00am
    • Slack for communication – see the Welcome Announcement on BrightSpace for how to join

Required Resources

  • Main Textbook: We are following Numerical Methods for Engineering with Python 3 by Jaan Kiusalaas

  • Python via Google Colab or a local Python installation is required (Colab recommended)

    • Note, I’ll assume you’ve never seen Python before and that you haven’t even written a single line of code. We’ll start from the ground (today!).
    • You’ll also use \(\LaTeX\) inside of the Colab environemtn for typesetting mathematics, but I’ll give you a primer in that as well.

Grading Scheme

Grade Item Value
Participation 5%
Homework (~8) 40%
Unit Problem Sets / Exams (2) 30%
Final Project and Reflection 15%
Debrief Interviews 10%

Explanations of Grade Items

  • Participation: Your collaboration in developing and implementing routines for solving problems is critical to our success in this course. You’ll earn credit for that work.

  • Homework: We’ll develop our routines in class together and you’ll apply those routines to solving problems on homework assignments.

  • Unit Problem Sets: We will have two (2) unit problem sets (or exams) during our semester.

    • These will stay unit problem sets unless unauthorized collaboration with AI, websites, or people becomes a problem.
  • Final Project and Reflection: In the final weeks of the semester, you’ll complete a short project that combines reflection and application. You’ll choose a numerical method we’ve studied and apply it to a meaningful problem in a domain you care about, resulting in a short paper and five slides.

  • Debrief Interviews: In the final two weeks of the semester, you’ll meet briefly with me to talk through a few problems and ideas from the course, explaining what you’ve learned in your own words. This conversation is an important part of your course assessment and focuses on understanding rather than memorization.

Brightspace

  • Announcements
  • Assignment Submissions
  • Gradebook
  • Go to the webpage for everything else

Course Webpage

I’ve built a webpage to organize our course content.

  • Syllabus

  • Tentative timeline

    • Links to notes (in Jupyter/Colab notebook format)
    • Links to class discussion companion slides in both slide and pdf formats
    • Assignment reminders

What’s Class Like?

  • Some lecture is going to be necessary here, but I hope it is collaborative

  • I have nearly complete sets of notes for you

    • The Python routines we need to build are scaffolded, with blanks for us to fill in
  • Generally, we’ll spend class time slowly solving one problem, identifying the steps required to solve problems of that type, and then writing Python code to implement the solution strategy.

  • You’ll use the functionality we develop in class on homework assignments and unit problem sets.

A Note on Approach to Class

  • I’m open to change in all of my courses.
  • If the structure isn’t working for you, let’s chat and see what changes we can make to improve your experience.
  • If you don’t want to tell me in person, leave an anonymous note under my office door.

My goal in this course is for all of you to learn as much about numerical methods as possible – we can’t achieve that if you don’t feel like you are benefiting from our class meetings.

A Note on AI Use

  • Large language models like ChatGPT, Copilot, and friends are powerful and valuable tools for increasing productivity.

  • The production you are seeking here, in coursework, is learning though – not simply churning out correct answers

  • American science fiction writer Ted Chiang says that “Using ChatGPT to complete assignments is like bringing a forklift into the weight room; you’ll never improve your cognitive fitness that way.”

    • You’ll churn out content but, within 5 minutes of speaking with someone, it will be obvious that you don’t have an actual foundation.
  • Andrew Heiss has published some thoughts about AI use, and I agree with much of what he’s said.

  • In this course, please stick to using AI for (i) troubleshooting broken python code or (ii) helping you with \(\LaTeX\).

    • You should be first-author on everything you write – code or otherwise. Please do not ask the AI to write or solve anything for you.

Let’s Get Our Hands Dirty!

Reminder: Complete the Week 1 Assignment on BrightSpace before the end of the day on Sunday!



Open our Day 1 Notebook and let’s get started.

Jupyter Notebooks via Google Colab

  • Jupyter notebooks allow mixtures of executable Python code along with formatted text.

  • In Google Colab, there is support for “click-button” formatting.

  • The environment supports markdown syntax for formatting as well.

  • These notebooks consist of two types of cells – text/markdown or code cells

    • By default, text cells are over a white background and code cells are over a grey-ish background.
    • This may differ depending on your web-browser’s settings.

Text/Markdown Cells

  • Double-click into an existing text cell to edit it.
  • Type freely, using markdown or the formatting buttons to format text as you like.
  • To split text across separate paragraphs, leave a blank line between the paragraphs in the text cell.
  • A preview of the rendered text will appear to the right of the cell editor.
  • To fully render the cell, hold down Shift and hit Enter (or Return)
  • To create a new text cell, hover your mouse between existing cells (or just beyond the last cell in the notebook) and click the + Text button to add a text cell.

Code Cells

  • Code cells must consist of valid Python code or comments.

    • Anything beyond a hashtag (#) on a line will be ignored as a comment.
    • You may start a line with a hashtag and that entire line will be interpreted as a comment.
    • You can include multi-line comments by using triple-quotes (""") in the line before the comment and the line after the comment.
  • Execute a code cell by holding down Shift and hitting Enter (or Return)

Basic Python: Python as a Calculator

At its most basic level, Python can function as a calculator. There are a few things to remember:

  • Parentheses – ( and ) – can be used for grouping operations, but other types of brackets cannot be used since they are special characters.
  • Multiplication must be explicitly defined with the use of the asterisk (*).
5*(6 + 3)
45
5(6 + 3)
TypeError: 'int' object is not callable
  • Exponentiation is signified by a double asterisk (**)
4**2
16
4^2
6

Displaying Output

  • By default, in a Jupyter notebook environment only the result of the last line of code will be printed.
  • Explicitly use print() if you want to see multiple lines of output.
print(5*(6 + 3))
print(4**2)
45
16

Variable Assignment

  • Variable assignment in Python is done via the equal sign (=) operator.
  • Data types are inferred, so there is no need to declare the type for a variable before using it.
x = 2.0
3*x + x**2 - 19
-9.0
y = "Hello"
z = "Friends"

y + " " + z
'Hello Friends'

Variable Naming Requirements and Conventions

Variable names cannot begin with a number or contain spaces

Beyond this, Python will essentially let you do whatever you want. There are some additional rules you should strive to follow to make your own life easier:

  • Do not use keywords as names for your variables.

    • Don’t let int = 34 – instead, use my_int = 34.
  • Do use meaningful names for your variables.

    • Don’t let xxyy = 17 – instead, use initial_guess = 17.
  • Do Be consistent with your naming conventions.

    • Don’t let my_int = 34 and then use initialGuess = 17 – commit to using camelCase or snake_case, but try not to mix the two.
  • Do use meaningful but concise names.

    • Don’t let initial_guess_for_minimum_over_the_closed_interval = 17 – just let initial_guess = 17 or initial_guess_minimum = 17.

A First Data Structure: Lists

  • Python lists are sometimes convenient objects to work with.

    • We’ll find direct and intermediary uses for them from time to time.
  • Lists are defined using square brackets, as seen below.

myList = [1, 4, 9, 16, 25]
myList2 = [350, 370, 400]
print(myList)
[1, 4, 9, 16, 25]
print(myList2)
[350, 370, 400]
  • Lists don’t exactly work how you might want them to though (at least not in a math context).
print(myList + myList2)
[1, 4, 9, 16, 25, 350, 370, 400]

Working with Lists

print(myList)
[1, 4, 9, 16, 25]

We can access particular list elements using square brackets.

We just need to remember two things when doing so:

  • Python starts counting from \(0\)
myList[2]
9
  • Python is right-endpoint exclusive
myList[1:4]
[4, 9, 16]

Editing Lists

print(myList)
[1, 4, 9, 16, 25]
  • One reason that lists are so convenient to work with is that it is easy to extend them.
  • For example, we can add the next perfect square to myList by using the append() method.
myList.append(49)
print(myList)
[1, 4, 9, 16, 25, 49]
  • We can also change the value of a list entry by accessing its position with square brackets and reassigning it.
myList[5] = 36
print(myList)
[1, 4, 9, 16, 25, 36]

A Warning: Test Everything

Not everything works the way you would expect it to…

print(myList)
[1, 4, 9, 16, 25, 36]
myNewList = myList

print(myNewList)
[1, 4, 9, 16, 25, 36]
myNewList[1] = 100

print(myNewList)
[1, 100, 9, 16, 25, 36]
print(myList)
[1, 100, 9, 16, 25, 36]
myNewList_copy = myNewList.copy()
myNewList_copy[1] = 4

print(myNewList)
[1, 100, 9, 16, 25, 36]
print(myNewList_copy)
[1, 4, 9, 16, 25, 36]

Sometimes behaviors are unexpected, like overwriting the entry of myList in index 1 resulting in the same change in myNewList.

There are always reasons for this…For example, when we assigned myNewList = myList, Python saves space by just having both objects reference the same location in memory.

Requesting a true copy of the object with .copy() was the appropriate thing to do, but such a thing is not obviously required.

Always check your work.

Arrays and {numpy}

We won’t actually use lists very often in our course

We’re much more interested in special structures, like arrays (think: vectors or matrices)

We can import the {numpy} module and use it to create these special structures

import numpy as np

Note. We used the alias np so that we can type np.function_name() instead of numpy.function_name() when we want to use functionality from this module. Doing this is common in Python.

Now we can use np.array() with lists to define our structures.

myVector = np.array([1, 2, 3])
myMatrix = np.array([
  [4, 5], #row 1
  [6, 7], #row 2
  [8, 9]  #row 3
])

print("My vector is: ", myVector)
print("My matrix is: ", myMatrix)
My vector is:  [1 2 3]
My matrix is:  [[4 5]
 [6 7]
 [8 9]]

Arithmetic with {numpy} Arrays

Arithmetic on arrays works the way you would want it to work, mathematically.

myVec_v1 = np.array([1, 2, 3])
myVec_v2 = np.array([4, 5, 6])

print(myVec_v1 + myVec_v2)
[5 7 9]
myMatrix_A = np.array([
  [4, 5],
  [6, 7],
  [8, 9]
  ])

print(5*myMatrix_A)
[[20 25]
 [30 35]
 [40 45]]

Developers also build in some conveniences which aren’t mathematically meaningful, but are colloquially understandable and useful!

myVec_v3 = myVec_v1 + 7

print(myVec_v3)
[ 8  9 10]

Programming Paradigm: Loops

Computers are excellent at following instructions and performing tedious tasks.

It is often the case where we’ll want to perform the same set of instructions over and over again.

If we find ourselves in this situation, loops will be helpful.

We’ll encounter two types of loop in our course.

  • A for loop is useful when we know ahead of time how many iterations our instructions must be run for.

  • A while loop can be used when we would like to run a set of instructions over and over again until a condition is no longer satisfied.

    • Be careful with these while loops though – using the wrong stopping condition can lead to infinite loops or unnecessarily lengthy procedures.

Programming Paradigm: Loops

  • A for loop is useful when we know ahead of time how many iterations our instructions must be run for.

  • A while loop can be used when we would like to run a set of instructions over and over again until a condition is no longer satisfied.

    • Be careful with these while loops though – using the wrong stopping condition can lead to infinite loops or unnecessarily lengthy procedures.
#A for loop
my_sum = 0
for i in range(6):
  my_sum = my_sum + i
  print("i is ", i, " and my_sum is ", my_sum)


print("The total sum is: ", my_sum)
i is  0  and my_sum is  0
i is  1  and my_sum is  1
i is  2  and my_sum is  3
i is  3  and my_sum is  6
i is  4  and my_sum is  10
i is  5  and my_sum is  15
The total sum is:  15

Programming Paradigm: Loops

  • A for loop is useful when we know ahead of time how many iterations our instructions must be run for.

  • A while loop can be used when we would like to run a set of instructions over and over again until a condition is no longer satisfied.

    • Be careful with these while loops though – using the wrong stopping condition can lead to infinite loops or unnecessarily lengthy procedures.
#A while loop
x = 1
while x <= 100:
  x = 2*x
  print(x)

print("The final value of x is: ", x)
2
4
8
16
32
64
128
The final value of x is:  128

Programming Paradigm: Conditional Statements

Another useful way to control your code is with the use of conditional statements.

This allows for code to be executed if a condition is true, and perhaps other (or no) code to be executed if it is false.

We use if, elif, and else statements for this.

For example, look at the following for loop which will print out values of x between \(0\) and \(100\) which are divisible by \(13\).

x = 0

for x in range(101):
  if x % 13 == 0:
    print(x)
0
13
26
39
52
65
78
91

Programming Paradigm: Functions

It will often be the case that we’d like to write functions in our course.

Functions begin with the def keyword and end with a return statement.

Consider the following silly function which multiplies two numbers together.

def product(a, b):
  #Function instructions
  myProduct = a*b
  
  #What the function results in
  return myProduct

Now that the product() function has been defined, we can use it!

product(3, 6)
18

Below is a perhaps more useful application.

def f(x):
  #my_output = -3*(x**2) -5*x + 8
  term1 = -3*x**2
  term2 = -5*x
  my_output = term1 + term2 + 8
  return my_output
f(4)
-60

Summary and a Motivating Example

  • In this notebook, you learned some basics about Python and the Jupyter Notebook environment.
  • I expect (and you should, too) that you’ll come back here often over the next couple of weeks as you continue to gain familiarity with Python.
  • In particular, you should feel free to copy/paste/edit from this notebook, especially when you are constructing functions and/or loops.

We’ll leave this notebook with a simple example which will motivate our study for the remainder of the semester.

In Python, and in many computing languages, we can use a double equal (==) operator to test equality. We can also use the usual inequalities to test sizes of numbers.

print(7 >= 3)
print(3.5 < 3)
print(5 == 3 + 2)
True
False
True

Just once more, for good measure…

print(0.1 + 0.2 == 0.3)
False

…and everything had been going so well – we’ll investigate this next time!