On 3/2/08, Robert Marik <marik at mendelu.cz> wrote:
> I have the following code, which seems to work, the function
> diff_in_steps(x^2*sin(x^3))
> differentiates with respect to x and shows steps, but it fails for
> diff_in_steps(x^2*sin(y))
Seems to work better with the following matchdeclare incantation.
Instead of recognizing constants I think you want expressions which
don't depend on x (since it appears the variable for differentiation is
always x and not something else).
freeofx (e) := freeof ('x, e);
freeofx_not1 (e) := e # 1 and freeofx (e);
matchdeclare(g,true,n,freeofx_not1,c,freeofx);
Then I get
(%i5) diff_in_steps(x^2*sin(y));
2
product: ( (x sin(y)) )'=...
2 2
y'= x derivace(sin(y)) + derivace(x ) sin(y)
2
power: ( x )'= (2 x) *( x )'
free of x: ( sin(y) )'=0
y'= (2 x sin(y))
(%o5) done
> It remains to solve this problem (it is not possible to use parameters or
> functions in more variables)
Not sure what you mean here.
> and also to format the result for reading --
> with tex and texput(derivace,["\\left(","\\right)^\\prime"],matchfix)
Looks like texput(derivace, "\\prime", postfix)
works OK here.
tex (derivace (x * y * z));
=> $$\left(x\,y\,z\right)\prime$$
Note that tex threw in parentheses here.
> (here I observed a strange thing: op(u/v) gives "//"
> on debian and "/" on archlinux)
Probably a version difference. op(a/b) => "//" until a pretty recent
version, now it op(a/b) => "/".
Hope this helps,
Robert Dodier