WOLFRAM NOTEBOOK

Lab 1: Welcome to Wolfram Notebooks

NetID: <Please fill in>

Introduction

Greetings students, this will be where we will be working on the lab. Wolfram Notebooks offer a great environment for developing and sharing technical workflows. You can add any type of content to notebooks--text, images, create visualizations, write code and evaluate it as well to see the output of the code. You can also add interactivity to notebooks very easily. We will explore all these options as we use the labs for some hands-on exercises to better understand the topics we discuss in the lecture sessions.

The Basics

Add Text

Notebooks can contain both "Text" and "Input" cells. Move the cursor right below this cell till it changes into a horizontal cursor and click in the notebook to see the cell insertion bar. Click on the "+" icon on the overhang and select "Plain Text". This will create a text cell and you can type whatever you would like in it.

Add Code

Anytime you simply click inside a notebook, an "Input" cell is started by default, which accepts "Wolfram Language Input". This allows you to write some code and then evaluate it to see the output.

Click below to start a new Input cell and type in 2+2 within it. Then press the "Shift" and "Enter" keys together from your keyboard to evaluate this input and look at the output.
Let’s try another example of code. Click in the notebook to place your cursor in a spot right below this cell. Start a new “input” cell and type in the magic incantation
ListStepPlot[{1,0,1,0,1}]
(exactly as you see it here).
Press the “Shift” and “Enter” keys together from your keyboard to evaluate this input and watch the output appear magically 😉

Use the Notebook as a Calculator

Try some calculations:

Try the following (place your cursor next to a number in the cell and press Shift and Enter from your keyboard simultaneously):
23+34
45678*567
43^2

Problem 1

Remember 1 bit can represent 2 things (0 or 1), two bits can represent 2 X 2 or 2^2 = 4 things, three bits can represent 2 X 2 X 2 = 2^3 = 8 things and n bits can represent 2 X 2 X ..... X 2 = 2^n things.
How many different things can we represent using 24 bits?

Problem 2

Remember the mathematical formula to find how many bits you would need to represent n different things?
Log
2
n
Also can be written in code as
Ceiling[Log[n,2]]
Use the formula to calculate the number of bits needed to represent 64 different things.

Problem 3

Out[]//TableForm=
1
2
2
2
2
4
3
2
8
4
2
16
5
2
32
6
2
64
7
2
128
8
2
256
9
2
512
10
2
1024
With the help of the above information, can you answer the following?
  • How many bits will be needed to represent the colors in VBGYOR?
  • How many bits will be needed to represent 256 colors?
  • How many bits will be needed to represent the 25 students + instructor +TA of ECE101?
  • How many bits will be needed to represent 1000 books in the Manga section of Champaign Public Library?
  • Use the Notebook to Create Visualizations

    Here is a list of 20 random integers between 1 and 10:
    In[]:=
    RandomInteger[10,20]
    Out[]=
    {10,9,2,10,3,6,2,0,0,0,9,5,8,2,0,5,2,0,1,2}
    You can plot them in a line graph as follows:
    In[]:=
    ListPlot[{10,9,2,10,3,6,2,0,0,0,9,5,8,2,0,5,2,0,1,2}]
    Out[]=
    In[]:=
    ListLinePlot[{10,9,2,10,3,6,2,0,0,0,9,5,8,2,0,5,2,0,1,2}]
    Out[]=

    Problem 4

    Plot the following data using ListLinePlot:
    {6,7,6,8,1,3,3,0,10,5,7,6,7,10,5,7,1,7,4,4}

    Problem 5

    Here is one way to visualize same data consisting of 0s and 1s:
    In[]:=
    ListStepPlot[{1,0,0,1,1,1,0,0,1}]
    Out[]=
    Use ListStepPlot to visualize the signal: {1, 1, 0, 1, 0, 1, 1, 0 ,0, 0, 1, 1}

    Use the Notebook to Work with Images

    Here is how you can find the dimensions of an image:
    In[]:=
    ImageDimensions
    Out[]=
    {488,458}
    The following shows the pixel values of this image:
    ImageData

    Problem 6

    Copy and paste an image from the web into your notebook and show its dimensions and pixel values.

    Use the Notebook for Interactive Content

    Problem 7

    Set the buttons appropriately to represent the number 5 using three bits.

    Submitting your work

    Publish your notebook and send the link to your TA Sattwik (sattwik2@illinois.edu).
    1. From the cloud notebook, click on “Publish” at the top right corner.
    2. From the desktop notebook, use the menu option File -> Publish to Cloud

    Additional help

    Look at this video to get familiar with the notebook interface: Learn to Use a Notebook
    Wolfram Cloud

    You are using a browser not supported by the Wolfram Cloud

    Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.


    I understand and wish to continue anyway »

    You are using a browser not supported by the Wolfram Cloud. Supported browsers include recent versions of Chrome, Edge, Firefox and Safari.