How to find the intersections between two functions by using "fzero"? Take for example these two functions: f(x) = exp(-x^2 / 2) and g(x) = x^2 -3x + 2. How to find the intersections between them by using fzero?
Thanks so much!

댓글 수: 1

It's a horrible homework question. To find all of the intersections, you must know how many to search for and where. It is easy to show that,
g(x)<=1<f(x)
outside the interval [0.3,2.7] and therefore any intersections have to happen in this interval. It is also clear from the plot below that f(x)-g(x)=0 has at least two roots in this interval. However, how do you know that there aren't more, lurking unsampled between the points shown in the plot?

댓글을 달려면 로그인하십시오.

답변 (1개)

John D'Errico
John D'Errico 2017년 11월 9일

3 개 추천

1. Create a new function that is the difference of them. I'll give you this one, because many people misunderstand how to use function handles.
f = @(x) exp(-x.^2/2);
g = @(x) x.^2 - 3*x +2;
h = @(x) g(x) - f(x);
2. Use fzero. You need to expend some thought here. Read the help for fzero.
WTP?

카테고리

태그

질문:

2017년 11월 9일

댓글:

2017년 11월 9일

Community Treasure Hunt

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

Start Hunting!

Translated by