Your solution to this project must consist of a single PDF document, called project1.pdf, containing the Sage code and the answers for the four problems. For each problem, write a Sage function, titled def problem1(), def problem2(), etc, with the appropriate input arguments. Do not change the function names. Upload the file project1.pdf through Blackboard. No other format will be accepted.
MCS 320 Project 1 : Introduction to Symbolic Computing with Sage
We will use Sage to explore the basics of symbolic computing and the basic functionality of a computer
algebra system.
Problem One.
Write a Sage function which takes on input as its argument an integer n and returns a random n degree
polynomial with randomly generated integer coefficients. The randomly generated integer coefficients
range from -100 to +100, inclusive. In addition to returning the randomly generated polynomial of degree n, the Sage function must return the number of real roots of the randomly generated polynomial.
In particular, this Sage function returns the randomly generated polynomial and the number of its real
roots in form of a Python tuple or a list.
Input example : program1(6), where n = 6.
Output example:
(89x^6 - 19x^5 - 80x^4 - 76x^3 + 54x^2 - 39x + 45, 2)
As your solution to this problem, provide the Sage function and the output for n = 4 and n = 10.
Problem Two. Write a Sage function which takes on input as its arguments a polynomial f with integer
coefficients and a list L. The polynomial f is a symbolic expression in the variable x. The list L consists
of an unspecified number of sub-lists, each of which contains two integers. These two integers represent
the x and y coordinates. As an example of L, consider L = [[x1, y1], [x2, y2], [x3, y3], …[xk, yk]]. This Sage
functions returns all sub-lists in L, for which f(xi) = yi
, for all xi and yi
in sub-lists of L.
Input example :
problem2( 2x^2-2x+3, [[0, 3], [1, 4], [2, 7], [3, 17], [4, 33], [5, 43], [6, 63],
[7, 87], [8, 116], [9, 147]])
Output example:
[[0, 3], [2, 7], [5, 43], [6, 63], [7, 87], [9, 147]]
As your solution to this problem, provide the Sage function and the output for f = x
3 − x
2 − 1
and L = [[0, −1], [1, −2], [2, 4], [3, 17], [4, 48], [5, 99], [6, 189], [7, 332]].
Problem Three. Write a Sage function which takes on input as its argument a polynomial f. The
polynomial f is a symbolic expression with integer coefficients. This function returns the count of how
often the sign of the coefficients has changed.
Input example :
problem3(13x^6 - 88x^5 + 53x^4 - 58x^3 - 57x^2 + 93x + 22)
Output example: 4
As your solution to this problem, provide the Sage function and the output for
f = −27 ∗ x
7 + 3 ∗ x
6 − 28 ∗ x
5 + 44 ∗ x
4 − 11 ∗ x
3 − 71 ∗ x
2 + 6 ∗ x − 14
UIC, Department of Mathematics, Statistics and Computer Science page 1
MCS 320 Project 1 due Friday, September 25, 2020 at 9 AM Fall 2020
Problem Four. Two cars leave an intersection at the same time. One car heads north at the constant
speed of s1 (ft/sec). The second car heads east at the constant speed of s2 (ft/sec). Write a Sage function
which takes on input as its argument the constant speed s1 of the first car, the constant speed s2 of the
second car, h hours and m minutes, the time the two cars left the intersection. This Sage function returns
the distance (in miles) between the two cars after h hours and m minutes.
Input example :
problem4(65, 65, 1, 12)
Output example: 75.2104485443873
As your solution to this problem, provide the Sage function and the output for problem4(25, 45, 1, 30),
where s1 = 25, s2 = 45, h = 1, and m = 30.
Project Guidelines and Submission Details
This project is due on Friday, September 25, 2020 at 9 AM. No late submissions will be accepted!
Your solution to this project must consist of a single PDF document, called project1.pdf, containing
the Sage code and the answers for the four problems. For each problem, write a Sage function, titled
def problem1(), def problem2(), etc, with the appropriate input arguments. Do not change the function
names. Upload the file project1.pdf through Blackboard. No other format will be accepted.
This project must be solved individually but you may brainstorm ideas with each other. Under no
circumstances are you allowed to copy or to collaborate with anyone else beyond big-picture discussion.
All submitted files will be automatically checked for plagiarism. Regardless of who copied from whom,
all caught in the act of plagiarism will be penalized. Using the internet resources is also off limits.
However, you are free to use our course resources, such as lecture notes, text books, and official Sage
documentation during the solving of this project.
If you have questions about this project, come to my online office hours, using the usual Zoom meeting