Question: Problem 3 : Polynomial division ( 1 0 pts . : Pseudocode, invariants and proofs: 5 pts . , Java code: 5 pts . autograded
Problem : Polynomial division pts: Pseudocode, invariants and proofs: pts Java code: pts autograded
Use the definition of polynomial division provided below:
Given two polynomials u and v with we can divide u by v to obtain a quotient polynomial q and a remainder polynomial satisfying the condition where the degree of is strictly less than the degree of v the degree of q is no greater than the degree of u and r and q have no negative exponents.
For the purposes of this class, the operation returns q as defined above.
The following are examples of division's behavior:
with
with
with
Note that this truncating behavior is similar to the behavior of integer division on computers.
Do the following:
Write a pseudocode algorithm for polynomial division. Write your answer in the file answersproblempdf
When writing pseudocode use symbols,, and to express rational number and polynomial arithmetic. You may also use to retrieve the coefficient at power of polynomial u as well as to denote the singleterm polynomial of degree i and coefficient c
State the loop invariant for the main loop and prove partial correctness. Write your answer in the file answersproblempdf For the proof question, you do not need to handle division by zero; however, you will need to do so in the Java program.
Important: write your pseudocode, invariants, and proofs first, then write the Java code. Going backwards will be harder.
Complete the public method public RatPoly divRatPoly in the RatPoly class and transfer your pseudocode algorithm into div. You may assume that the divisor p is nonnull. If p is zero div returns some q such that qisNaN is true. As with the other operations eg mul if this.isNaN or pisNaN, div returns some q such that qisNaN is true.
There is an extensive test suite for division in RatPolyDivideTest.java. You can run this test suite to evaluate your progress and the correctness of your code.
Step by Step Solution
There are 3 Steps involved in it
1 Expert Approved Answer
Step: 1 Unlock
Question Has Been Solved by an Expert!
Get step-by-step solutions from verified subject matter experts
Step: 2 Unlock
Step: 3 Unlock
