/* muller.c -- Solve f(x)=0 by Muller's Method Written November 26, 2012 by Eric Olson for Math 701 */ #include #include #include #define N 20 typedef double complex Complex; Complex f(Complex z){ return cexp(z)+z; } Complex muller(Complex z[3],Complex w[3]){ Complex a,b,c; #ifdef MAPLE { Complex T[64]; #include "getcoef.i" } #else { Complex t0=z[0]-z[1]; Complex t1=z[0]-z[2]; Complex t2=z[1]-z[2]; Complex d=t0*t1*t2; a=w[2]; b=(t1*t1*(w[1]-w[2])+t2*t2*(w[2]-w[0]))/d; c=(t0*w[2]-t1*w[1]+t2*w[0])/d; } #endif Complex d=csqrt(b*b-4*a*c); Complex t1=b+d; Complex t2=b-d; if(cabs(t1)