Weby shortcut
teste

SUBSC

  • This routine substitutes one of the sub-summands of a given polynomial, produced in the list by the  function SEARCHC.



SUBSC:=function(pol, rel)
local pol_s, lm, lc, rs, ind, ind1;

if pol = Zero(pol) then
    return pol;
else
    pol_s:=SplitString(String(pol), "+");
fi;
lm:=List(pol_s, mon -> MON_STRG(mon));
lc:=List(pol_s, mon -> COEF_STRG(mon));
#Print("pol_s= ",pol_s, "\n","lm= ",lm, "\n","lc=  ", lc, "\n");

if rel[1] = Zero(pol) and rel[2] <> Zero(pol) then
    rs:=[];    
    rs[1]:="(0)*U";
    rs[2]:=String(rel[2]);
elif rel[1] <> Zero(pol) and rel[2] = Zero(pol) then
    rs:=[];
    rs[1]:=String(rel[1]);
    rs[2]:="(0)*U";
else
    rs:=List(rel, String);
fi;


if MON_STRG(rs[1]) in lm then
    ind := Position(lm, MON_STRG(rs[1]));
    if EvalString(lc[ind]) / EvalString(    COEF_STRG(rs[1])     ) in Integers then
        lc[ind] := Concatenation( "(", String(EvalString(lc[ind]) / EvalString( COEF_STRG(rs[1]) )), ")");
        lm[ind] := Concatenation("(", rs[2], ")");
        for ind1 in [1..Size(lm)] do
            pol_s[ind1] := Concatenation( lc[ind1], "*", lm[ind1]);
        od;
        pol_s:= JoinStringsWithSeparator(pol_s, "+");
        return EvalString(pol_s);
    else
        return pol;
    fi;    
else
    return pol;
fi;


end;

Listar Todas Voltar