CSCE 625 Homework Assignment #8 due: Tues, 11/24/09 1. Write a prolog function to remove duplicates from a list: ?- remdups([1,3,4,2,4,3,6,8,6,5,4,2,3,4,9],X). X = [1, 8, 6, 5, 2, 3, 4, 9] 2. Implement prime factorization in Prolog. Here is an example: ?- factor(120,M). M = [5, 3, 2, 2, 2] ?- factor(7,P). P = [7] Note: you can use a simple algorithm that iterates from 1 up to N or sqrt(N) and tests for divisibility using mod. for example: divisible(N,X) :- M is N mod X,M=0. You will probably want to write and call an auxilliary function that builds up a list of factors as you go. 3. Write a logic program to compute the zeros of sin(x), that is the values of x such that sin(x)=0, using Newton's method. Newton's method says that, given a function f(x) and an initial guess or starting point x0, it may be iterated to get closer and closer to a zero by using this update equation: x_i+1 = x_i - f(x_i)/f'(x_i), where f'(x) is the derivative. You may assume a fixed value for f(x) and f'(x), i.e. sin(x) and cos(x). Write your predicate as zero(X,Y), where X is an input guess, and Y is the output value, iterated to be within some threshold of zero, e.g. -0.0001 0 and S > 0).