top of page
Search
rozzeta8659

Homework 5 Monomials All Operations: A Complete Guide for Students



Exercise 2: Suppose we represent univariate polynomials as lists of monomials. Each monomial of the form $ax^n$ is represented as a list (a n) consisting of the coefficient a and the exponent n. Thus the polynomial $2-3x+x^2$ is represented by ((2 0) (-3 1) (1 2)). We assume that each exponent can occur in the polynomial representation at most once. E.g. ((1 0) (2 0)) is not a valid representation. Devise functions (add-pol p1 p2) and (mult-pol p1 p2) taking as arguments two polynomials p1,p2 and returning their sum and product respectively. For example, let p1 be ((1 0) (1 1)) (i.e., $p_1(x)=1+x$) and p2 ((-1 0) (1 1) (3 2)) (i.e., $p_2(x)=-1+x+3x^2$). Then (add-pol p1 p2) => ((2 1) (3 2)) (mult-pol p1 p2) => ((-1 0) (4 2) (3 3))Even though it might look like a tedious task, it is not so terrible because we will call higher-order functions to rescue us. Thanks to the folding function foldl, we will reduce our problem just to monomials. Let's start by defining simple operations on monomials. To make our code more comprehensible, we define the following functions extracting the coefficient and the exponent from a monomial.(define (get-coef m) (car m)) ; first component(define (get-exp m) (cadr m)) ; second componentNext it is easy to define addition of two monomials of the same exponents, namely $ax^n + bx^n = (a+b)x^n$. Similarly, multiplication of monomials is defined by $(ax^n)(bx^k)=abx^n+k$.


Now we come to the main trick. Suppose we have two polynomials $p_1(x)=a_0+a_1x$ and $p_2(x)=b_0+b_1x+b_2x^2$. We can express their sum as$p_1(x) + p_2(x) = ((p_1(x) + b_0) + b_1x) + b_2x^2$. Thus we need only to add a polynomial and a monomial at a single steps. Then the repetitive sum can be done by foldl function. Similarly for the multiplication, we can first compute products of all monomials by means of the function f-all-pairs from Exercise 1 and then express the results as $p_1(x)p_2(x) = (((a_0b_0 + a_0b_1x) + a_0b_2x^2) + a_1b_0x) + \cdots$.




Homework 5 Monomials All Operations



Thus we need a function adding a monomial mon and a polynomial pol. The function has to distinguish two cases: 1) we add a monomial whose exponent does not occur in pol, 2) or whose exponent occurs in pol. So we first filter monomials in pol according to their exponentsto obtain the monomial of the same exponent as mon and the remaining monomials. If there is no monomial of the same exponent, we just cons mon to the result, otherwise we add monomials of the same exponent and cons it to the result.


(define (add-mon-pol mon pol) (define (same-exp? m) (= (get-exp mon) (get-exp m))) ; #t if m has the same exponent as mon (define same-mon (filter same-exp? pol)) ; list containing the monomial of the same exponent or empty list (define rest (filter (compose not same-exp?) pol)) ; remaining monomials of different exponents (if (null? same-mon) (cons mon rest) (cons (add-mon mon (car same-mon)) rest)))


Finally, we can apply the folding function foldl to sum all monomials as was shown above. However, there are still two problems we have to deal with. 1) It may happen that the result contains monomials of the form $0x^n$. Such monomials can be clearly filtered out of the result. 2) It is common to sort monomials according to their exponents. Thus we define a function normalize solving these two problems.


Is your child spending hours each night struggling with homework on order of operations or interval notations? Does test preparation for distributive property exams cause an extra level of stress for them? Varsity Tutors can find you a talented algebra tutor in Schaumburg, IL, who can work with students at all proficiency levels. Your child's tutor will work with them one on one to understand topics such as writing equations given slope and a point, writing equations in standard form, calculating scope, and square roots. Their tutor will work around your schedule, making the process as easy as possible. They can work with their tutor either online or in person at a time and place that is most convenient for you and your schedule.


Multiplying and dividing monomials, along with each concept of algebra are important stepping stones for high level math courses. Looking ahead to your child's future career goals, algebra will become very important if they wish to become an engineer, surveyor technician, or architect. Let us match your child with an expert algebra tutor in Schaumburg, IL, who will put your child's needs first. Contact Varsity Tutors today to find a tutor who might help your child excel at algebra. 2ff7e9595c


0 views0 comments

Recent Posts

See All

Baixar Crafting and Building 2.7 1

Baixar Crafting and Building 2.7 1: Um jogo de sandbox gratuito e divertido para todos Se você está procurando um jogo que permita...

Comments


bottom of page