Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
I am having trouble coding this problem. Any help would be appreciated.
Implement in a matlab .m file a function whose prototype is:
function [xroot,count] = secant( f, x0, tol, maxit)
This function should have a help section similar to newtn. Your function should be implemented so that the user can either provide just f and x0, using the default value of tol = 1.0e-8 and maxit = 20, or provide f, x0, and tol, using the default value of maxit = 20, or provide f, x0, tol, and maxit. The parameter f is a function handle to some function whose root is desired, and x0 is an initial guess. The optional parameters are tol: stopping tolerance for the iteration, and maxit: the maximum number of iterations allowed.
The function secant will attempt to find a root of f, xroot, using the secant method.
Use your secant function to find the equilibrium position of the spring-tension problem described in class and whose function file (equilibrium.m) would begin like this:
function y = equilibrium(x)
% computes the net force in the x-direction:
% y = 4*(sqrt(9+x^2) -3)
0 · ·