Physics 234: Exercise 2
Imagine a hypothetical non-binary computer whose oating-point numbers are encoded using
one sign bit and seven decimal digits. Each number is stored internally in the format
i
f4
f3
f2
f1
f0
e
and interpreted as the value (, i, f,
Physics 234: Lab Test
Thursday, April 7, 2011
UserID: p234u
Students Name:
1. How many of the numbers 1000, 1001, . . . , 7999, 8000 are perfect squares?
58
2. The number of ways to group 2n objects into n pairs is
T2n =
(2n)!
.
n! 2n
(Remember that n! =
Physics 234: Lab Test
Tuesday, April 5, 2011
UserID: p234u
Students Name:
1. How many of the numbers 1000, 1001, . . . , 7999, 8000 are perfect cubes?
11
2. The number of ways to group 2n objects into n pairs is
T2n =
(2n)!
.
n! 2n
(Remember that n! = 1 2
Physics 234: Computational Physics
In-class Midterm Exam
Monday, February 14, 2011
Students Name:
Fill-in-the-blank and multiple choice questions (20 points)
Mark your answers on the exam sheet in blue or black ink. Please be clear
about your selections.
Physics 234: Quiz 7
Friday, March 25, 2011
Students Name:
1. A 4th-order polynomial p(x) passing through all the points in S = cfw_(x0 , y0 ), . . . , (x4 , y4 ) is a
Lagrange interpolant for the data set S. p(x) is plotted in the gure above. But superimp
Physics 234: Exercise 1
1. An N -bit binary register can hold 2N unique bit patterns. To represent an unsigned
integer, the bit patterns are interpreted as the base-2 numbers 0 to 2N 1. There are
several possible ways to represent signed integers. Nonethe
Physics 234: Quiz 2
Friday, January 28, 2011
Students Name:
1. The corrections are 01, 01, and 3637.
$ more grid.cpp
#include <iostream>
using std:cout;
using std:endl;
#include <iomanip>
using std:setw;
int main()
cfw_
int n = 1;
do
cfw_
cout < setw(6) <
Physics 234: Lab Test
Tuesday, April 5, 2011
UserID: p234u
Students Name:
1. How many of the numbers 1000, 1001, . . . , 7999, 8000 are perfect cubes?
2. The number of ways to group 2n objects into n pairs is
T2n =
(2n)!
.
n! 2n
(Remember that n! = 1 2 3
Physics 234: Computational Physics
Final Exam
Thursday, April 22, 2010 / 14:0017:00 / CAB 239
Students Name:
Instructions
There are eleven questions. You should attempt all of them. Mark your response on the test
paper in the space provided. For those que
Physics 234: Lab Test
Tuesday, April 6, 2010
Students Name:
UserID: p234u
1. Consider the recursive sequence dened by x0 = 2 and xn+1 := 2 + 2/xn . Its asymptotic value
X = limn xn is equal to the innite continued fraction
2
X =2+
2
2+
2
2+
2+
2
2 +
Repo
Physics 234: Exercise 4
Imagine a hypothetical non-binary computer whose oating-point numbers are encoded using
one sign bit and seven decimal digits. Each number is stored internally in the format
i
f4
f3
f2
f1
f0
e
and interpreted as the value (, i, f,
Physics 234: Exercise 2
1. We know that the addition overows because the most signicant carry bit is on.
1
1
A
+ 7
2
1
F
2
1
1
1
+ 0
0
1
0
1
0
1
1
1
1
1
0
1
0
1
1
0
0
1
1 1 1
0 1 0
0 0 1
2. We begin by expanding in powers of x.
ap = xq = (xn + x)q
n+1
q
x
Physics 234: Exercise 3
1. Suppose we have an NN matrix A whose elements Ai,j are labelled by row i and column
j, both counting from zero. The standard way to store such a matrix is to pack its N 2
elements into a one-dimensional array that can be accesse
Physics 234: Exercise 3
1. (a) Of the N 2 N = N (N 1) elements not on the main diagonal, half can be thrown
away. Hence, at least N 2 N (N 1)/2 = N (N + 1)/2 must be kept.
(b) The indexing rules I(i, j) for the symmetric matrix case are as follows.
upper
Physics 234: Exercise 4
Imagine a hypothetical non-binary computer whose oating-point numbers are encoded using
one sign bit and seven decimal digits. Each number is stored internally in the format
i
f4
f3
f2
f1
f0
e
and interpreted as the value (, i, f,
Physics 234: Exercise 1 Solutions
1. (a) The number 116 can be expanded in powers of two
116 = 64 + 32 + 16 + 4
= 26 + 25 + 24 + 22 ,
and hence 116 = 011101002 . Positive numbers that can be represented with a zero high bit
are the same in both representa
Physics 234: Computational Physics
Final Exam
Friday, April 17, 2009 / 14:0017:00 / V103
Students Name:
Instructions
There are ten questions. You should attempt all of them. Mark your response on the test paper
in the space provided. For those question th
Physics 234: Exercise 2
1. Complete the 8-bit, unsigned addition given below. Show all the steps in both hexadecimal
(left) and binary (right).
1
A
+ 7
F
2
1 1 1
1 1 1 1 1
+
Is there an overow?
2. Suppose we want to nd an iterative algorithm for raising t
Physics 234: Quiz 1
Wednesday, January 19, 2011
Students Name:
1. The 8-bit unsigned binary computation shown below represents the addition 35 + 165 = 200. Fill in the
missing six digits (zeros and ones) in the bottom row and the missing carry bits in the
Physics 234: Solutions to Practice Exam Questions
1.
2. A polynomial with roots at 1, 2, and 3 can be factored as p(x) (x + 1)(x 2)(x 3). The
requirement that p(0) = 1 xes the prefactor:
1
1
p(x) = (x + 1)(x 2)(x 3) = x3 4x2 + x + 6 .
6
6
3.
4. Suppose f
Solutions to practice test 1
1(b) The number 255 = 111111112 is the largest that can be represented in an 8-bit unsigned
binary system. Hence, 255 + 1 overows to give 000000002 = 0.
2(a) Since its second argument is passed by value, foo(4,z) does nothing
Physics 234: Computational Physics
In-class Midterm Exam
Wednesday, February 11, 2009
Students Name:
Fill-in-the-blank and multiple choice questions (20 points)
Mark your answers on the exam sheet in blue or black ink. Please be clear
about your selection
Physics 234: Exercise 1 Solutions
1. (a) Take the complement of each bit (i.e., exchange 0 1) and add 1. In this way 3 goes to 3
as follows: 00000011 11111100 + 1 = 11111101.
(b) The most negative representable number 2N 1 is its own twos complement. When
Physics 234: Computational Physics
In-class Midterm Exam
Friday, February 12, 2010
Students Name:
Fill-in-the-blank and multiple choice questions (20 points)
Mark your answers on the exam sheet in blue or black ink. Please be clear
about your selections.
1(b) The number 255 = 111111112 is the largest that can be represented in an 8-bit unsigned
binary system. Hence, 255 + 1 overows to give 000000002 = 0.
2(a) Since its second argument is passed by value, foo(4,z) does nothing to the value of z.
bar(2.3,z)
Physics 234: Lab Test
Tuesday, April 6, 2010
Students Name:
UserID: p234u
1. Consider the recursive sequence dened by x0 = 2 and xn+1 := 2 + 2/xn . Its asymptotic value
X = limn xn is equal to the innite continued fraction
2
X =2+
2
2+
2
2+
2+
2
2 +
Repo
Physics 234: Lab Test
Thursday, April 8, 2010
Students Name:
UserID: p234u
1. Consider the recursive sequence dened by x0 = 3 and xn+1 := 3 + 3/xn . Its asymptotic value
X = limn xn is equal to the innite continued fraction
3
X =3+
3
3+
3
3+
3+
3
3 +
Rep
Physics 234: Practice Lab Test
1. How many of the numbers 1, 2, . . . , 1000 are perfect squares?
31
How many are perfect cubes?
10
(Hint: you can solve this question without using either sqrt or pow.)
2. Consider an unbounded square grid of points spaced
Physics 234: Lab Test
Tuesday, March 31, 2009 / Thursday, April 2, 2009
Students Name:
UserID: p234u
1. Consider the nite sequence of numbers
S = (n2 + 3n5 )65 = (4, 100, 738, . . . , 3480876100).
n=1
How many of the numbers in S are divisible by 12? (Hin
Physics 234: Computational Physics
Final Exam
Friday, April 17, 2009 / 14300717300 / V103
Students Name: Kev ll BQAQlA
Instructions
There are ten questions. You should attempt all of them. Mark your response on the test paper
in the space provided. F
function ps1q4
%
ID: 1364035, Craig Yanitski
%
The solution to question 4 of the first problem set
x = linspace (0, 5, 100);
%Initialize a vector with the x values
a = 0.1:0.2:1.1;
%Initialize a vector with the constant
values
Table = [x',(erf(x*a(1)', (e