duffing_eq.h
/*------------------------------------------------------------------------------------
ダフィング方程式から得られるジャパニーズ・アトラクタ
Japanese attractor derived from the Duffing equations
dx/dt = y
dy/dt = -K * y - x^3 + B * cos(t)
duffing_eqs.h
------------------------------------------------------------------------------------*/
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
// #define ITERATION 100 /* 全ての軌跡が欲しいとき when we want all trajectories */
// #define ITERATION 60000 /* ジャパニーズ・アトラクタ(2π毎のデータ) Japanese attractor (data for every 2 * PI) */
#define ITERATION 100000 /* ジャパニーズ・アトラクタ(2π毎のデータ) Japanese attractor (data for every 2 * PI) */
#define SKIPS 1000
#define DIV 1000 /* 1周期(2π)の分割数 Number of divisions in one cycle ( 2 * PI) */
#define PHASE_DEGREE 0
// 45と設定した場合は、位相の角度が45度の意味
// If set to 45, it means the phase angle is 45 degrees
// 0 <= PHASE_DEGREE < 360
// parameters
#define K 0.05
#define B 7.5
// 初期値
// initial values
#define X0 0.2
#define Y0 0.1
#define DELTA_T 2.0 * M_PI/(double)DIV /* step size of the fourth-order Runge-Kutta method */
/*--------------------------------------------------------------------------*/
extern double fx( double t, double x, double y );
extern double fy( double t, double x, double y);
extern void duffing_RK4( double t, double *x, double *y );