#include <stdio.h>

#include "zersolc.h"  /* declarations of the solver C interface functions and macroses */

/********************************************************************/
/* The definition of the function: f(z) = exp(3*z) + 2*z*cos(z) - 1 */
_complex_ f (_complex_ z, void * p)
{
return cexp(3.0*z) + 2.0 * z * ccos(z) - 1.0;
}

/********************************************************************/
/* The definition of the function derivative: f'(z) = 3*exp(3*z) + 2*cos(z) - 2*z*sin(z) */
_complex_ df (_complex_ z, void * p)
{
return 3.0 * cexp(3.0*z) + 2.0 * ccos(z) - 2.0 * z * csin(z);
}

/********************************************************************/

int main (int argc, char ** argv)
{
void * solver = create_solver(f, df, 0, "", -2.0, 2.0, -2.0, 3.0);  /* pass the function and the region parameters */

int max_n_zeros = 32, n_zeros = 0;                    /* specify maximum and current number of wanted zeros */

_complex_ Z[max_n_zeros], V[max_n_zeros];             /* allocate arrays for zeros and values of the function */

find_zeros(solver, max_n_zeros, Z, V, &n_zeros);      /* the solver sets Z, V, n_zeros and returns 0 if successful */

print_status(solver, "");                             /* the solver prints information about the search status */

free_solver(solver);                                  /* free the memory allocated by the solver */

print_zeros(min(n_zeros, max_n_zeros), Z, V, stdout); /* print the content of arrays of zeros Z and function values V */

return 0;
}

/********************************************************************/