Honigmelone

102 Reputation

8 Badges

9 years, 42 days

MaplePrimes Activity


These are replies submitted by Honigmelone

@Christian Wolinski 

hey thanks for your solution. I tested it a bit and I found a strange behaviour. Most of the times it already seems to work without assume and simplify, but see for yourself:


restart:

f_symbol:=abs(a-b)*abs(1,a-b);

abs(a-b)*abs(1, a-b)

(1)

convert(f_symbol,signum);                                   #works

a-b

(2)

f_plus:=abs(a(t)+b)*abs(1,a(t)+b);

abs(a(t)+b)*abs(1, a(t)+b)

(3)

(convert(f_plus,signum));                                   #works

a(t)+b

(4)

f_minus:=abs(a(t)-b)*abs(1,a(t)-b);

 

abs(-a(t)+b)*abs(1, a(t)-b)

(5)

# assume(a(t),real,b,real);                                 #it always works with this assumption

c:=simplify(simplify(simplify(convert(f_minus,signum))));   #expected result: a(t)-b

abs(-a(t)+b)*signum(a(t)-b)

(6)

simplify(c);                                                #???????

a(t)-b

(7)

simplify(f_minus,symbolic);

a(t)-b

(8)

 


Download simplify_abs.mw

@Kitonum 

thank you for your answer! Your addition works for me.

@acer 

thanks for your answers, I guess I missunderstood the assume facility. Yes I use Maple 18.

@tomleslie 

Well I agree that if you set b(t):= 0 this means that b(t) equals 0 for all t  and thus diff(b(t),t) is zero for all t too. However in some situations you might want to evaluate an expression at a t0 for which you know that b(t0):=0 but eval(diff(b(t),t),t0) is whatever. So we are discussing difrent points here I guess. If you know any better way to tell maple that a funktion has a specified value at a given value of its argument but not for all values you might have the better solution for OP's problem.

OP wants the result a(t)*(diff(b(t), t))  and that is exactly the result of my answer.

@Carl Love 

Thank you both for your suggestions, my code will run smoothly now:)

Regards,

Honigmelone

@Mac Dude  EDIT: this is supposed to be a reply to mac dude, but somehow I replied to myself :(

Hey, thanks for your suggestion. Just to clarify the problem that I had: When a vector e.g.

v:=<2*r1(t),diff(r2(t),t)+diff(r1(t),t$2)>

and a list

r:=[r1(t),r2(t)]

then

VectorCalculus[Jacobian](v,diff~(r,t)) only returns the error:

"Error, invalid input: too many and/or wrong type of arguments passed to VectorCalculus:-Jacobian; first unused argument is [r1(t), r2(t)]"

Maybe there is something else that I am doing wrong, but thank to thaw /freeze my workaround became much simpler.

Honigmelone

@Preben Alsholm

Thanks for your suggestions! With them and the help of freeze thaw I was able to write a function that computes the Jacobian even if there are anonymous functions and their derivatives involved. I also didn't know about selectremove, however I think it's quite difficult to use this in a function when the order of derivative is not known. Here is what I wrote if anyone else ever stumbles across this.

MyJacobian := proc(a::Vector,b::Vector)
    # a consists of expressions of the elements of b(t)
    description "Computes the Jacobian of two vectors even if vector b is made up of anoymous functions and vector a contains derivatives of b(i)"
    local a_subs;
    local b_subs;
    local sizeb:
    local i,j,J_subs:

    sizeb := LinearAlgebra[Dimension](b);
    a_subs := convert(a,D);
    b_subs := convert(b,D);

   #substitution loops
    for j from 1 to sizeb do
        a_subs := subs(b_subs(j)=freeze(b_subs(j)),a_subs);
    end do;

    for i from 1 to sizeb do
        b_subs := subs(b_subs(i)=freeze(b_subs(i)),b_subs);
    end do;


    #Jacobian
    J_subs := VectorCalculus[Jacobian](a_subs,convert(b_subs,list)):

    return convert(thaw(J_subs),diff);
end proc:

Hey, I also got the error and I think it's normally caused if any statement is between the variable declaration and the proc().

Regards

1 2 Page 2 of 2