4 y1' = -0.04*y1 + 1E4*y2*y3 y1(0)= 1
5 y2' = 0.04*y1 - 1E4*y2*y3 -3E7*y2^2 y2(0)= 0
6 y3' = 3E7*y2^2 y3(0)= 0
9 Rhs(t,y):= matrix([ -0.04*y[1,1] + 1E4*y[2,1]*y[3,1]],
10 [ 0.04*y[1,1] - 1E4*y[2,1]*y[3,1] -3E7*y[2,1]^2],
13 define(Rhs_Time('t,'y),diff(Rhs('t,'y),'t))$
15 gen_jacobian(F,xx,Fdim)::= block([i,n:ev(Fdim),J,X:ev(xx)],
17 mynumer: if fpprec <= 16 then 'float else 'bfloat, declare(mynumer,evfun),
18 J: genmatrix(lambda([i,j],ev(diff(F(X,_y)[i,1],_y[j,1]),diff,mynumer)),n,n),
19 buildq([J,t:X],lambda([t,_y],J))
22 Rhs_Jac:gen_jacobian(Rhs,t,3)$
24 compile(Rhs,Rhs_Time)$
28 y0:matrix([1],[0],[0])$
31 mass_matrix: ident(3)$ /* must be either 'false or a square mass matrix
32 = ident(dim) for an ODE with trivial mass matrix */
38 Start:elapsed_real_time()$
44 [DO_DQ,tn,hn,me,failed]: Eulix_Step(y,t,Rhs,Rhs_Time,Rhs_Jac,h,me, dense_output=dense_out,
45 absolute_tolerance=atol,relative_tolerance=rtol,
46 'mass_matrix=mass_matrix,check_parameters=Check_Parm,
49 h: tn-t, /* <<<< in case of reject within Eulix */
51 printf(true,"Eulix failed at t: ~7,4f~%",t),
54 if dense_out then ( /* dense_output=true */
55 printf(true,"t: ~7,4f hn: ~10,8f me:~2d y1=~13,6e y2=~13,6e y3=~13,6e~%",
56 tn, hn, me, y[1,1], y[2,1], y[3,1]),
57 y:copymatrix(DO_DQ[1])
58 ) else y:copymatrix(DO_DQ),
59 printf(true,"t: ~7,4f hn: ~10,8f me:~2d y1=~13,6e y2=~13,6e y3=~13,6e~%",
60 tn, hn, me, y[1,1], y[2,1], y[3,1]),