!set methtit=Addition of equations with coefficients
!set methparmtype=parm equation >,parm equation >,\
	number, number, choice 2
!set methparmrelax=5
!set methhelp=This method computes the weighted sum of two equations.\
	The result can either be added to hypotheses, or replace\
	one of the two starting equations.

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

!exit
:form
 Introduce a new equation which is <br>
 !default methparm3=1
 !default methparm4=1
 !read deduc/methparm.phtml 3,5
 times the equation
 !read deduc/methparm.phtml 1
 <br> plus
 !read deduc/methparm.phtml 4,5
 times the equation
 !read deduc/methparm.phtml 2
 <br>
 This new equation will
 !formselect methparm5 list 0,1,2 prompt \
	be added to the hypotheses,\
	replace the first one,\
	replace the second one
!exit
:check
!ifval $methparm3=0 and $methparm4=0
  error=Zero addition!
  !exit
!endif
!ifval ($methparm=1 and $methparm3=0) or \
	  ($methparm=2 and $methparm4=0)
  error=You want to replace an equation whose coefficient in the addition\
	is zero? This will make you lose information!
  !advance penalty
  !exit
!endif
!distribute items $methparmobj1 into data1,left1,sign1,right1
!distribute items $methparmobj2 into data2,left2,sign2,right2
!if $data1 issametext $data2
  error=This method prohibits the addition of an equation to itself.
  !exit
!endif
methexp=\(($methparm3)*($left1 $sign1 $right1) + ($methparm4)*($left2 $sign2 $right2))

!read deduc/sub/simplify ($methparm3)*($left1) + ($methparm4)*($left2)\
	($methparm3)*($right1) + ($methparm4)*($right2)
!distribute lines $out into newleft, newright
!if $newleft=$empty or $newright=$empty
  error=bad_data
  !exit
!endif

newobject$methparm5=$newleft = $newright
oldobject=$methparm5
forcereplace=$methparm5

!exit
