Reference no: EM132463701
PHY 505 - Computational Physics - University at Buffalo
Question 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.
Question 2. Write a recursive function to find the integral In = 0∫1xn 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.
Question 3. Error analysis excercise: 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 error 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.
Attachment:- Computational Physics.rar
Calculate and determine dollar value of the interest expense
: Calculate and determine dollar value of the interest expense for the 2018 fiscal year. Round your answer to the nearest whole dollar.
|
Determine the book value of the investment
: Determine the book value of the investment that should be reported at year end by All Good Company. Round to nearest whole dollar.
|
Determine the unrealized gain or loss on the investment
: Determine the unrealized gain or loss on the investment that should be reported at year end by All Good Company. If it is a loss, enter as a negative number
|
Calculate and determine the dollar value of cash
: Calculate and Determine the dollar value of cash provided or (used) by operating activities. If the total is a use of cash, enter as a negative number
|
PHY 505 Computational Physics Assignment
: PHY 505 Computational Physics Assignment Help and Solution, University at Buffalo - Homework Help - Write a function to find the power set of a set
|
What must the standard deviation for data be
: A recent survey of Fortune 500 firms found that on average, they contribute $332.54 per month for each salaried employee's health insurance.
|
Determine net cash received over life of bond investment
: Determine net cash received over life of bond investment.Annapolis Company purchased a $4,000, 6%, 5-year bond at 99 and held it to maturity.
|
Compute the income from operations
: Determine and Compute the Income from operations, Net income, Comprehensive income, Retained earnings balance at December 31, 2020
|
What is the probability of encountering 2 birds in 15 miles
: What is the probability of encountering 2 birds in 15 miles? What is the probability of encountering at least 2 birds in 20 miles?
|