Write a function to find the power set of a set


Problem 1: Write a function to find the power set of a set. The function should take a set as an input, and generate the elements of its power set. What is the complexity of the program? Write the complexity in a doc string at the beginning of your program.

Problem 2: Write a recursive function to find the integral In = 01xn exp(x) dx using a stable backward implementation. Now, plot the value of the integral as a function of n from 0 to 30. You can take I90 = 0 and begin the backward recursion. What is the complexity of the program? Write the complexity in a doc string at the beginning of your program.

Problem 3: Error analysis exercise: We can see that the integral I = 0 exp(-x)dx = 1. However, to do this integral on computer, we need a representation of exp(x). Write a function to implement the Taylor series of exp(x) using N terms. The function should have name expf (x, N). Now write a program to integrate this function using trapezoidal rule from x = 0 to x = xc. In principle, the error in your answer should decrease as N increases and xc increases. However, you also have another parameter ?x inside your program and the answer should get closer to 1 as ?x decreases. However, for the purpose of this problem, keep ?x = 0.01 fixed.

Let's analyze the effect of xc and N on the integral computed by your program. In one figure, make the line plots of error = Ia - 1, where Ia is the approximate integral computed by your program, as a function of N = [1, 50] when xc = 2, 8, 15, 20, 50. In the second figure, plot the error vs. xc = [0, 50] when N = 5, 10, 20, 40, 100.

Please put your figures in a word document, and describe the effects of the paramters on the error. Also, describe if a particular choice of implementation of function expf (x, N ) makes a difference. For exam- ple, you can compute the terms directly as xn/n! or you can get next term by multiplying the previous term with x/n at each step if you are going from lower n to higher n. You can also implement the sum in the series in backward or forward manner and either add whole terms or build terms at each step. The error due to finite N and finite xc is called algorithmic error. If your total errors only keep decreasing as N and/or xc increase, it means your round-off errors are either ap- proximately constant or not growing very fast. However, if your error decrease and then begin to increase, it means that initially algorithmic error decreased and round-off error was small, but later round-off errors took over. Include this discussion specifically for your program.

Our Computational Physics Assignment Help service has proficient tutors, experienced proofreaders and trained editors, who work altogether and put their maximum effort, in order to deliver you the finest assignment solution that no other in the industry can provide.

Tags: Computational Physics Assignment Help, Computational Physics Homework Help, Computational Physics Coursework, Computational Physics Solved Assignments

Attachment:- Computational Physics.rar

Request for Solution File

Ask an Expert for Answer!!
Physics: Write a function to find the power set of a set
Reference No:- TGS03043571

Expected delivery within 24 Hours