simp_assuming (was Re: mydefint2)



From: Stavros Macrakis 
Sent: Friday, March 16, 2012 1:53 PM
To: Robert Dodier 
Cc: woollett at charter.net ; maxima at math.utexas.edu ; maxima-bounces at math.utexas.edu ; Barton Willis 
Subject: Re: [Maxima] simp_assuming (was Re: mydefint2)

The name is still misleading.  This is really "evaluate and resimplify with assumptions", and not "simplify with assumptions". 


I would suggest something like this:



/* internal programming version without convenience feature */

with_assumption_list (e, fcts) ::=
  buildq ([e, fcts],
    unwind_protect(
       (apply ('supcontext, [?gensym ("cntxt")]),
apply ('assume, fcts),
e),
       killcontext (context)))$

/* evaluate with assumptions */
with_assumptions(e,[fcts]) ::=
   buildq([e,fcts],
     with_assumption_list(e,fcts))$

/* resimplify with assumptions */
resimplify(e,[fcts]) :=    /* Note := NOT ::= */
  if fcts=[]
  then expand(e,0,0)
  else with_assumption_list(expand(e,0,0),fcts)$


Examples:


with_assumptions changes the evaluation context:


(%i9) with_assumptions(integrate(x^a,x),not equal(a,-1));
(%o9) x^(a+1)/(a+1)     <<< takes assumptions into account in evaluating the integral

(%i10) foo:abs(x)$
(%i11) resimplify(foo,x<0);

(%o11) -x     <<< resimplifies the expression abs(x)

(%i12) with_assumptions(foo,x<0);

(%o12) abs(x)     <<< evaluating 'foo' in that context doesn't resimplify the result


(%i13) resimplify(integrate(x^a,x),not equal(a,-1));
Is  a+1  zero or nonzero?                    <<< expression is not evaluated in the assumption context
n;

(%o13) x^(a+1)/(a+1)

An evaluate-and-resimplify function combines two different concepts -- but it might be easier to use for new users, so perhaps with_assumptions should do an implicit resimplify....


       -s


I modified simp_given() in pw.mac to use these new context based methods with good results.

simp_given(e,[fcts]) ::=
buildq([e,fcts],
with_assumption_list(resimplify(e,fcts),fcts))$

When running rtest_pw.mac with this new definition of simp_given(), I get all tests passed, 223/223 and performance was unaffected.  So it looks as good as pw?s original simp_given().

Rich