#include <stdlib.h>	/* atof */
#include <string.h>	/* strcmp */
#include "de.h"
#define mu p[0]
#define x0 v0[0]
#define y0 v0[1]
#define x1 v1[0]
#define y1 v1[1]
#define gm_F(x) (mu*x + 2*(1-mu)*x*x/(1+x*x))
void gm_init(double p[], double v0[])
{
  mu = 0.8;
  x0 = 0.1; y0 = 0.0;
}
void gm_map(double p[], double t, double v0[], double v1[])
{
  x1 = y0 + 0.008*(1 - 0.05*y0*y0)*y0 + gm_F(x0);
  y1 = -x0 + gm_F(x1);
}
void gm_options(int argc, char *argv[], double p[], double v0[])
{
  int i;

  for (i=1; i<argc; i++)
    if (strcmp(argv[i], "-mu") == 0 && i+1 < argc)
      mu = atof(argv[i+1]);
    else if (strcmp(argv[i], "-x") == 0 && i+1 < argc)
      x0 = atof(argv[i+1]);
    else if (strcmp(argv[i], "-y") == 0 && i+1 < argc)
      y0 = atof(argv[i+1]);
}
struct de gm_de = {
  1, 2, gm_init, gm_options, gm_map,
};
