Question: Error, (in Convert) unable to convert

Hi,

 

I would like to differentiate a sinlge-variable function containing abs(), min(), and max() calls. For smaller functions it seems to work, however for my procedure, it does not seem to work. What can be the problem? I would appreciate any comment. 

 

It seems to work for the followings:

> diff(min(5*x,3),x);
                     /                    3
                     |     5          x < -
                     |                    5
                     |                     
                     |                    3
                    <  undefined      x = -
                     |                    5
                     |                     
                     |                3    
                     |     0          - < x
                     \                5    
> diff(abs(max(1, x)+x),x);  # also works
    

My procedure is called dia:

> dia:=proc(X::Matrix,C::Vector)
local i,j,k,l,t,v,Dpos,Dneg,Dposmin,Dnegmax,N,M;
N,M:=Dimensions(X);

#DiA
for i to M do:
for j to N do:
v[j,i]:=C[i]*X[j,i];
od;
od;

for j to N do:
Dpos[j]:=add( abs( v[j,i] - max(seq(v[k,i],k=1..N)) ) ,i=1..M );
Dneg[j]:=add( abs( v[j,i] - min(seq(v[k,i],k=1..N)) ), i=1..M );
od;

Dposmin:=min(seq(Dpos[j],j=1..N));
Dnegmax:=max(seq(Dneg[j],j=1..N));

for j to N do:
t[j]:=sqrt((Dpos[j]-Dposmin)^2+(Dneg[j]-Dnegmax)^2);
od;
Vector(N,t);
end proc:

When I call it:

> X:=Matrix(3,3,<<x,0.2,0.8>|<0.8,0.2,0.2>|<0.2,0.8,0.2>>);C:=Vector(3,1/3);
                     
> diff(dia(X,C)[2],x);
Error, (in Convert) unable to convert

Best regards,

Zoltán Faigl

Please Wait...