remove dependencies inside function?
- Subject: remove dependencies inside function?
- From: Barton Willis
- Date: Wed, 3 Oct 2012 19:53:49 +0000
I think the cure is to quote diff -- try something like
(%i2) diff11(expr,ydep,xindep) :=
block([dep,dexpr,sol],
dep: depends(ydep,xindep),
dexpr : diff(expr,xindep),
apply('remove, [ ydep , 'dependency ]),
solve (dexpr, 'diff (ydep,xindep)))$
(%i3) diff11(x^3+x*y+y^5,y,x);
(%o3) ['diff(y,x,1)=-(y+3*x^2)/(5*y^4+x)]
OK--
(%i4) dependencies;
(%o4) []
(%i5) depends(y,x);
(%o5) [y(x)]
(%i6) diff11(x^3+x*y+y^5,y,x);
(%o6) ['diff(y,x,1)=-(y+3*x^2)/(5*y^4+x)]
Not OK--function deleted depends(y,x):
(%i7) dependencies;
(%o7) []
--Barton
________________________________________
From: maxima-bounces at math.utexas.edu [maxima-bounces at math.utexas.edu] on behalf of Edwin Woollett [woollett at charter.net]
Sent: Wednesday, October 03, 2012 13:51
To: Stavros Macrakis
Cc: maxima mailing list; ivo.welch at gmail.com
Subject: Re: [Maxima] remove dependencies inside function?
On Oct. 2, 2012, Stavros Macrakis wrote:
---------------------
>Per documentation, 'remove' quotes its arguments, thus *perhaps *making it
>*
>slightly* easier to use interactively, and definitely making it annoying
>to use programmatically.
>
>The workaround:
>
> apply('remove, [ ydep , 'dependency ] )
--------------------------------------------------------
If I use the apply ('remove...) method, solve complains.
In the following, I first avoid any remove effort and solve
likes the task. I then replay with your remove line as part of
the function, and solve complains about something obscure.
-----------------------------------------------------------------
(%i1) display2d:false$
(%i2) dependencies;
(%o2) []
(%i3) diff11(expr,ydep,xindep) :=
block([dep,dexpr],
dep: depends(ydep,xindep),
dexpr : diff(expr,xindep),
display (dexpr),
/* apply('remove, [ ydep , 'dependency ] ), */
solve (dexpr, diff (ydep,xindep)))$
(%i4) diff11(y+log(y)+x,y,x);
dexpr = 'diff(y,x,1)/y+'diff(y,x,1)+1
(%o4) ['diff(y,x,1) = -y/(y+1)]
(%i5) dependencies;
(%o5) [y(x)]
(%i6) remove(y,dependency);
(%o6) done
(%i7) dependencies;
(%o7) []
(%i8) diff11(expr,ydep,xindep) :=
block([dep,dexpr],
dep: depends(ydep,xindep),
dexpr : diff(expr,xindep),
display (dexpr),
apply('remove, [ ydep , 'dependency ] ),
solve (dexpr, diff (ydep,xindep)))$
(%i9) diff11(y+log(y)+x,y,x);
dexpr = 'diff(y,x,1)/y+'diff(y,x,1)+1
solve: all variables must not be numbers.
#0: diff11(expr=log(y)+y+x,ydep=y,xindep=x)
-- an error. To debug this try: debugmode(true);
(%i10) dependencies;
(%o10) []
----------------------------------------
Ted
_______________________________________________
Maxima mailing list
Maxima at math.utexas.edu
http://www.math.utexas.edu/mailman/listinfo/maxima