# Question:Performance discriminant procedure

## Question:Performance discriminant procedure

Maple 2016

Hi all, we know Maple provided discrim method to find discriminant of a polynomial

> f := a*x^2 + b*x + c

> discrim(f, x) = b^2 - 4*c*a

I want to write a similar method with independent variable is a, b, c,... my code is below

discriminant := proc(poly::polynom, kvar::{set, list})
local f, kv, vars;
f := poly;
kv := {op(kvar)};
vars := indets(f) minus kv;
while nops(vars) > 0 do
f := discrim(f, vars[1]);
f := factors(f)[2];
f := map(t -> if verify(kv, indets(t[1]), `subset`) then t[1]; fi, f);
f := mul(f);
vars := indets(f) minus kv;
end;
return f;
end:

Some examples

> f := a*x^2 + b*x + c

> discriminant(f, [a, b, c]) = c*a - b^2/4

> f := a*x^3 + b*x + c

> discriminant(f, [a, b, c]) = c^2*a + 4*b^3/27

> f := (a^2 + b^2 + c^2)^2 - k*(a + b + c)*(a - b)*(b - c)*(c - a)

> discriminant(f, [k]) = k*(k - 4)*(k + 4)*(k - 8/3)*(k + 8/3)*(k^2 - 512/81)...

Maple already similar method? If not have, we can improve performance it?

Thank you very much.

﻿