Hello, dear friend, you can consult us at any time if you have any questions, add WeChat: daixieit

BU MET CS-550: Comp. Math. for Machine Learning, v.1.0

Homework 1(v2)

. programming in Python or R

. individual work only and no plagiarism!!!

Homework Problems

1. The sum of the squares of the first n natural numbers is An   =  12  + 22  + ··· + n2   and  the square of the sum of the first n natural numbers is Bn  = (1 + 2 ··· + n)2 .  Let Cn  = Bn − An. For example, A10  = 385 and B10  = 3, 025. Then C10  = 3, 025 − 385 = 2, 640. What is B100  − A100 ?

2. Recall the definition of n! = 1 · 2 ··· (n−1)n.  For example, 5! = 120 and the sum of its digits is 1+2 = 3. What is the sum of the digits of 200!

3. Fibonacci Numbers are defined recursively as follows:  F0 = 1, F1 = 1 and F(n) = f(n−2)+F(n−1) for n ≥ 2. There- fore, the first Fibonacci numbers are  1, 1, 2, 3, 5, 8, 13, 21.

Let Z be a number representing the last 7 digits of your BUID. For example, if your BUID is U21437893,then Z = 1, 437, 893. Suppose you take the sequence S(Z) to contain the first n Fibonacci numbers with Fn  ≤ Z. What is the sum of even values in S(Z)?

4. In 1769, Leonhard Euler considered the following to be true: For all integers n,k > 1, if the sum of n k − th powers of

positive integers is itself a k-th power then n ≥ k.  In other words,

a1(k) + a2(k) + ··· + an(k) = bk      = n k

This was disproved using a computer in 1966:

(a) Write a Python  (no Numpy) program to compute the solution. Consider the following intervals for your com- putation:

20 a1 40

80 ≤ a2  ≤ 100

100 ≤ a3  ≤ 120

120 ≤ a4  ≤ 140

140 ≤ b ≤ 160

(b) Compute the execution time (using timeit

https://docs. python. org/3/library/timeit. h tml

5. Consider the last eight digits of your BUID as coordinates of four points A, B , C, and D.  For example, if BUID is U21437893 then A  =  (2, 1),  B  =  (4, 3)  C  =  (7, 8)  and D = (9, 3). Compute the perimeter of ABCD.

6. A Pythagorean triplet is a set of three natural numbers, a < b < c, for which a2 +b2 = c2 For example, 32 +42 = 52 and therefore (3, 4, 5) is a Pythagorean triplet. Consider the last four digits of your BUID as a number.  How many Pythagorean triplets are there? What is the maximum abc for your triplets?

7. A palindromic number reads the same both ways (just like strings). The largest palindrome made from the product of two 2-digit numbers is 9009 = 91 × 99.  Find the largest palindrome made of a product of two 3-digit numbers.

8. A positive integer is called square root smooth if all of its prime factors are strictly less than its square root.   For example, including the number 1, there are 29 square root smooth numbers not exceeding 100. Let N be the number representing the last 4 digits of your  BUID.  How  many smooth square root numbers are less than N? What is the largest such number? What is the median of such numbers?

9. using a graphics package (Matplotlib in Python) draw the following functions on the same plot (different colors and separate legends) for 0 ≤ x ≤ 1

(a) y = x

(b) y = x2

(c) y = −log x (natural base)

(d) y = ex

.