Question: Please Please Please make sure it is able to give the correct results for the tests/queries Write a Prolog program deriv(E,D) to do symbolic differentiation

Please Please Please make sure it is able to give the correct results for the tests/queries

Write a Prolog program deriv(E,D) to do symbolic differentiation of polynomial arithmetic expressions with respect to x. The first argument E is a polynomial arithmetic expression, and the second argument is the fully simplified expression, which must be expressed in canonical form.

You may use the cut symbol, !, e.g., after the Prolog interpreter finds an answer, to prevent the interpreter from returning the same answer again.

Tip: Beware of unary operators! -10 is different from -(10) or -x, and they have different expression trees.

Simplify as much as possible

Test cases:

PLEASE PLEASE PLEASE PLEASE MAKE SURE ALL TEST CASES WORK

?- deriv(x^2, Y).

Y = 2*x.

?- deriv((x*2*x)/x, Y).

Y = 2.

?- deriv(x^4+2*x^3-x^2+5*x-1/x, Y).

Y = 4*x^3+6*x^2-2*x+5+1/x^2.

?- deriv(4*x^3+6*x^2-2*x+5+1/x^2, Y).

Y = 12*x^2+12*x-2-2/x^3.

?- deriv(12*x^2+12*x-2-2/x^3, Y).

Y = 24*x+12+6/x^4.

Step by Step Solution

There are 3 Steps involved in it

1 Expert Approved Answer
Step: 1 Unlock blur-text-image
Question Has Been Solved by an Expert!

Get step-by-step solutions from verified subject matter experts

Step: 2 Unlock
Step: 3 Unlock

Students Have Also Explored These Related Databases Questions!