diff --git a/macros/contexts/contextLimitedRadical.pl b/macros/contexts/contextLimitedRadical.pl index 8c7bbd291f..49569d2ecd 100644 --- a/macros/contexts/contextLimitedRadical.pl +++ b/macros/contexts/contextLimitedRadical.pl @@ -128,6 +128,20 @@ sub _contextLimitedRadical_init { }; } +########################### +# +# Convenience +# +# Pass $a,$b, get Formula("$a sqrt($b)") but simplified + +sub preprad { + my ($a, $b) = @_; + return Formula("0") if $a == 0 || $b == 0; + return Formula("$a") if $b == 1; + my $simplifieda = abs($a) == 1 ? ($a > 0 ? '' : '-') : $a; + return Formula("$simplifieda sqrt($b)"); +} + ########################### # # Create root(n, x)