The procedure Math_Func allows one to obtain a list of mathematical functions (in the Maple sense) and of their power in a given expression. For example
Math_Func([(sin(x)^2+cos(x)^3)/x+sin(x)^2*cos(x)^3+1/sin(x)^2])returns in the global variable ALIAS_MATH_FUNC the list
3 2 1 [cos(x) , sin(x) , -------] 2 sin(x)If these terms appears more than once in the expression the MakeF procedure (see section 2.1.1) will generate a code where they are evaluated for each occurrence, which is costly. The ALIAS_FSIMPLIFY mechanism described in the MakeF section may be used to evaluate only once these expressions and substitute them by interval when calculating the interval evaluation. The end-user write its own ALIAS_FSIMPLIFY procedure but the result of Math_Func may be used to write such a procedure. A typical ALIAS_FSIMPLIFY using this functionality is as follows:
ALIAS_FSIMPLIFY:=proc(fid,expr) local aux,ai: if type(expr,string) then fprintf(fid,"INTERVAL_VECTOR ALIAS_S(%d);\n",nops(ALIAS_MATH_FUNC)): for ai from 1 to nops(ALIAS_MATH_FUNC) do aux:=Convert_Frac_Cons(Code(ALIAS_MATH_FUNC[ai],[x,y,z,w])): fprintf(fid,"ALIAS_S(%d)=%s;\n",ai,aux): od: RETURN(0): fi: aux:=expr: for ai from 1 to nops(ALIAS_MATH_FUNC) do aux:=subs(ALIAS_MATH_FUNC[ai]=ALIAS_S(ai),aux): od: RETURN(aux): end:Note the use of the Code procedure to convert the expression into an interval equivalent.