Converting a function to one



Richard Hennessy wrote:
> Hi List,
>  
> I have an expression containing many calls to the same function say
>  
> f(someargs)+f(someotherargs)/f(somestuff)
>  
> and I want to know what is the fastest way to change all of the 
> occurrences of this function to the number 1.  I want/need to do this 
> in my program to eliminate pwdelta(someargs)'s inside of an integral 
> and so that is the reason for my question.  I have been doing it a 
> silly way by creating a new function and using opsubst(g=pwdelta, 
> expr) where g is defined g(x):=1.  Is that the best way?  It is pretty 
> fast, but is there a better way?  One problem I get is that I have to 
> do an ev(opsubst(g=pwdelta, expr), nouns) to get Maxima to change the 
> g's to a 1 and I have been observing in the list that ev() is a 
> problem function.
>  
> Thanks for any help,
>  
> Rich
> ------------------------------------------------------------------------
>
> _______________________________________________
> Maxima mailing list
> Maxima at math.utexas.edu
> http://www.math.utexas.edu/mailman/listinfo/maxima
>   

You might want to play with evaluated and unevaluated function 
definitions, etc.

E.g.

(%o33) f(x):=x^2+2
(%i34) g: 'f+ 'f/('f+1)^2;

(%o34) f/(f+1)^2+f
(%i35) ''g;

(%o35) (x^2+2)/(x^2+3)^2+x^2+2
(%i36) subst(f=1,g);

(%o36) f/(f+1)^2+f
(%i37) subst('f=1,g);

(%o37) 5/4


HTH,
 -sen
If you define your functions as unevaluated expressions, then you can 
evaluate them when needed, and you can use 'subst' to replace them by 1.

E.g.