Write the python code for the problems

Assignment Help Python Programming
Reference no: EM131976433

Topic: CS and Math

Question: Write the python code for the following problem. Problems are given below.

1. Modified Cholesky Factorization: An n x n positive definite matrix A can be factorized into A = LDLT, where L is lower triangular and D is diagonal.

Modifications to the diagonal elements of D are applied to ensure that the matrix is "sufficiently positive definite" as follows:

25_figure.png

Implement the modified Cholesky's algorithm by integrating the above modification in the appropriate part of the code. Apply your algorithm to the following randomly generated matrix:

import numpy as np

A = np.random.rand(10, 10)*2 - 1

A = A + A.T

Quantify the difference between A and the modified version A, as outputted by the algorithm by 1) comparing the eigenvalues of the two matrices; 2) comparing the diagonal values of the two matrices, and 3) computing the sum of the squares of the non-diagonal elements of A - Am. Use appropriate scipy functions for eigenvalue and norm computations as needed. Use δ = 10-8 and β = 100 in your implementation. Comment on your results.

2. Steepest Descent with quadratic interpolation line search: Consider the usual steepest descent step xk+1 = xk + αkpk, where αk is the step size and pk = -∇f(xk). During the k-th iteration of the steepest descent algorithm, we first make and initial guess α0 for the step-size as:

α0 = (2(f(xk) - f(xk-1)))/φ'(0),

where φ(α) = f(xk + αpk). Performing a quadratic interpolation using φ(0), φ'(0), and φ(α0) as knot points and minimizing the quadratic, we obtain the new trial step

α1 = φ'(0)α02/(2[φ(α0) - φ(0) - φ'(0)α0]).

If the sufficient decrease condition:

φ(α) ≤ φ(0) + c1αφ'(0)

is satisfied, we terminate the search, Otherwise, we use φ(0), φ'(0), and φ(a1) as new knot points and continue the search. Write a python program using the TensorFlow package to implement this approach. Apply your implementation to minimize the Rosenbrock function and benchmark the required number of iterations to converge to the minimum [within 10-6 tolerance) against the built-in method GradientDescentOptimizer () with constant learning rate 0.001. Use c1 = 10-4 in your implementation.

3. Conjugate Gradient (CG): Let A be n x n positive definite matrix. Implement the CG method for solving the linear system Ax =b as outlined in attached file.

Apply your algorithm to solve a linear system in which Ai,j = 1/(i + j - 1) and b = (1, 1, · · · , 1)T. Set the initial point x0 = 0 and try dimensions 5, 8. Report the number of iterations required to reduce the residual below 10-6. Verify your solutions by comparing your results with the builtin scipy solver.

Attachment:- Assignment File.rar

Reference no: EM131976433

Questions Cloud

How to thoroughly research a topic is extremely important : Describe your experiences using resources, including concerns encountered when conducting academic research through the Ashford University Library.
What was the value of depreciation expense : Density Farms, Inc. had sales of $500,000, cost of goods sold of $180,000, What was the value of depreciation expense?
Discuss the various technical challenges everyone has posted : Discuss the various technical challenges / opportunities everyone has posted. Based on your discussion, choose the most important challenge for your Part 3.
What concentration of aqueous baso4 : What concentration of aqueous BaSO4 would have the same vapor pressure as a 0.4M solution of CaCl2 at the same temperature, assuming ideal behavior?
Write the python code for the problems : Topic: CS and Math. Write the python code for the following problem. Implement the modified Cholesky's algorithm by integrating
What is the volume of the balloon when it bursts : If the atmospheric pressure at 30.0 km is 28.0 torr and the temperature is -44.0 °C, what is the volume of the balloon when it bursts?
How many ppb of no2 is in the sample of air : A cubic meter of air was sampled at 1.0 atm and 20 C. An analysis of that sample found it contained 160 micrograms of NO2. How many ppb of NO2 is in the sample
The spot exchange rate of EUR : Suppose that the spot exchange rate of EUR is 1.2545 USD for 1Euro. What is the 3-month forward exchange rate?
Describe why stated research design is appropriate : Delineate your intended methodology and research design. Restate the purpose of your study. Explain why stated methodology will be best.

Reviews

Write a Review

Python Programming Questions & Answers

  Write a python program to implement the diff command

Without using the system() function to call any bash commands, write a python program that will implement a simple version of the diff command.

  Write a program for checking a circle

Write a program for checking a circle program must either print "is a circle: YES" or "is a circle: NO", appropriately.

  Prepare a python program

Prepare a Python program which evaluates how many stuck numbers there are in a range of integers. The range will be input as two command-line arguments.

  Python atm program to enter account number

Write a simple Python ATM program. Ask user to enter their account number, and print their initail balance. (Just make one up). Ask them if they wish to make deposit or withdrawal.

  Python function to calculate two roots

Write a Python function main() to calculate two roots. You must input a,b and c from keyboard, and then print two roots. Suppose the discriminant D= b2-4ac is positive.

  Design program that asks user to enter amount in python

IN Python Design a program that asks the user to enter the amount that he or she has budget in a month. A loop should then prompt the user to enter his or her expenses for the month.

  Write python program which imports three dictionaries

Write a Python program called hours.py which imports three dictionaries, and uses the data in them to calculate how many hours each person has spent in the lab.

  Write python program to create factors of numbers

Write down a python program which takes two numbers and creates the factors of both numbers and displays the greatest common factor.

  Email spam filter

Analyze the emails and predict whether the mail is a spam or not a spam - Create a training file and copy the text of several mails and spams in to it And create a test set identical to the training set but with different examples.

  Improve the readability and structural design of the code

Improve the readability and structural design of the code by improving the function names, variables, and loops, as well as whitespace. Move functions close to related functions or blocks of code related to your organised code.

  Create a simple and responsive gui

Please use primarily PHP or Python to solve the exercise and create a simple and responsive GUI, using HTML, CSS and JavaScript.Do not use a database.

  The program is to print the time

The program is to print the time in seconds that the iterative version takes, the time in seconds that the recursive version takes, and the difference between the times.

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