Question

MATLAB please Required information Consider the forward finite-difference, centered finite-difference, and backward finite-difference formulas given below with O(h^2), respectively. Forward finite-difference formula: dy/dx ≈ (y(i+1) - y(i)) / h Centered finite-difference formula: dy/dx ≈ (y(i+1) - y(i-1)) / (2h) Backward finite-difference formula: dy/dx ≈ (y(i) - y(i-1)) / h Second derivative formulas: Forward finite-difference formula: d^2y/dx^2 ≈ (y(i+2) - 2y(i+1) + y(i)) / h^2 Centered finite-difference formula: d^2y/dx^2 ≈ (y(i+1) - 2y(i) + y(i-1)) / h^2 Backward finite-difference formula: d^2y/dx^2 ≈ (y(i) - 2y(i-1) + y(i-2)) / h^2 Develop an M-file function that computes first- and second-derivative estimates of order O(h^2) based on the given formulas. The function's first line should be set up as function [dydx, d2ydx2] = diffeq(x,y) where x and y are input vectors of length n containing the values of the independent and dependent variables, respectively, and dydx and d2ydx2 are output vectors of length n containing the first-derivative and second-derivative estimates at each value of the independent variable. The function should generate a plot of dydx and d2ydx2 versus x. Have your M-file return an error message if the input vectors are not the same length, or the values for the independent variable are not equally spaced. (Please upload your response/solution using the controls below.)

          MATLAB please

Required information

Consider the forward finite-difference, centered finite-difference, and backward finite-difference formulas given below with O(h^2), respectively.

Forward finite-difference formula:
dy/dx ≈ (y(i+1) - y(i)) / h

Centered finite-difference formula:
dy/dx ≈ (y(i+1) - y(i-1)) / (2h)

Backward finite-difference formula:
dy/dx ≈ (y(i) - y(i-1)) / h

Second derivative formulas:

Forward finite-difference formula:
d^2y/dx^2 ≈ (y(i+2) - 2y(i+1) + y(i)) / h^2

Centered finite-difference formula:
d^2y/dx^2 ≈ (y(i+1) - 2y(i) + y(i-1)) / h^2

Backward finite-difference formula:
d^2y/dx^2 ≈ (y(i) - 2y(i-1) + y(i-2)) / h^2

Develop an M-file function that computes first- and second-derivative estimates of order O(h^2) based on the given formulas. The function's first line should be set up as function [dydx, d2ydx2] = diffeq(x,y) where x and y are input vectors of length n containing the values of the independent and dependent variables, respectively, and dydx and d2ydx2 are output vectors of length n containing the first-derivative and second-derivative estimates at each value of the independent variable. The function should generate a plot of dydx and d2ydx2 versus x. Have your M-file return an error message if the input vectors are not the same length, or the values for the independent variable are not equally spaced.

(Please upload your response/solution using the controls below.)
        
Show more…
matlab please requiredinformation consider the forward finite differencecentered finite differenceand backward finite difference formulas given below with oh2respectively 2h h2 2h h2 2h h2 d 80814

Added by Donna C.

Close

Computer Science and Information Technology
Computer Science and Information Technology
Trishna Knowledge Systems 2018 Edition
AceChat toggle button
Close icon
Ace pointing down

Please give Ace some feedback

Your feedback will help us improve your experience

Thumb up icon Thumb down icon
Thanks for your feedback!
Profile picture
MATLAB please Required information Consider the forward finite-difference, centered finite-difference, and backward finite-difference formulas given below with O(h^2), respectively. Forward finite-difference formula: dy/dx ≈ (y(i+1) - y(i)) / h Centered finite-difference formula: dy/dx ≈ (y(i+1) - y(i-1)) / (2h) Backward finite-difference formula: dy/dx ≈ (y(i) - y(i-1)) / h Second derivative formulas: Forward finite-difference formula: d^2y/dx^2 ≈ (y(i+2) - 2y(i+1) + y(i)) / h^2 Centered finite-difference formula: d^2y/dx^2 ≈ (y(i+1) - 2y(i) + y(i-1)) / h^2 Backward finite-difference formula: d^2y/dx^2 ≈ (y(i) - 2y(i-1) + y(i-2)) / h^2 Develop an M-file function that computes first- and second-derivative estimates of order O(h^2) based on the given formulas. The function's first line should be set up as function [dydx, d2ydx2] = diffeq(x,y) where x and y are input vectors of length n containing the values of the independent and dependent variables, respectively, and dydx and d2ydx2 are output vectors of length n containing the first-derivative and second-derivative estimates at each value of the independent variable. The function should generate a plot of dydx and d2ydx2 versus x. Have your M-file return an error message if the input vectors are not the same length, or the values for the independent variable are not equally spaced. (Please upload your response/solution using the controls below.)
Close icon
Play audio
Feedback
Powered by NumerAI
David Collins Ivan Kochetkov
Kathleen Carty verified

Sri K and 78 other subject AP CS educators are ready to help you.

Ask a new question

*

Labs

-

Want to see this concept in action?

NEW

Explore this concept interactively to see how it behaves as you change inputs.

View Labs

*

Key Concepts

-
Key Concept
Premium Feature
Explore the core concept behind this problem.
Play button
Key Concept
Premium Feature
Explore the core concept behind this problem.
Your browser does not support the video tag.

*

Recommended Videos

-
6-write-a-matlab-function-called-finidifflstm-to-compute-the-first-derivatives-via-finite-difference-of-any-given-vector-dataset-where-the-inputs-of-the-function-are-the-dataset-write-a-simi-16172

(b) Write a MATLAB function called "FiniDiff1st.m" to compute the first derivatives via finite difference of any given vector dataset, where the inputs of the function are the dataset. Write a similar MATLAB function called "FiniDiff2nd.m" to compute the second derivatives via finite difference of the given vector dataset. Note that the sampling rate of the dataset is 100 Hz, therefore h = ́dt = 0.01s. You should setup the step size within the functions. Hint: Consider using different finite difference methods on the first and last data points, and middle points. (c) Use the MATLAB functions you wrote to perform finite difference on the position data to compute the (x, y) components of the velocity and acceleration of the UAV. Then calculate the UAV speed and the magnitude of acceleration via the following equations: s = ∑∑(V_x^2 + V_y^2), a = ∑∑(a_x^2 + a_y^2) Note that the sampling rate of the dataset is 100 Hz, therefore h = ́dt = 0.01s. (d) Plot the computed s and a in one figure. Find out the maximum speed and acceleration (using MATLAB's max() function) and display them on screen.

Sri K.

write-a-code-to-approximate-the-derivative-of-a-function-fx-using-forward-finite-difference-quotient-f-x-h-f-x-fx-for-small-h-h-for-the-function-fx-sinx-at-x1-compute-the-fd-quotients-for-h-70858

Write a code to approximate the derivative of a function f(x) using forward finite difference quotient f( x + h ) - f( x ) f'(x) ≈ ------------------- (for small h). h For the function f(x) = sin(x), at x=1 , compute the FD quotients for h = 1/2k, k=5,...,N, with N=30 and compare with the exact derivative cos(x). Output k , h , error. Where SHOULD the error tend as h → 0 ? 1. Look at the numbers. Does the error behave as expected ? Output to a file "out" (or to arrays in matlab), and plot it [ gnuplot> plot "out" u 2:3 with lines ] Which direction is the curve traversed, left to right or right to left ? Look at the numbers. h is decreasing exponentially, so the points pile up on the vertical axis. The plot is poorely scaled. To see what's happening, use logarithmic scale, i.e. output k , log(h) , log(error) and replot. 2. What is the minimum error ? at what k ? Why does the error get worse for smaller h ? 3. Repeat, using centered finite differences [copy your code to a another file and modify it] f( x + h ) - f( x - h ) f'(x) ≈ ----------------------- (for small h). 2 h 4. Which formula performs better ? in what sense ?

Sri K.

write-single-script-which-does-each-of-the-following-in-turn-make-sure-you-run-the-script-in-order-t0-see-the-results-and-possible-errorsl-before-submitting-itl-plot-the-function-f-xy-vx-y-a-05791

Write a single script which does each of the following in turn. Make sure you run the script in order to see the results (and possible errors!) before submitting it! 1. Plot the function f(x, y) = ∑∑x² + y² and assign the result to q1. 2. Plot the function f(x, y) = cos(x² + y²) / e^(x² + y²) and assign the result to q2. 3. Find the derivative ∂²/∂x∂y (x³y² / (x - cos(y))) and assign the result to q3. 4. Assign g(x, y) = xy / (x² + y²) and calculate f_yxx(1.2, 3.8) (triple derivative!) and assign the result to q4. 5. Assign f(x, y) = x - xy² + ∑y. Find ∇f(2, 9) and assign the result to q5. You'll need subs, too. 6. Find the directional derivative of f(x, y) = x/y + sin(xy) in the direction of u = 3i - 2j and assign the result to q6. 7. Find all critical points for f(x, y) = (y - 2) ln(xy). In Matlab ln is done with log. Assign the result to [q7x, q7y]. 8. Use Lagrange multipliers to find the maximum and minimum values of f(x, y) = xy² subject to the constraint x² + y² = 16. Assign the second-to-last line to [q8L, q8x, q8y] and the last line to q8f.

Sri K.


*

Recommended Textbooks

-
Computer Science and Information Technology

Computer Science and Information Technology

Trishna Knowledge Systems 2018 Edition
achievement 1,724 solutions
Introduction to Programming Using Python

Introduction to Programming Using Python

Y. Daniel Liang 1st Edition
achievement 1,372 solutions
Computer Science - An Overview

Computer Science - An Overview

Glenn Brookshear, Dennis Brylow 12th Edition
achievement 1,773 solutions

*

Transcript

-
00:01 Q is equal to q into p q minus c into q so p into q is equal to q into minus 1 .9 q plus 890 minus 130 q plus 48 4 .0 1 .9 q square…
Need help? Use Ace
Ace is your personal tutor. It breaks down any question with clear steps so you can learn.
Start Using Ace
Ace is your personal tutor for learning
Step-by-step explanations
Instant summaries
Summarize YouTube videos
Understand textbook images or PDFs
Study tools like quizzes and flashcards
Listen to your notes as a podcast
Continue solving this problem
Create a free account to:
  • View full step-by-step solution
  • Ask follow-up questions with Ace AI
  • Save progress and study later
Continue Free
Numerade

Get step-by-step video solution
from top educators

Continue with Clever
or



By creating an account, you agree to the Terms of Service and Privacy Policy
Already have an account? Log In

A free answer
just for you

Watch the video solution with this free unlock.

Numerade

Log in to watch this video
...and 100,000,000 more!


EMAIL

PASSWORD

OR
Continue with Clever