#!/usr/bin/perl
#
# Computes the discriminant of a polynomial wrt some literal. We try to do
# things intelligently, by calling samuel with -Z if the polynomial doesn't
# contain any denominators.

die "Usage: $0 polynomial literal\n" unless ($#ARGV == 1);
$p = $ARGV[0];
$l = $ARGV[1];
$samcmd = "|samuel -bZ";
$samcmd = "|samuel -b" if ($p =~ /\//);
open(STDOUT, $samcmd) || die "Cannot spawn samuel: $!\n";
print "P=$p;L=$l;~?L(?P,?P:?L);\n";
close STDOUT;
