// ---------------------------- // ziftest.cpp // ---------------------------- #include "ww.h" #include "zif.h" class gfun : public fun { public: gfun() {} double f(double x) { return (cos(x) - x); } }; // -------------------------------------------------- void main() { nl(); banner("Ziftest"); pl("f(x) = cos(x) - x"); nl(); gfun *g = new gfun(); precision(14); double z = zef(g,0.5,0.001,1e-10); pl("The zero of g is z = ",z); pl("Check: g(z) = ",g->f(z)); }