Clear Filters
Clear Filters

How to use finite difference to find slope for a function?

2 views (last 30 days)
I have a function F(x)=x^2 + x - 10, how can I creat code for forward, back ward and central finite difference approximation of the slope ? I don't know where can I start.
dpb on 16 Feb 2021
Start buy defining the function...
fnF=@(x)x.^2 + x - 10;
Then you have to evaluate the function over whatever range of x you're interested in before doing differences of any sort.
wenchong chen
wenchong chen on 19 Feb 2021
I only got how to find slope for a point, how to find slop for (-1 to 1) in finite difference approximation?

Sign in to comment.

Answers (1)

Shubham Khatri
Shubham Khatri on 21 Feb 2021
I have used forward finite difference approximation to design the following code for the purpose.
h=0.1; % step's size
N=10; % number of steps
for n=1:20
y(n+1)= y(n)+h*(4*y(n) + 41)^(0.5);
x = -1:0.1:1.1;
Hope it helps


Find more on Creating and Concatenating Matrices in Help Center and File Exchange


Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!