偏微分方程代写 Numerical Solution to PDEs using

ESAM 446-1: Numerical Solution to PDEs using
Finite Differences

偏微分方程代写 Once you can represent polynomials, you should write a RationalPolynomial class. This class should look a lot like the Fraction class

The goal of this homework assignment is to write a Python class to represent ratio nal polynomials. Everything must be in the fifile polynomial.py. By rational polyno mials, I mean the ratio of two polynomials, each of which have integer coeffiffifficients. In general, the polynomials could have rational coeffiffifficients, but this is equivalent to in teger coeffiffifficients. First you will write a Polynomial class; the RationalPolynomial class will then contain a numerator and denominator, which are both instances of Polynomial.

Here’s a list of features you need to implement for the Polynomial class:  偏微分方程代写


  • Attributes of Polynomial: the order of the polynomial, and the coeffiffifficients. You should store the coeffiffifficients using a numpy array of integers, e.g.,

coefficients=np.zeros(order+1,dtype=int)

coefficients[order] = 1

makes the polynomial xn where n is the order. Strictly speaking, you don’t need the order to be an attribute, because it is related to the length of the coeffiffifficients array, but it might be convenient to store it as its own varible.


  • A staticmethod called from_string which allows the user to defifine a polyno mial from a string. This should be able to make sense of strings of the form

"-1-7x^4+3x^2". Hint: First split the equation up into monomial terms, and then extract the coeffiffifficients from each monomial.  偏微分方程代写


  • A __repr__ function which gives a useful visual representation of the polyno mial.


  • Methods for addition, subtraction, multiplication, and equality.

  • Dividing two polynomials (__truediv__) should return a RationalPolynomial.

The hw1_tests1.py script contains the pytest tests I will use to grade the Polynomial class.

Once you can represent polynomials, you should write a RationalPolynomial class. This class should look a lot like the Fraction class I discussed in lecture.  偏微分方程代写

Features for the RationalPolynomial class:


  • It should store a numerator and denominator, each of which are Polynomials; in Fraction they were both integers.


  • It should have a staticmethod called from_string. The string used to specify a RationalPolynomial will have parentheses around the number and denomina

tor, and these will be separated by a / character. E.g., "(2 + x)/(-1 + x + 2*x^3)".


  • When you initialize a RationalPolynomial, you should check if there are any common factors between the numerator and denominator. Hint: It is probably

easier to fifind a package that will do this for you, rather than coding up an algorithm to do this yourself.


  • Methods for addition, subtraction, multiplication, division, and equality.

I also encourage you to write a repr function, which will be useful for debugging.  偏微分方程代写

偏微分方程代写

更多代写:cs代写   经济代考   会计代写      计算机科学代写  文章修改代写

发表回复

客服一号:点击这里给我发消息
客服二号:点击这里给我发消息
微信客服1:essay-kathrine
微信客服2:essay-gloria