!set methtit=Dividir una integración en dos
!set methenv=ZZ QQ RR
!set methparmtype=parm function integrate, function
!set methhelp=Este método permite escribir \(integrate(A+B,t)) como\
 \(integrate(A,t) + integrate(B,t)).

!if $wims_read_parm iswordof form check
  !goto $wims_read_parm
!endif

!exit
:form
!set N=!linecnt $mtobj1
!reset methparm3
!if $N>1 and $methsubstep=1
  :first
  !set methsubstep=2
  Elija la integral a cortar:
  <p>
  !read deduc/methparm.phtml 1
  </p>
!else
  !bound methparm1 between integer 0 and $N default 1
  !if $methparm1=0 or $error!=$empty
    !goto first
  !endif
  <input type="hidden" name="methparm1" value="$methparm1">
  !set methsubstep=1
  !set l=!line $methparm1 of $mtobj1
  !set l=!item 2 to -1 of $l
  !set k=!mathsubst integrate= in $l
  !set k=!declosing $k
  !set v=!item 2 of $k
  Écrire \($l = integrate(f1($v),$v) + integrate(f2($v),$v)), où
  <p>
  \(f1($v) = ) <input size="30" name="methparm2" value="$methparm2"> (obligatoire), <br>
  \(f2($v) = ) <input size="30" name="methparm3"> (facultative).
  </p>
!endif
!exit
:check
ker=!item 2 of $methparmobj1
ker=!mathsubst integrate= in $ker
ker=!trim $ker
ker=!declosing $ker
!distribute items $ker into iker,ivar
vartest=!varlist $ivar
!if $ivar != $vartest
  error=Fail
  !exit
!endif

!if $methparm3=$empty
  !read deduc/sub/simplify ($iker)-($methparm2)
  !if $out=$empty
    error=bad_data
    !exit
  !endif
  methparm3=$out
!else
  wims_rawmath_variables=$variables
  methparm3=!rawmath $methparm3
!endif
!read deduc/sub/checkzero ($iker)-($methparm2)-($methparm3)
!if $out=$empty
  error=bad_dataSuma incorrecta. Corrija por favor.
  !exit
!endif
!if $out!=yes
  error=Suma incorrecta. Corrija por favor.
  !exit
!endif

newobject1=(integrate($methparm2,$ivar)+integrate($methparm3,$ivar))
oldobject=1
!reset methparm3
methexp=
!exit
