!for j in 1,2
  liste=',^,(
  quote=!item 1 of $liste
  circ=!item 2 of $liste
  parenthese=!item 3 of $liste
  nb_char=!charcnt $(part_$j)
  nb_inconnues=0
  !for i from 1 to $nb_char
    caractere=!char $i of $(part_$j)
    !if $inconnue isin $caractere
      nb_inconnues=!eval $nb_inconnues+1
    !endif
  !next i
  end=!eval $nb_char+3*$nb_inconnues
  !for i from 1 to $end
    caractere=!char $i of $(part_$j)
    !if $inconnue isin $caractere
        k=!eval $i+1
        :continue
        caractere_svt=!char $k of $(part_$j)
        !if $quote isin $caractere_svt
          k=!eval $k+1
          !goto continue
        !endif
        !if $circ isin $caractere_svt
          k=!eval $k+2
        !endif
        !if $parenthese notin $caractere_svt
          interm1=!char 1 to $k-1 of $(part_$j)
          interm2=!char $k to $end of $(part_$j)
          part_$j=$interm1$xout$interm2
        !endif
    !endif
  !next i
!next j

!if $part_1 != $empty
  eq_interne = $part_1$eg$part_2
!else 
  eq_interne = $empty
!endif

!for i = 5 to 1 step -1
  prime=!word $i of ' '' ''' '''' '''''
  !if $prime isin $eq_interne
    ordre=$i
    !break
  !endif
!next i

!if $cmd!=resume and $equation!=$empty
     
  !if solgale isin $show
    solg=!exec mupad print(Unquoted,generate::TeX(op(solve(ode($eq_interne,$inconnue$xout)))));
    !if $solg!=$empty and solve notin $solg and ode notin $solg
      solg_tex=$solg
      solg=
    !else
      mess_erreur=1
    !endif
  !endif

  nbre=!itemcnt $cond_ini
  nbre_p=!itemcnt $graph_ini
  nbr_graphini=!eval $ordre-$nbre_p

  !ifval $nbre!=$ordre
    nbr_CI=!eval $ordre-$nbre
    erreur=1
    !ifval $nbr_CI < 0
      nbr_CI=!eval -$nbr_CI
    !endif
    !ifval $nbr_CI=1
      !if graphp isin $show
        anim_graph=1
      !endif graphp isin $show
    !endif $nbr_CI=1
  !endif $nbre!=$ordre

  !if solpart isin $show and $nbre!=0
    solp=!exec mupad print(Unquoted,generate::TeX(op(solve(ode({$eq_interne,$cond_ini},$inconnue$xout)))));
    !if $solp!=$empty and solve notin $solp and ode notin $solp
      solp_tex=$solp
      solp=
    !else
      mess_erreur=1
    !endif
  !endif solpart isin $show
  
  !if graphp isin $show or graphg isin $show or p_anim isin $show or p_fix isin $show
    abs_min=!eval $abs_min
    abs_max=!eval $abs_max
    !if $abs_min>=$abs_max
      abs_min=$default_abs_min
      abs_max=$default_abs_max
    !endif
    abscisses=[$abs_min : $abs_max]
    ord_min=!eval $ord_min
    ord_max=!eval $ord_max
    !if $ord_min>=$ord_max
      ord_min=$default_ord_min
      ord_max=$default_ord_max
    !endif
    !if $ord_max>$ord_min
      ordonnees=[ $ord_min : $ord_max]
    !else
      ordonnees=
    !endif
  !endif graphp isin $show or graphg isin $show or p_anim isin $show or p_fix isin $show

  !if graphg isin $show
    solg=!exec mupad op(solve(ode($eq_interne,$inconnue$xout)));
    !if solve notin $solg and ode notin $solg and sum notin $solg
      solgraph=$solg
      !if x isin $inconnue
        solgraph=!mathsubst x=y in $solgraph
      !endif
      !if t isin $xout
        solgraph=!mathsubst t=x in $solgraph
      !endif
      !for i = 1 to $nb_courbes
        j=!randitem $i,-$i 
        interm_$i=!replace C1 by $j in $solgraph
        !for l from 2 to 5
          interm_$i=!replace C$l by 1 in $(interm_$i)
        !next l
        !for k from 6 to 10
          interm_$i=!replace C$k by -1 in $(interm_$i)
        !next k
      !next i
      solgraph=$interm_1 title"",
      !for i from 2 to $nb_courbes-1
        solgraph=$solgraph$(interm_$i) title"",
      !next i
      solgraph=$solgraph$(interm_$nb_courbes) title""
    !else
      mess_erreur=1
    !endif solve notin $solg and ode notin $solg and sum notin $solg
  !endif graphg isin $show

  !if graphp isin $show
    !ifval $anim_graph=1
      !ifval $ordre=1
        solp=!exec mupad op(solve(ode($eq_interne,$inconnue$xout)));
      !else
        solp=!exec mupad op(solve(ode({$eq_interne,$cond_ini},$inconnue$xout)));
      !endif
      ins_anim_frames=70
      ins_anim_delay=0.04
      solgraph=!replace C$ordre by (-20+40*s) in $solp
    !else
      solp=!exec mupad op(solve(ode({$eq_interne,$cond_ini},$inconnue$xout)));
      !if solve notin $solp and ode notin $solp and sum notin $solp
        solgraph=$solp
      !endif solve notin $solp and ode notin $solp and sum notin $solp
    !endif $anim_graph=1
    !if x isin $inconnue
      solgraph=!mathsubst x=y in $solgraph
    !endif
    !if t isin $xout
      solgraph=!mathsubst t=x in $solgraph
    !endif
  !endif graphp isin $show

  !if p_anim isin $show
    !if $graph_ini!=$empty
      !ifval $nbr_graphini=0
        solp=!exec mupad op(solve(ode({$eq_interne,$graph_ini},$inconnue$xout)));
        !if solve notin $solp and ode notin $solp and sum notin $solp
          solgraph=$solp
          !if x isin $inconnue
            solgraph=!mathsubst x=y in $solgraph
          !endif
          !if t isin $xout
            solgraph=!mathsubst t=x in $solgraph
          !endif
          ins_anim_frames=70
          ins_anim_delay=0.04
          solgraph=!mathsubst s=(($s_max-$s_min)*s+$s_min) in $solgraph
        !else
          mess_erreur=1
        !endif solve notin $solp and ode notin $solp and sum notin $solp
      !else
        erreur=2
      !endif $nbr_graphini=0 
    !else
      erreur=3
    !endif $graph_ini!=$empty
  !endif p_anim isin $show

  !if p_fix isin $show
    !ifval $nbr_CI=0
      solp=!exec mupad op(solve(ode({$eq_interne,$cond_ini},$inconnue$xout)));
      !if solve notin $solp and ode notin $solp and sum notin $solp
        solgraph=$solp
        !if x isin $inconnue
          solgraph=!mathsubst x=y in $solgraph
        !endif
        !if t isin $xout
          solgraph=!mathsubst t=x in $solgraph
        !endif
      !else
        mess_erreur=1
      !endif solve notin $solp and ode notin $solp and sum notin $solp
    !else
      erreur=1
    !endif $nbr_CI=0    
  !endif p_fix isin $show

!endif $cmd!=resume and $eq!=$empty
