acer

21438 Reputation

29 Badges

15 years, 115 days

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@DoingMath2018 If your input procedure doesn't have conditionals and branching (ie. are simple operators that utilize a formula) then handling an arbitrary number of dependent variables and instead using an expression doesn't seem to present great difficulty.

For example (noticing that the dummy variable of integration, r, is correctly skipped and is not one of the independent variables):

restart;

expr := [x^2-y^2+a*z+Int(cos(q*r*s),r=0..1)];

[x^2-y^2+a*z+Int(cos(q*r*s), r = 0 .. 1)]

vars := [op(indets(expr,And(name,Non(constant),satisfies(u->depends(expr,u)))))];

[a, q, s, x, y, z]

exprJ := unapply(VectorCalculus:-Jacobian( expr, vars ), vars):

evalf(exprJ(0.1,0.2,0.3,0.4,0.5,0.6));

Vector[row](6, {(1) = .6, (2) = -0.5997840278e-2, (3) = -0.3998560185e-2, (4) = .8, (5) = -1.0, (6) = .1})

# check
map(diff~,expr,vars);
evalf(eval(%, Equate(vars,[0.1,0.2,0.3,0.4,0.5,0.6])));

[[z, Int(-r*s*sin(q*r*s), r = 0 .. 1), Int(-q*r*sin(q*r*s), r = 0 .. 1), 2*x, -2*y, a]]

[[.6, -0.5997840278e-2, -0.3998560185e-2, .8, -1.0, .1]]

 

Download VCJ_arb.mw

Above I have constructed a single Vector-valued procedure rather than a Vector of procedures. I'm not sure which you want.

If you really do prefer to use an input operator rather than an input expression then you could look over my Answer above.

I think it would be easier to learn how to leverage Maple's functionality than it would be to implement your own basic CAS.

It is still unclear to me how you plan to subsequently utilize this Jacobian-thing that you're after. Providing more details of the input example class and also how the result will be subsequently utilized should surely be a core part of the question.

Have a look at the Help pages for the Student:-Calculus1 package.

@tomleslie The OP made it quite clear in his Question that he wanted to act on operators/procedures rather than expressions. That was the central point of the Question.

Your code deals with function calls which evaluate to expressions prior to Jacobuan being called. So your suggestion is not what was requested.

One could map unapply over an expression-based solution like yours, after the fact, to get a result with operators. But that is a kludge generally weaker than using D (which also has some abilities to deal with conditionals and code branching within the procedure, and that otherwise mostly gets wrecked/ignored by a function call to produce an expression result).

@tomleslie Investigating the older behavior is a good idea. But the following does not agree with one of your examples (even if put in a single execution group).

restart;

kernelopts(version);

`Maple 2019.0, X86 64 LINUX, Mar 9 2019, Build ID 1384062`

with(VectorCalculus):

# assume(x, 'real');
# assume(y, 'real');

D[1]((x, y) ->x^2-y^2);

proc (x, y) options operator, arrow; 2*x end proc

 

Download D_TL.mw

@Carl Love The example that I showed produces the same results in my Maple 2019.0 as it did in what I posted from Maple 2018.0.

I suspect that you have not noticed the key aspects of my two alternatives. One uses procedure f defined before loading the package, and the other used unapply afterwards. I did not claim that :-D would work on the operator defined literally as you have it, after loading the full VectorCalculus package and placing the assumptions (which is literally similar to what the OP had).

restart;

kernelopts(version);

`Maple 2019.0, X86 64 LINUX, Mar 9 2019, Build ID 1384062`

with(VectorCalculus):

assume(x, 'real');
assume(y, 'real');

:-D[1]( unapply(x^2-y^2, [x,y]) );

proc (x, y) options operator, arrow; 2*x end proc

:-D[2]( unapply(x^2-y^2, [x,y]) );

proc (x, y) options operator, arrow; -2*y end proc

restart;

kernelopts(version);

`Maple 2019.0, X86 64 LINUX, Mar 9 2019, Build ID 1384062`

f := (x, y) -> x^2-y^2;

proc (x, y) options operator, arrow; x^2-y^2 end proc

with(VectorCalculus):

assume(x, 'real');
assume(y, 'real');

:-D[1](f);

proc (x, y) options operator, arrow; 2*x end proc

:-D[2](f);

proc (x, y) options operator, arrow; -2*y end proc

:-D[1]( unapply(x^2-y^2, [x,y]) );

proc (x, y) options operator, arrow; 2*x end proc

:-D[2]( unapply(x^2-y^2, [x,y]) );

proc (x, y) options operator, arrow; -2*y end proc

 

VCD_M2019.0.mw

Trying to export package "overloads" of kernel builtins is difficult to get exactly right (and not always possible). [edit] If Tom is correct and this is a regression breakage then I do not yet know whether the bug is Library-side or kernel-side.[/edit]

Please upload a worksheet, or add a comment with the full details to this thread. Please don't post a duplicate thread, which is unhelpful.

@Carl Love Yes, simplify with side-relations can just do this:

restart;

G:=Groebner:-Basis({a+b+c-1,a^2+b^2+c^2-2,a^3+b^3+c^3-3},
                   plex(c,b,a),characteristic=0,output="basislm"):

lprint(G);
   [[6, a^3, 6*a^3-6*a^2-3*a-1], [2, b^2, 2*a^2+2*a*b+2*b^2-2*a-2*b-1],
    [1, c, a+b+c-1]]

Groebner:-NormalForm(a^4+b^4+c^4,G,plex(c,b,a),characteristic=0);

                         25/6

I suppose that this was originally intended for people to do without Maple, where they would concoct or notice that the target expressions can be obtained by a judicious expansion (with cancellation) of a polynomial of the original three expressions.

Perhaps the OP was shooting for something like this (just a guess as to intent):

restart;

eqs := [t1 = a+b+c,
        t2 = a^2+b^2+c^2,
        t3 = a^3+b^3+c^3]:

vals := [t1=1,t2=2,t3=3]:

R4 := 1/2*(t2-t1^2)^2-1/3*t1^4+4/3*t1*t3;

(1/2)*(-t1^2+t2)^2-(1/3)*t1^4+(4/3)*t1*t3

# Notice this
subs(eqs, R4);
expand(%);

(1/2)*(-(a+b+c)^2+a^2+b^2+c^2)^2-(1/3)*(a+b+c)^4+(4/3)*(a+b+c)*(a^3+b^3+c^3)

a^4+b^4+c^4

expand(eval(R4, eqs)) = eval(R4, vals);

a^4+b^4+c^4 = 25/6

R5 := 1/6*(5*(t1^2+t2)*t3+t1^3*(t1^2-5*t2));

(5/6)*(t1^2+t2)*t3+(1/6)*t1^3*(t1^2-5*t2)

# Notice this
subs(eqs, R5);
expand(%);

(5/6)*((a+b+c)^2+a^2+b^2+c^2)*(a^3+b^3+c^3)+(1/6)*(a+b+c)^3*((a+b+c)^2-5*a^2-5*b^2-5*c^2)

a^5+b^5+c^5

expand(eval(R5, eqs)) = eval(R5, vals);

a^5+b^5+c^5 = 6

 

Download subs_challenge.mw

So, is there some "easier" reformulation of R4 or R5 which might be concocted with more of an "aha!" moment?

@Carl Love I wish I'd thought of it earlier.

@Christopher2222 I submitted a bug report related to this a few years ago.

@tomleslie Yes, and now you've obtained a method that is essentially the same as what dharr showed earlier (as in the examples,Explore help page).

[I'm not suggesting that you haven't come up with this all by yourself. I think it's the natural way to approach it efficiently. I'm pretty sure I've seen Preben do the same thing. I've long wanted something like DEplot to offer the same flexibility+efficiency.]

Please post your followups to this thread here, instead of entirely new Question threads.

To get the visual effect of subscripted text (but not as output) you might have to toggle into non-executing 2D Math input mode and manually flip off italics from the menubar.

@Christopher2222 It looks as if his question is about how to enter it as input, while your answer is only about how to produce output.

Moreover he seems to want a subscripted/superscripted bit of "text", which I interpret as meaning something formatted in upright roman font. So mi is not the right typesetting markup for that.

I don't see how your answer relates properly to this question at all.

@dharr Vote up, because this shows dsolve being called only the one time.

The help page referred to is available in the Help system under the topic examples,Explore

First 77 78 79 80 81 82 83 Last Page 79 of 450