Ask Question, Ask an Expert

+61-413 786 465

info@mywordsolution.com

Ask Math Expert


Home >> Math

1. Solving nonlinear equations, python modules, arrays, lists, functions, scipy, timing and plotting

In this example we investigate the time it takes to reach a certain accuracy using the Newton method and the secant method. Three test cases are considered: rst, con rm that your own code is second order accurate using the number of Newton iterations as a parameter. Then study scipy's Newton and secant method using the tolerance tol as parameter. Consider the determination of the zero of f(x) = exp( x) x.

First some preparations:

- We will use the modules math, time, scipy, scipy.optimze and scilab which need to be imported

- Then we will require an implementation of the function f(x) and of its derivative f0(x)

- As we are interested in the performance of our method in the case where the function evaluation is very costly we will arti cially increase the time for evaluation of f(x) and its derivative by a substantial amount using the sleep function from the time module

- As we do not know the exact solution, we will use the scipy library Newton method to determine a very accurate approximation as reference solution

- We will use the time function from the time module to determine the time required for the solvers. You might have to do multiple runs of the timing to get an accurate time.

In [ ]: # labbook -- fill in the missing bits see LB

# you will need the modules: math, time, scipy, scipy.optimze and pylab import math as ma

#LB ... fill in the missing bits here ...

# define function and derivative tev = 0.01 # time for one function evaluation (see sleep below)
def f(x):

""" function evaluation """

#LB include the function here as fx = .... tm.sleep(tev) # add some time to mimic a lengthy function evaluation return fx

def df(x):

""" derivative evaluation """

#LB fill in the derivative1.1.1 First experiment: implement very simple Newton method and compare accuracy against time spent.

Second experiment: investigate the tolerance parameter of the scipy newton method

Third experiment: investigating the tolerance parameter for the scipy secant method

Show how to convert any of the three container structures into any other.

What is the shape of an array? How can it be changed? Provide an example.

Math, Academics

  • Category:- Math
  • Reference No.:- M91227544

Have any Question?


Related Questions in Math

Assessment taskpractical investigation- question 1 requires

Assessment Task Practical Investigation - Question 1 requires selecting reference points from the graph. It is expected that each student will choose different reference points to other students. Take note of the criteri ...

Mathematics- algebraic geometry problemlet k denotes an

Mathematics- Algebraic Geometry Problem Let K denotes an algebraically closed field and let P 1 be constructed as in Example 5.5(a) in Gathmanns notes, i.e. P 1 is the gluing of X 1 = A 1 and X 2 = A 1 along  the open su ...

Questions - provide solution to the following questionsq1

Questions - Provide solution to the following questions: Q1. Evaluate the following: ∫xsin3xdx Q2. If , then for what value of α is A an identity matrix? Q3. The line y = mx + 1 is a tangent to the curve y 2 = 4x. Find t ...

Assignment - provide solution to the following questionsq1

Assignment - Provide solution to the following questions: Q1. Evaluate the following: ∫xsin3x dx Q2. If , then for what value of α is A an identity matrix? Q3. The line y = mx + 1 is a tangent to the curve y 2 = 4x. Find ...

Assignment - solving the five question in the very details

Assignment - Solving the five question in the very details, thanks a lot. Question - Let a ∈ P n be a point. Show that the one-point set {a} is a projective variety, and compute explicit generators for the ideal I p ({a} ...

Instructionsthe aim of the assignment is that the

Instructions The aim of the assignment is that the student/group studies and applies numerical methods such as Euler's method, the Improved Euler's method and the Runge-Kutta method to solve first-order differential equa ...

Mathematics- algebraic geometry problemlet k denotes an

Mathematics- Algebraic Geometry Problem Let K denotes an algebraically closed field and let P 1 be constructed as in Example 5.5(a) in Gathmanns notes, i.e. P 1 is the gluing of X 1 = A 1 and X 2 = A 1 along  the open su ...

Question 1 what is the nth order approximation using taylor

Question: 1. What is the nth order approximation using Taylor series? 2. What is Error Propagation? 3. Please explain what the total numerical error is? Please illustrate how the change of step size will affect the total ...

Clarity succinctness writing your name and netid1

Clarity, succinctness, writing your name and Netid: 1 Indistinguishability 1. If {X n }n is computationally indistinguishable from {Y n } n , {Y n } n is computationally indistin- guishable from {Z n } n, then (select th ...

Maths assignment - 1 analysis of a data setusing a

Maths Assignment - 1. Analysis of a data set Using a continuous data set you are requested to collect in the types of data and gathering data section, perform a statistical analysis on your data. You have opportunities t ...

  • 4,153,160 Questions Asked
  • 13,132 Experts
  • 2,558,936 Questions Answered

Ask Experts for help!!

Looking for Assignment Help?

Start excelling in your Courses, Get help with Assignment

Write us your full requirement for evaluation and you will receive response within 20 minutes turnaround time.

Ask Now Help with Problems, Get a Best Answer

Why might a bank avoid the use of interest rate swaps even

Why might a bank avoid the use of interest rate swaps, even when the institution is exposed to significant interest rate

Describe the difference between zero coupon bonds and

Describe the difference between zero coupon bonds and coupon bonds. Under what conditions will a coupon bond sell at a p

Compute the present value of an annuity of 880 per year

Compute the present value of an annuity of $ 880 per year for 16 years, given a discount rate of 6 percent per annum. As

Compute the present value of an 1150 payment made in ten

Compute the present value of an $1,150 payment made in ten years when the discount rate is 12 percent. (Do not round int

Compute the present value of an annuity of 699 per year

Compute the present value of an annuity of $ 699 per year for 19 years, given a discount rate of 6 percent per annum. As