Solve f'(0) w/ MATLAB: Optimal h for f(x)=e^x

In summary, the conversation discusses writing a MATLAB program to compute the derivative of a given function using different values of h. The optimal h value is related to how close it is to the real value of the derivative. The first step is to look up the definition of a derivative. Programming experience is not necessary for this task.
  • #1
kreil
Insights Author
Gold Member
668
68

Homework Statement


Write a MATLAB program to compute f'(0) for f(x)=e^x and h=1;0.1;0.01...1E-9 using the forward and central difference formula. What is the optimal h?



The Attempt at a Solution



I have no clue how to write programs in matlab, if anyone can help me get started I would REALLY appreciate it.
 
Physics news on Phys.org
  • #2
you mean a MATLAB script right?
 
  • #3
Anyway my advice is to write a function as have h as the input, and f' as the output..
in the function, you will just write the formula as a function of h.
as for which value is optimum, well it's related to how close it is to the real value...
 
Last edited:
  • #4
Well, for staters, do you know the two expressions for the derivative that are mentioned in the assignment?

In other words, do you know how to express the derivative as each of these two kinds of differences?

- Warren
 
  • #5
no, i don't know what the formulas are
 
  • #6
Then your first step must be looking up the definition of a derivative in your textbook.

- Warren
 
  • #7
i know what a derivative is, i don't know how to program in matlab.

[tex]f'(x)=\lim_{h{\rightarrow}0}\frac{f(x+h)-f(x)}{h}[/tex]
 
  • #8
Do you know how to program at all ?
in any language?
 
  • #9

1. What is the purpose of solving f'(0) with MATLAB?

Solving f'(0) with MATLAB helps us find the optimal value of h for the function f(x)=e^x. This value can then be used to approximate the derivative of f(x) at x=0 with greater accuracy.

2. What does f'(0) represent?

f'(0) represents the derivative of the function f(x) at the point x=0. In other words, it is the slope of the tangent line to the graph of f(x) at x=0.

3. How does MATLAB help in finding the optimal h for f(x)=e^x?

MATLAB has built-in functions and algorithms that can be used to approximate the derivative of a function. By using these functions and varying the value of h, we can find the optimal h that gives us the most accurate approximation of f'(0) for the function f(x)=e^x.

4. Why is it important to find the optimal h for approximating f'(0)?

Finding the optimal h allows us to get a more accurate approximation of f'(0) for the given function. This can help us better understand the behavior of the function and make more accurate predictions and calculations.

5. Can the optimal h for f(x)=e^x be used for other functions?

No, the optimal h for f(x)=e^x is specific to this function and cannot be used for other functions. Each function may have a different optimal h value for approximating its derivative at a specific point.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • Engineering and Comp Sci Homework Help
Replies
3
Views
805
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
2K
  • Advanced Physics Homework Help
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
4K
  • Programming and Computer Science
Replies
3
Views
641
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
8K
Back
Top