def s2(Q,P,B) { return [Q+B/P,P]; } def t2(Q,P,B) { return [-Q,-P+2*Q^2+t]; } def p2check(F,B) { G=-diff(F,[t,t])+2*F^3+t*F+B-1/2; return red(G); } def test() { Y=0; print(p2check(Y,1/2)); Y = s2(0,t/2,1/2); Y0=subst(Y[0],t,x); print("Solution is ",0); print(Y0); gnuplot.gnuplot("plot [-5:5] "+rtostr(Y0)+";"); print(p2check(Y[0],-1/2)); } def test2() { Y=0; Y = s2(0,t/2,1/2); Y = t2(Y[0],Y[1],-1/2); Y = s2(Y[0],Y[1],3/2); print(p2check(Y[0],-3/2)); Y0=subst(Y[0],t,x); print("Solution is ",0); print(Y0); ctrl("fortran_output",1); gnuplot.gnuplot("plot [0.2:20] "+rtostr(Y0)+";"); ctrl("fortran_output",0); } end$