load("Eulix.mac")$

/* 
  y' =  2 * t * y * log(z)    y(0)=1
  z' = -2 * t * z * log(y)    z(0)=%e
  
  exact solution  y(t)=exp(sin(t^2))  z(t)=exp(cos(t^2))
*/

solution(t):= [exp(sin(t^2)),exp(cos(t^2))]$
high_precision: true$

if high_precision then (
  fpprec:40,
  t0:bfloat(1/10),
  y0:solution(t0),
  atol:1e-30,  rtol:1e-28,
  /* h:1b-3, */
  me:20,
  if true then
    mass_matrix:bfloat(ident(2)) /* must be either 'false or a square mass matrix 
                                 = ident(dim) for an ODE with trivial mass matrix */
  else mass_matrix:false

) else (

  t0:0.1,
  y0:solution(t0),
  atol:1e-10,  rtol:1e-8,
  /* h:0.1, */
  mass_matrix: ident(2), /* must be either 'false or a square mass matrix 
                         = ident(dim) for an ODE with trivial mass matrix */
  me:6
)$

/* debugmode:true$ */

Logging:false$

[tlist,ylist]:Eulix([2*t*y*log(z),-2*t*z*log(y)],[y,z],y0,[t,t0,sqrt(float(%pi)),0.5],
                    logging=Logging,'absolute_tolerance=atol,'relative_tolerance=rtol,
                    combined_t_y_list=false)$
maxabs(L1,L2):= max(abs(first(L1)-first(L2)),abs(second(L1)-second(L2)))$
for i:1 thru length(tlist) do (
  printf(true,"t: ~7,4f  err: ~13,6e ~%",tlist[i],maxabs(ylist[i],solution(tlist[i])))
)$
