df(x) The first derivative of a function f(x) at a point x = xo can be...
Fantastic news! We've Found the answer you've been seeking!
Question:
Transcribed Image Text:
df(x) The first derivative of a function f(x) at a point x = xo can be approx- dx imated with the two-point central difference formula: df(x) _ f(x+h)-f(xo-h) dx 2h Where h is a small number. Write a user-defined function that calculates the derivative of a math function f(x) by using the two-point central difference formula. For the user-defined function name, use dfdx=deriv (func, x0), where func is a name for the function that is passed into deriv, and x0 is the point where the derivative is calculated. Use h = 0.001 in the two-point central difference formula. Use the user-defined function deriv to calculate the following derivatives in your main script: 1. f(x)=sin(x) at x0 = 0 2. f(x)=sin(x) at x0 = pi/2 3. f(x)=x* sin(x)e* at x0 = 0.1 4. f(x)=x* at x0 = 2.3 (Note that this is hard to compute analytically, but easy to compute with MATLAB df(x) The first derivative of a function f(x) at a point x = xo can be approx- dx imated with the two-point central difference formula: df(x) _ f(x+h)-f(xo-h) dx 2h Where h is a small number. Write a user-defined function that calculates the derivative of a math function f(x) by using the two-point central difference formula. For the user-defined function name, use dfdx=deriv (func, x0), where func is a name for the function that is passed into deriv, and x0 is the point where the derivative is calculated. Use h = 0.001 in the two-point central difference formula. Use the user-defined function deriv to calculate the following derivatives in your main script: 1. f(x)=sin(x) at x0 = 0 2. f(x)=sin(x) at x0 = pi/2 3. f(x)=x* sin(x)e* at x0 = 0.1 4. f(x)=x* at x0 = 2.3 (Note that this is hard to compute analytically, but easy to compute with MATLAB
Expert Answer:
Answer rating: 100% (QA)
import math def derivfunc x0 h 0001 return funcx0 h funcx0 h 2 h Define the ... View the full answer
Related Book For
Posted Date:
Students also viewed these databases questions
-
Verify that it does not matter which product you use to predict the limiting reagent by using both products in this combustion reaction to determine the limiting reagent and the amount of the...
-
C. / d. Names of methods and variable should always start with: 8. upper case letter and upper case for all subsequent words . b. lower case letter and lower case for all subsequent words it does not...
-
(a) What is the symbol for a scores deviation from the mean? (b) What is the symbol for the sum of the deviations? (c) What does it mean to say the sum of the deviations around the mean equals zero?
-
What personal constructs do you rely on when perceiving the people in this photo?
-
What commodity futures are traded on futures exchanges? Who do you think could usefully reduce risk by buying each of these contracts? Who do you think might wish to sell each contract?
-
In a purely private market economy, how is the FOR WHOM question answered? Is that optimal?
-
While the electromagnetic interaction between the photons and the charged electrons and positrons kept them in equilibrium with each other during the early universe, show that the direct...
-
Marlin Company has suspected something fishy for several months. It has noticed that its profits have been slowly decreasing, while revenues have been increasing. After consulting with you, a fraud...
-
Assumethe following attributes :A, B, C, D, E, F and Gwiththe candidate key :Aand Cand the following functional dependencies : A--> B, F A, C-->D, E F --> G a. Draw the 1NF relational model and...
-
From the slide titled "Enhanced Processor w/PC Tester Circuit" from the lecture segment titled Programming a CPU with Machine Language - The Execution, implement the following division algorithm:...
-
Then the composition gof(x) is given by 1 If f(x) and g(x) x-1 X+1
-
7. Consider three five-year Treasury bonds at par ($1,000) with coupon of 2%. 4%, and 6% respectively. (a) Compute their durations. (b) What can you conclude about the relationship between duration...
-
In this assignment you are asked to translate C code to ARM64/ARMv8 assembly code, or trace assembly code. C code variables should be mapped to allocated stack frame space or ARMv8 registers in...
-
Identify and list the families of law found in Saudi Arabia over history and currently today. Explain the families of law, what those are, and how it impacts the criminal justice system of Saudi...
-
Explain how internal control work done by auditors impacts the audit risk equation. Does control risk change if the auditors are providing an opinion over internal controls? How is detection risk...
-
Kath and Kim each wish to borrow $5 million for five years, but Kath prefers to borrow at floating rate while Kim prefers fixed. However, Kath has a higher credit rating and has an absolute advantage...
-
A parallel-plate capacitor is formed of two plates, with both sides L = 13.0 cm and spaced d= 9.50 cm apart. The plates are charged to 4.80 nC. What is the potential difference across the plates?
-
Classify each of the following activities as proper or prohibited under the various consumer statutes you have studied. a. Calling a hospital room to talk to a debtor who is a patient there. b....
-
Find the volume of the solid generated by revolving the region under the graph of y = 1/(3x-x2) From x = 1 to x = 2 about (a) The x-axis (b) The y-axis
-
In Problems a-c find the Cartesian equations of the graphs of the given polar equations. a. = 1/2 b. r = 3 c. r cos + 3 = 0 d. r - 5 cos = 0
-
Prove that f is continuous at c if and only if limt0 (c + t) = f(c).
-
Calculate the ignition delay period (in deg ca) in a diesel engine using Eqns (16.15a) and (16.15b) using the conditions at the beginning of fuel injection that exist after compression in the engine...
-
This question is based on Fig. 16.9. An engine operating on an Otto cycle has a maximum peak pressure of \(60 \mathrm{bar}\). If the pressure and temperature at the beginning of the cycle are 1.0 bar...
-
Compare the air-standard cycle thermal efficiencies of an Otto cycle obtained by calculating the state points around the cycle with the value obtained from Eqn (3.16) for an 'engine' operating with a...
Study smarter with the SolutionInn App