WOLFRAM NOTEBOOK

ECE101 Lab 1: Welcome to Wolfram Notebooks

NetID: <Fill in>
Link to your published notebook: <Add it here>

Introduction

Greetings students, this is what you will be using to complete your ECE101 lab sessions.
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.
2+2
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 you see below:
ListStepPlot[{1,0,1,0,1}]
(☝🏽Type exactly what you see above).
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):
In[]:=
23+34
In[]:=
45678*567
In[]:=
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? Type in code to compute this below.

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[2,n]]
Use the formula to calculate the number of bits needed to represent 64 different things.

Use the Notebook to Create Visualizations

The following code creates a list of 20 random integers between 1 and 10:
In[]:=
RandomInteger[10,20]
Every-time you run the code ☝🏽 you will get a different list of 20 random integers. Don't take my word for it. Try running it a couple of different times.
You can use the code below 👇🏽 to plot the numbers from above in a line graph. Copy paste your list from above in place of the red caret ^ :
ListPlot[]
You should get something like this:
In[]:=
ListPlot[{2,8,1,2,3,3,7,4,5,2,5,10,8,4,0,9,10,7,2,6}]
Out[]=
Try the following with you list of numbers to get a different looking graphs:
ListLinePlot[]
ListStepPlot[]

Problem 4

I have the following list of bits:
{0,1,1,0,0,0,0,0,1,0,0,0,0,0,0}
Use one of the visualization functions from above that you think will best represent the bit pattern visually.
(Choose from ListPlot, ListLinePlot, ListStepPlot and remember to replace the original list of numbers with the bits from above ☝🏽).

Use the Notebook to Work with Images

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

Problem 5

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

Extra Credit: Use the Notebook for Interactive Content

Notebooks are useful for quickly and easily creating some pretty complex interactive interfaces that make it easy for your reader to interact with the explanation of a concept and understand it better.

Problem 6

Set the buttons below appropriately to represent the 7 colors, each with a unique pattern of bits (really a binary number).
A filled dot represents 1 and an unfilled dot represents 0.
Out[]=
Do you have enough bits so that each color has a unique representation?
If not, how do you solve the problem?

Submitting your work

1
.
Publish your notebook
1
.
1
.
From the cloud notebook, click on “Publish” at the top right corner.
1
.
2
.
From the desktop notebook, use the menu option File -> Publish to Cloud
2
.
Copy the published link
3
.
Add it to the top of the notebook, below your netID
4
.
Print to PDF
5
.
Upload to Gradescope
6
.
Just to be sure, maybe ping your TA Sattwik on Canvas that you have submitted.

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.