binsearch
*find the operating boundary between the two given points (pc and po)
*the variable dim and the arrays pc and po are already initialized
*vector-wise arithmetic is done here
.control

echo > point

*point on plane should work if region is convex
param=pc
$circuitparam
source $circuitcirc
chFAIL=0
$passfail
echo $&chFAIL >> point


if chFAIL=0

*find margin
param=po
delta=po-po
$circuitparam
source $circuitcirc
chFAIL=0
$passfail

if chFAIL=1
*the margin edge is in the specified range (else "pegged")

	delta=(po-pc)/2
	let param=param-delta
	while (delta[0]>accuracy)
		delta=delta/2
		$circuitparam
                source $circuitcirc
		chFAIL=0
		$passfail
		if chFAIL=1
*get narrower
                        echo 
                        echo RESULT: TEST FAILED
                        echo

			param=param-delta
		else
*get wider
                        echo 
                        echo RESULT: TEST PASSED
                        echo 

			param=param+delta
		end
	end
end


*param equals value between known pass and fail values (unless it is "pegged")

echo $&param >> point
echo $&delta >> point

end

.endc
