Great Deal! Get Instant $10 FREE in Account on First Order + 10% Cashback on Every Order Order Now

Problem One. Write a Sage function which takes as an input a polynomial p. The polynomial p will be a symbolic expression with integer coefficients. The function will return the count of how often the...

1 answer below »
  1. Problem One. Write a Sage function which takes as an input a polynomial p. The polynomial p will be a symbolic expression with integer coefficients. The function will return the count of how often the sign of the coefficients has changed. For instance the polynomial p(x) = x3 − x2 + x + 15 changes sign twice since the coefficients are 1, −2, 1, 15.

    Input example :

     problem1(11*x^6 - 6*x^5 + 5*x^4 - 58*x^3 - 51*x^2 + 9*x + 22) 

    Output example: 4

    As part of your solution to this problem, provide the Sage function and the output for

    p = -2*x^7 + 3*x^6 - 28*x^5 + 44*x^4 - 11*x^3 - 71*x^2 + 6*x - 14 

    Problem Two. Write a Sage function which takes as an input an integer M. Output the number of prime numbers ≤ M that are of the form k2 + k + 1. If M = 30 then the output would be 3 since there are three prime numbers ≤ 30 that are of the form k2 +k+1: 3 = XXXXXXXXXX,7 = XXXXXXXXXXand 13=32 +3+1.

    Input example :

     problem2(300) 

    Output example: 9

Answered 12 days After Sep 18, 2021

Solution

Ankur answered on Sep 30 2021
135 Votes
Solutions to this project must consist of a single, computer typed, PDF document, called project1.pdf, containing the Sage code and the answers for the four problems. For each problem, write a Sage func- tion, titled def problem1(), def problem2(), etc, with the appropriate input arguments.
Problem One.
Write a Sage function which takes as an input a polynomial p. The polynomial p will be a symbolic expression with integer coefficients. The function will return the count of how often the sign of the coefficients has changed. For instance the polynomial p(x) = x3 − x2 + x + 15 changes sign twice since the coefficients are 1, −2, 1, 15.
Solution: Sage function
Var(‘x’)
f= x3 − x2 + x + 15 %% Any polynomial can use
Sage : f.coefficients(sparse=False)
Sage :...
SOLUTION.PDF

Answer To This Question Is Available To Download

Related Questions & Answers

More Questions »

Submit New Assignment

Copy and Paste Your Assignment Here