Skip to main content

Introduction to Jupyter Notebooks and Least Squares Fitting

Learn how to use Jupyter Notebooks for computational science and engineering, and apply the method of least squares to fit experimental data to a physical model.

Save this reading to your study set

Sign up free

In modern computational science and engineering, the ability to combine executable code, mathematical equations, and explanatory text in a single document is invaluable. This article introduces you to the Jupyter Notebook environment—a standard tool in the Python ecosystem—and demonstrates how to apply the mathematical method of least squares to fit a physical model to experimental data.

Getting Started with Jupyter

To begin working with computational models, you first need a robust environment. While there are many ways to install Python, the Anaconda Distribution is a highly recommended method for students and researchers. Anaconda provides a comprehensive suite of packages and includes the Anaconda Navigator, a graphical interface that allows you to launch applications like Jupyter Notebook with a single click.

Once launched, Jupyter Notebook opens in your web browser, providing an interactive interface where you can write code, view outputs, and document your thought process simultaneously.

This illustration shows the steps to download, install, and launch the Jupyter Notebook using Anaconda Distribution.
This illustration shows the steps to download, install, and launch the Jupyter Notebook using Anaconda Distribution.

The Building Blocks: Cells, Kernels, and Markdown

A Jupyter Notebook is not a single monolithic file, but rather a collection of interconnected components:

  • Cells: The fundamental unit of a notebook. A notebook is composed of multiple "cells" that can be executed individually. There are two primary types:
    • Code Cells: These contain executable Python code. When run, the output (such as a plot or a calculation) appears directly below the cell.
    • Markdown Cells: These are used for documentation. They allow you to use rich text formatting, headers, and mathematical notation to explain your work.
  • The Kernel: This is the "engine" running behind the scenes. The kernel is the computational process that executes the code contained in your cells.

Keep reading for free.

Create an account to finish this reading and make it part of your study routine.

Continue reading free

Already have an account? Log in

Updated

Study it your way.

Import this reading into your study set to get started with another study mode.

Make it your own.

Keep this reading in a new study set, or add it to one you already use.