1 /* Problem 2 for colnew */
9 xt : sqrt(2*(gamma-1)/gamma);
11 /* Number of differential equations */
20 /* Locations of side conditions */
21 zeta : float([0, 0, 1, 1]);
23 /* Set up parameter array. */
24 ipar : makelist(0,k,1,11);
27 /* 4 collocation points per subinterval */
29 /* Initial uniform mesh of 10 subintervals */
32 /* Size of fspace, ispace */
37 /* Initial approx is provided */
41 /* No fixed points in mesh */
43 /* Tolerances on all components */
46 /* Two error tolerances (on u and its second derivative */
48 tol : [1d-5, 1d-5, 1d-5, 1d-5];
50 fspace : makelist(0d0, k, 1, 40000)$
51 ispace : makelist(0, k, 1, 2500)$
54 /* Define the equations */
55 fsub(x, z1, z2, z3, z4) := [z1/x/x - z2/x + (z1-z3*(1-z1/x) - gamma*x*(1-x*x/2))/eps4mu,
56 z3/x/x - z4/x + z1*(1-z1/2/x)/dmu];
57 df : jacobian(fsub(x,z1, z2, z3, z4),[z1,z2,z3,z4]);
58 dfsub(x, z1, z2, z3, z4) :=
59 subst(['x=x,'z1=z1,'z2=z2,'z3=z3,'z4=z4], df);
60 g(z1, z2, z3, z4) := [z1, z3, z1, z4 - 0.3*z3 + .7];
61 gsub(i, z1, z2, z3, z4) :=
62 subst(['z1=z1,'z2=z2,'z3=z3,'z4=z4], g(z1, z2, z3, z4)[i]);
63 dg:jacobian(g(z1, z2, z3, z4), [z1,z2,z3,z4]);
64 dgsub(i, z1, z2, z3, z4) := subst(['z1=z1,'z2=z2,'z3=z3,'z4=z4], row(dg, i)[1]);
67 block([cons : gamma*x*(1-0.5*x*x),
68 dcons : gamma*(1-1.5*x*x),
71 [[0, 0, -cons, -dcons],
74 [[2*x, 2, -2*x + cons, -2 + dcons],
77 [iflag, fspace, ispace] :
78 colnew_expert(ncomp, m, aleft, aright, zeta, ipar, ltol, tol, fixpnt, ispace, fspace,
79 0, fsub, dfsub, gsub, dgsub, solutn);
81 /* Print values of solution at x = 0,.05,...,1 */
85 zval : colnew_appsln([x], 4, fspace, ispace)[1],
86 printf(true, "~5,2f ~{~15,5e~}~%", x, zval),