Hi everyone, I'm trying to write a function that finds a point at
which two functions f(x) and g(x) intersect, i.e., f(x) = g(x). I'm using
Newton's Method and making and h(x)=f(x)-g(x) and h'(x) as well, but I'm not getting the right x-value. Please help me debug my code!
% function x = fgIntersect(f, df, g, dg, x0, tol, maxIter)
h=f(x0)-g(x0)dh=df(x0)-dg(x0)k=1;while k<=maxIterx=x0-h/dh;if abs(x-x0)<tol*abs(x)returnendx0=x;k=k+1;endend
Best Answer