!set methtit2=Divide an inequality by an expression of constant sign
!set methtit=Divide an inequality by an expression
!set methenv=ZZ QQ RR
!set methparmtype=function,parm inequality,choice,parm inequality >
!set methparmrelax=4
!set methhelp=This method transforms an inequality of type \(A > B) into\
 an equivalent inequality \(A/f > B/f) (or \(A/f < B/f)), where \(f) is an algebraic\
 expression which must be constantly positive or constantly negative.

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

!exit
:form
 Divide the inequality
!read deduc/methparm.phtml 2
 by the expression
!read deduc/methparm.phtml 1,10
 which is
!formselect methparm3 list 0,-1,1 prompt \
	$ch_choose, always negative, always positive
 because
!set ch_optional=it is a number
!read deduc/methparm.phtml 4
!exit
:check
!bound methparm3 within -1,0,1 default 0
!if $methparm3=0
  error=empty_data
  !exit
!endif
!distribute items $methparmobj2 into data,left,sign,right
!read deduc/sub/checkineq ($methparm1),=,0
ztest=$out
!if $ztest=yes
  error=Division by zero!
  !advance penalty
  !exit
!endif
!if $ztest=bad
  !if $methparm4<1
    :bad
    sens=!item ($methparm3+3)/2 of negative, positive
    error=I don't see why \($methparm1) is $sens.
    !exit
  !endif
  !distribute items $methparmobj4 into data,left2,sign2,right2
  gt=>
  lt=<
  eq=$(empty)=
  !if ($methparm3>0 and $lt isin $sign2) or \
	($methparm3<0 and $gt isin $sign2)
    !exchange left2,right2
  !endif
  sens=!item ($methparm3+3)/2 of <,>
  !if $eq notin $sign2
    sens=$sens=
  !endif
  !read deduc/sub/checkineq ($methparm1) - ($left2) + ($right2),$sens,0
  !if $out!=true
    !goto bad
  !endif
!else
  !if ($methparm1)*$methparm3<0
    error=Error of sign!
    !exit
  !endif
!endif
:OK
methexp=Divide \($left $sign $right) by \($methparm1)

!read deduc/sub/simplify ($left) / ($methparm1)\
  ($right) / ($methparm1)
!distribute lines $out into newleft,newright
!if $newleft=$empty or $newright=$empty
  error=bad_data
  !exit
!endif
!if $methparm3<0
  newsign=!translate internal <> to >< in $sign
!else
  newsign=$sign
!endif
newobject2=$newleft $newsign $newright
oldobject=2

badsign=!translate internal <> to >< in $newsign
resultlist=$newobject2,\
	$newright $newsign $newleft,\
	$newleft $badsign $newright
!exit
