Implement a restricted form of classic problem of arithmetic

Assignment Help Programming Languages
Reference no: EM132241777

Assignment -

Overview - In this assignment, you implement a restricted form of the classic problem of simplifying arithmetic expressions. You first implement two simplification operations, then a general algorithm to transform such expressions into a normal form.

The main restriction is that we only deal with the operations +, -, and *, and that the arguments are only integers and a single variable symbol x. Therefore, all expressions eventually simplify to apolynomial in x, with integer coefficients.

TYPES OF EXPRESSIONS IN THIS ASSIGNMENT

We have two main types of expressions in this assignment: Assignment 2 expressions or A2Expr are built as explained above, and polynomials in x or PExpr are represented in a specific short form.

1. Write a Lisp function: (remove-identities E)

2. Write a Lisp function: (simplify-zeroes E)

3.1 - Write a Lisp function: (simplify E)

BONUS QUESTION - Does the order of calls to remove-identities and simplify-zeroes in simplify matter? Could we get a different final result in simplify if we called these two functions in a different order?

  • If your answer is yes, give an example with two different call sequences with different results.
  • If your answer is no, give a good logical argument for why.

4. Write a Lisp function: (normalize P)

5. Write a Lisp function: (polynomial E)

5.1 Write two Lisp functions: (poly-add P1 P2) (poly-subtract P1 P2)

For these two functions, the inputs P1 and P2 are PExpr in normal form. The output should be the sum (for poly-add) or difference (for poly-subtract) of the two PExpr, also in normal form. See poly-add, poly-subtract examples in public tests.

5.2 Write a Lisp function: (poly-multiply P1 P2)

Again, the inputs P1 and P2 as well as the output are PExpr in normal form. See poly-multiply examples in public tests.

5.3 Implement polynomial, using the three helper functions.

Hint: use recursion, with the base cases:

1. integer n - represent by (n . 0)

2. atom x - represent by (1 . 1)

See polynomial examples in public tests.

6. Printing a PExpr in normal form.

Write a Lisp function: (print-pexpr P)

Instructions - Need to be done with LISP languages.

Attachment:- Assignment File.rar

Reference no: EM132241777

Questions Cloud

Propose your strategy for advertising the new product : Explore the Internet to find a multinational company for which you would enjoy building new consumer products.
Compute the total cost of ordering and carrying flour : Determine the economic order quantity. What is the average number of bags on hand? Compute the total cost of ordering and carrying flour.
State two smart goals for ge based on the case : Describe what GE could have done to improve the process of transporting the evaporator. Provide specific recommendations.
What the particular theorist was known for : Complete the following table by reordering the theorists according to the relevant date (and providing these dates), writing at least 90 words.
Implement a restricted form of classic problem of arithmetic : You implement a restricted form of the classic problem of simplifying arithmetic expressions. You first implement two simplification operations
Provide a brief summary about the challenges you faced : Provide a brief summary about the challenges you faced while completing this proposal. Select one of the five functions of management that appealed.
Evaluate the effectiveness of a planned change : Organizational development (OD) is a set of techniques for implementing a planned change to make people and organizations more effective.
Managing performance of employees is vital-yet delicate : Managing performance of employees is vital-yet delicate-responsibility. Describe potential causes of this scenario. What could manager have done differently?
What proportion of children ate the marshmallow : What proportion of children ate the marshmallow before the researcher returned to the room, and what proportion waited? What does Dr. de Posada say is the most.

Reviews

len2241777

2/24/2019 9:50:28 PM

Instructions - This is my assignment's requirements, it need to be done with LISP languages. Could you please have a look it, and I just wondering how much is it. Update 2: fixed typo in Question 2, (0 * Exp) changed to (* Exp 0). Added test cases 2.8, 3.9. 3.10 in a2-public-tests.lisp to cover more variations of multiply by zero. Update 20: added missing case (- Exp 0) in Question 1. I regret this omission, but at this point it seems easier to change the specification rather than rework all test cases to follow the old spec. Hints: To compute the product of two PExpr, "multiply them out" and normalize the result.

Write a Review

Programming Languages Questions & Answers

  Provide a brief history of the language

Provide a brief history of the language (1-2 slides) including standards if any. What need does this language fill that others do not and discuss the language in terms of the paradigms described in Chapters 1-5 of our textbook. Provide code sample..

  Write unix shell scripts using dos commands

Assume you are an experienced DOS programmer and you want to write UNIX shell scripts using DOS commands. Use the alias command so you can type the follow DOS commands and perform UNIX functions

  Create a new class called soda that is also a beverage

Create a new class called Soda that is also a caffeinated beverage by default it will have no option for condiments. Have it called in main. Main also calls the old addLemon function on Tea so that the customer gets two lemons.

  Write program to calculate and output tuition

Write a C++ program to calculate and output tuition. Prompt user for number of credits taken and type of classes ('U' for undergraduate - $380 per credit hour, or 'G' for graduate.

  Can explain procedural language in clearly and simply?

Can explain procedural language in clearly and simply? And compare other object-oriented programming, functional programming, logic programming and imperative programming.

  Create a catch block that catches the exception

Write a C# console application in which you declare an array of five integers and store five values in the array.

  Identify one advantage to using event-driven programming

Identify at least one advantage to using event-driven programming, as compared to using purely procedural programming.

  Write a program which displays four options to the user

Write a program which displays 4 options to the user and asks the user to enter one option and displays the output depending on the choice.

  Write program to asks user to enter temperatures

Write down the C++ program which asks the user to enter 12 temperatures for each month in year and store them in one-dimensional array called "temps".

  Write down public static method using public interface

Using only public interface of UnorderedLinkedList class, write down a method: public static void reverse(UnorderedLinkedList staff) that reverses the entries in a linked list.

  Write non-recursive function-compute n-th fibonacci number

Fibonnacci series 0,1,1,2,3,5,8,13,21,... starts with terms 0 and 1 and has property that each succeeding terms is sum of the two preceding terms. Write the non-recursive function which computes the n'th Fibonacci number.

  Write down a program which explores the seating patterns

write a program that explores the seating patterns related to course performance by using an array of student scores.

Free Assignment Quote

Assured A++ Grade

Get guaranteed satisfaction & time on delivery in every assignment order you paid with us! We ensure premium quality solution document along with free turntin report!

All rights reserved! Copyrights ©2019-2020 ExpertsMind IT Educational Pvt Ltd