1 Archimedean spiral
Using Pyplot and Numpy, state a function arc that draws a green Archimedean spiral according to the following parameterized equation:
- x(t) = cos(t)
- y(t) = sin(t)
t should vary in [0,5] (step 0.01) and the function should call plt.plot with arguments x and y, as well as plt.show() function at the end. Call the function.
2 Heart
Using Pyplot and Numpy, state a function heart that draws in dashed red the following parameterized equation:
- x(t) = 16sin3(t)
- y(t) = 13cos(t) 5cos(2t) 2.5cos(3t) cos(4t)
t should vary in [0,2] (step 0.01) and the function should call plt.plot with arguments x and y, as well as plt.show() function at the end. Call the function.
To see the result you should first close the window of part 1 (Archimedean spiral).
3 Graphs
We wish to use graph theory in order to solve the following problem. A company should carry different chemical products P1, P2, , Pk from the factory to a city. For security reasons, some products should not be carried in the same truck: i,0 < i < k,Pi is not compatible with Pi+1. Moreover Pk is not compatible with P1.
- Write a comment: how can we state an undirected graph that visually represents this problem: 1. What are the vertices, what are the edges? 2. What is the specific property of this graph?
- Write an algorithm that, given an integer k > 1, returns the minimum number of trucks necessary to carry all the products.
4 Algorithm
In ancient times, Egyptians did not use multiplication tables. Instead, they transformed any calculation into multiplication by two, and additions. The principle of Egyptian multiplication is the following: (x y) = 2 (x (y/2)) if y is even, and
(x y) = x + (x (y 1)) if y is odd. For instance,
(7 10) = (2 (7 5)) = (2 (7 + (7 4))) = (2 (7 + (2 (7 2)))).
Write a recursive Python function that, given two strictly positive integers x and y (the arguments of the function), returns the result of x y obtained using the Egyptian method. Of course, directly multiplying x by y is allowed in your code if and only if x 2 or y 2.

![[Solved] CS5007 Homework 4](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip.jpg)

![[Solved] CS5007 Homework 3](https://assignmentchef.com/wp-content/uploads/2022/08/downloadzip-1200x1200.jpg)
Reviews
There are no reviews yet.