!set methtit=变量的逆替换
!set methenv=ZZ QQ RR
!set methparmtype=parm function integrate, function, function
!set methhelp=本方法对不定积分应用变量逆替换.

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

!exit
:form
 !set N=!linecnt $mtobj1
 !if $N>1 and $methsubstep=1
  :first
  !set methsubstep=2
  施行变量逆替换: <p>
  !read deduc/methparm.phtml 1
 !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
  !set nvar=!item 1 of $newvariables
 对 \($l) 作变量逆替换: 令 <br>
  \($nvar = h($v) = )
  !read deduc/methparm.phtml 2,18
, 可得
   <div class="wimscenter">
    \($l = integrate(f(h($v))h'($v)d$v) = integrate(f($nvar)d$nvar)) ,
  </div>
  其中
  \(f($nvar) = )
  !read deduc/methparm.phtml 3,36
.
 !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=失败
  !exit
 !endif

 newvar=!item 1 of $newvariables
 vv=!varlist nofn $methparm2
 vtest=!listcomplement $ivar,e,pi,euler in $vv
 !if $vtest!=$empty
  error=\(h($ivar)) 只能是 \($ivar) 的函数.
  !exit
 !endif
 hprime=!exec maxima diff($methparm2,$ivar);
 !if $hprime=$empty
  :bad_data
  error=bad_data
  !exit
 !endif
 vv=!varlist nofn $methparm3
 vtest=!listcomplement $newvar,e,pi,euler in $vv
 !if $vtest!=$empty
  error=\(f($newvar)) 只能是 \($newvar) 的函数.
  !exit
 !endif
 substed=!mathsubst $newvar=($methparm2) in $methparm3
 !read deduc/sub/checkzero ($substed)*($hprime)-($iker)\
    diff($methparm3,$newvar)
 !distribute lines $out into ztest,difftest
 !if $ztest=$empty or $difftest=$empty
  !goto bad_data
 !endif
 !if $ztest!=yes
  error=把错误公式应用于变量替换!
  !advance penalty
  !exit
 !endif

 !read deduc/sub/simplify $methparm3\
    ($methparm3)*($newvar)
 !distribute lines $out into newker,res
 !if $newker=$empty or $res=$empty
  !goto bad_data
 !endif
 !if strictintegrate iswordof $m_options and $difftest=yes
  error=你不能把 \(f($newvar)) 取成常数. \
    请换一个方法.
  !exit
 !endif

 !if $difftest=yes
  newobject1=($res)
 !else
  newobject1=integrate($newker,$newvar)
 !endif
 oldobject=0,1
 newobject0=$newvar=$methparm2
 methexp=\($newvar=$methparm2)
 variables=$variables,$newvar
!exit

