// pde_sparse14.java high order discretization, // solve a4(x)*uxxxx(x) + a0(x)*u(x) = F(x) // F(x) = a4(x)*96 a0(x)*(4 x^4 + 2 x + 1) // a4(x) = x+1 a0(x) = x^2 -1 // boundary conditions computed using u(x) // with only two boundary conditions, see pde_14a_eq.java for 4 // analytic solution is u(x) = 4 x^4 + 2 x + 1 // // solve for Ui numerical approximation U(x_i) // matrix solve simultaneous equations for U // needs simeq and nderiv class pde_sparse14 { final int nx = 10; // number of X coordinates // initialize k and f including boundary sparse kf = new sparse(nx); double xg[] = new double[nx]; // uniform spacing not required, with nuderiv double cuxxxx[][] = new double[nx][nx]; // for each partial derivative in nderiv D = new nderiv(); // has rderiv double hx; // could use nuderiv double xmin = 0.2; // problem parameters double xmax = 3.3; boolean debug = false; pde_sparse14() { double x; double val, err, avgerr, maxerr; double ug[] = new double[nx]; double Ua[] = new double[nx]; double cx[] = new double[nx]; double t_start, t_init, t_kf, t_simeq, t_end; System.out.println("pde_sparse14.c running"); System.out.println("Given a4(x)*uxxxx(x) + a0(x)*u(x) = F(x)"); System.out.println(" F(x) = a4(x)*96 a0(x)*(4 x^4 + 2 x + 1) "); System.out.println(" a4(x) = x+1 a0(x) = x^2 -1"); System.out.println("with 2 boundary conditions, at least one Dirichlet"); System.out.println("xmin+hxmaxerr) maxerr = err; avgerr = avgerr + err; System.out.println("ug["+i+"]="+ ug[i]+ ", Ua="+Ua[i]+ ", err="+(ug[i]-Ua[i])); } System.out.println(" maxerr="+maxerr+", avgerr="+ avgerr/(double)(nx)); t_end = System.currentTimeMillis(); System.out.println("total took "+((t_end-t_start)/1000.0)+" seconds"); System.out.println(" "); } // end pde_sparse14 constructor void build_discrete() { // build cuxxxx[point][term] for(int i=0; i