Comparison of advanced PDE solver (apde) and ordinary one (pde).
MGL code:
ranges -1 1 0 2 0 2 new ar 256 'exp(-2*(x+0.0)^2)' new ai 256 apde res1 'exp(-x^2-p^2)' ar ai 0.01:transpose res1 pde res2 'exp(-x^2-p^2)' ar ai 0.01 subplot 1 2 0 '_':title 'Advanced PDE solver' ranges 0 2 -1 1:crange res1 dens res1:box axis:xlabel '\i z':ylabel '\i x' text -0.5 0.2 'i\partial_z\i u = exp(-\i x^2+\partial_x^2)[\i u]' 'y' subplot 1 2 1 '_':title 'Simplified PDE solver' dens res2:box axis:xlabel '\i z':ylabel '\i x' text -0.5 0.2 'i\partial_z\i u \approx\ exp(-\i x^2)\i u+exp(\partial_x^2)[\i u]' 'y'
C++ code:
void smgl_apde(mglGraph *gr) { gr->SetRanges(-1,1,0,2,0,2); mglData ar(256), ai(256); gr->Fill(ar,"exp(-2*(x+0.0)^2)"); mglData res1(gr->APDE("exp(-x^2-p^2)",ar,ai,0.01)); res1.Transpose(); mglData res2(gr->PDE("exp(-x^2-p^2)",ar,ai,0.01)); gr->SubPlot(1,2,0,"_"); gr->Title("Advanced PDE solver"); gr->SetRanges(0,2,-1,1); gr->SetRange('c',res1); gr->Dens(res1); gr->Axis(); gr->Box(); gr->Label('x',"\\i z"); gr->Label('y',"\\i x"); gr->Puts(mglPoint(-0.5,0.2),"i\\partial_z\\i u = exp(-\\i x^2+\\partial_x^2)[\\i u]","y"); gr->SubPlot(1,2,1,"_"); gr->Title("Simplified PDE solver"); gr->Dens(res2); gr->Axis(); gr->Box(); gr->Label('x',"\\i z"); gr->Label('y',"\\i x"); gr->Puts(mglPoint(-0.5,0.2),"i\\partial_z\\i u \\approx\\ exp(-\\i x^2)\\i u+exp(\\partial_x^2)[\\i u]","y"); }