acer

32313 Reputation

29 Badges

19 years, 314 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@ecterrab One of the points is that there is no call to any diff or conjugate before the forget.

So what is being forgotten that affects the (sole, only) call to diff that happens afterwards?

(I already knew what the subfunctions option to forget is supposed to do, thanks. I just don't see how that is relevent when the problematic example call to diff was not also called before the forget&unwith. What is being forgotten?)

The difference does not seem to lie in Physics:-ModuleUnload (which gets called by issuing restart but not by issuing unwith(Physics) , btw).

I also tested forcing a call to that, and it doesn't seem to be the key.  diff_forget_hmm2.mw

@Preben Alsholm That is an interesting observation.

It's still not clear to me what is the difference, since :-diff doesn't have a remember table, just before this call to forget. Some other action may be key, induced by the forget(:-diff) call, related to whether option subfunctions is utilized.

(I have not yet traced through that call to forget, say in the debugger, to try and pinpoint the difference. Clearly the "forgetting" doesn't relate specifically to f(x) or its conjugate per se, since that was not previously used. But the forgetting does something, and option subfunctions=false apparently disables whatever that is...)

restart;

kernelopts(version); # No Physics update applied

`Maple 2022.1, X86 64 LINUX, May 26 2022, Build ID 1619613`

restart;

with(Physics):

unwith(Physics);

op(4,eval(:-diff)); # no remember table

forget(:-diff,subfunctions=false);

#forget(Physics:-diff); # doesn't see to matter here

:-diff(:-conjugate(f(x)), x);

diff(conjugate(f(x)), x)

restart;

with(Physics):

unwith(Physics);

op(4,eval(:-diff)); # no remember table

forget(:-diff,subfunctions=true); # default

:-diff(:-conjugate(f(x)), x);

(diff(f(x), x))*(-conjugate(f(x))/f(x)+2*abs(1, f(x))/signum(f(x)))

Download diff_forget_hmm.mw


I wonder how it is useful to have *both* of these results.

diff(y(x),x)^3:
select( has, ["itself"=%, op(%)], diff(y(x),x));

["itself" = (diff(y(x), x))^3, diff(y(x), x)]

Q*diff(y(x),x)^3:
select( has, ["itself"=%, op(%)], diff(y(x),x));

["itself" = Q*(diff(y(x), x))^3, (diff(y(x), x))^3]


Also,

 

I wonder how it is useful to have such different results
for the expanded versus unexpanded forms.

 

expr1 := (Q+diff(y(x),x)^2)/(diff(y(x),x)^3+R);
expr2 := expand(expr1):

(Q+(diff(y(x), x))^2)/((diff(y(x), x))^3+R)

select( has, [op(expr1)], diff(y(x),x));

[Q+(diff(y(x), x))^2, 1/((diff(y(x), x))^3+R)]

select( has, [op(expr2)], diff(y(x),x));

[Q/((diff(y(x), x))^3+R), (diff(y(x), x))^2/((diff(y(x), x))^3+R)]

 

@nm The Help page says "operands", and you say "parts", which is not exactly the same. If you meant operands then you could have made that clear at the start.

You wrote, "...I want to select the part of the expression which has diff(y(x),x) in the expression." But your use (lattermost, in the Reply directly above) of the select command is returning an expression of the same type as the input. So in your words you state that you want only the "parts" (operands, you now say), but your use of select will return something applied to some of the operands (so that the result is of the same type).

Moving on (and using select in your last mentioned manner) these look weird and quite possibly unuseful,


Is this useful?
How is the next result a useful part of the input?

arctan( diff(y(x),x), Q);
select(has, % ,diff(y(x),x));

arctan(diff(y(x), x), Q)

arctan(diff(y(x), x))


Is it useful to have *both* of these results?

diff(y(x),x)^3;
select(has, %, diff(y(x),x));

(diff(y(x), x))^3

diff(y(x), x)

Q + diff(y(x),x)^3;
select(has, %, diff(y(x),x));

Q+(diff(y(x), x))^3

(diff(y(x), x))^3

 

It's a valid expression, though you might not encounter it in your cases.

 

2^diff(y(x),x);
select(has, %, diff(y(x),x));

2^(diff(y(x), x))

undefined

 

How is the next result a useful part of the input?

 

abs(1,diff(y(x),x));
select(has, %, diff(y(x),x));

abs(1, diff(y(x), x))

abs(diff(y(x), x))

 

How is it useful for the result for the expanded form be so
different from the result for the unexpanded form?

 

expr1 := Q*(diff(y(x),x)^3+R);
expr2 := expand(expr1);
select(has, expr1, diff(y(x),x));
select(has, expr2, diff(y(x),x));

Q*((diff(y(x), x))^3+R)

Q*(diff(y(x), x))^3+Q*R

(diff(y(x), x))^3+R

Q*(diff(y(x), x))^3

Download hmmm.mw

This question lacks important details.

What does, "...the part of the expression which has diff(y(x),x) in the expression" mean? What do you mean by "the part".

Could it mean the addend of an expression which is a sum? Could it also mean the multiplicand of an expression which is a product?

What if the expression were, say,

    sin( f( diff(y(x),x) ) + Q )

What "part" of that expression would you be you after?

What if the expression were 3*diff(y(x),x) ? Which "part" of that would you want?

@Teep It is unclear what you are asking.

Do you have the .mla file, and do not know how to utilize it? Or are you lacking that file?

If you lack that file then you can obtain it from under the link I gave.

That link I gave also has notes various ways to install it. The basic idea is that you need the location of the .mla & .help files to be in one of the locations assigned to the libname variable. You can accomplish that manually by appending to libname the location that you place them (and optionally do that in an initialization file). Or you can install to a special location for which Maple adjusts libname on launch, and that link mentions how to accomplish that automatically.

Try to follow the instructions. If you have problems tell us explicitly and clearly what you have tried so far.

Do you actually have the files? Are they from here?

restart;

kernelopts(version);

`Maple 2022.1, X86 64 LINUX, May 26 2022, Build ID 1619613`

with(IntegrationTools):

f := sin(x)/sqrt(2+sin(2*x)):

raw := eval(value(Change(expand(Int(f,x)),t=tan(x),t)),t=tan(x)):

Q := combine(simplify(convert(combine(simplify(raw,tan),
                                      radical,symbolic),
                              sincos),symbolic)):

FF := simplify(evalc(Re(Q))) assuming x::real;

(1/2)*arctan((sin(x)-cos(x))/(2+sin(2*x))^(1/2))-(1/4)*ln((2+sin(2*x))^(1/2)+sin(x)+cos(x))+(1/8)*ln((-2*sin(x)-2*cos(x))*(2+sin(2*x))^(1/2)+2*sin(x)*cos(x)+sin(2*x)+3)

FFF := simplify(expand(evalc(Re(Q)))) assuming x::real;

(1/2)*arctan((sin(x)-cos(x))/(2+2*sin(x)*cos(x))^(1/2))-(1/4)*ln((2+sin(2*x))^(1/2)+sin(x)+cos(x))+(1/4)*ln((2+sin(2*x))^(1/2)-sin(x)-cos(x))

simplify(diff(FF,x)-f);

0

simplify(diff(FFF,x)-f);

0

Download intfun2.mw

With the H I supplied then --  given the form of f -- the simplest check is likely the following (Maple 2022.1),

    simplify(diff(H,x) - f);
                      0

For the F you gave, one slightly terser check is,

    (simplify@@2)(expand(diff(F,x) - f))

My earlier concoction manipulates diff(H,x) in order to obtain f, which (as is quite often the case) is a more involved task that simplifying their difference to zero.

The integration should be fun to see.

@MaPal93 That old posting you cited is (IMO) not the best way to install the DirectSearch v.2 package, in modern Maple versions. Here are some alternatives, in a descending priority that I would prefer:

1) Open the Maple cloud directly from your Maple GUI, and install that package directly from there.
2) Visit the Maple cloud webpage for that package and download from there.
3) Use the installer that comes in the .zip file bundled at the Application Center page for that package.

All of those approaches should put the relevent files into some special location that Maple looks for (so that you don't have to manually adjust libname in an edited initialization file).

You may have to completely close the Maple GUI and relaunch in order to see the Help pages that come with it.

If none of those approaches work then it would be interesting to know what is in the folder/directory that'd be named as the output of this Maple command:
    cat(kernelopts(homedir),"/maple/toolbox");

I have not yet found a satisfactory way.

I got something backwards (a simplification challenge):

H := 1/2*(-arctan((cos(x) - sin(x))/sqrt(2 + sin(2*x)))
     - log(cos(x) + sin(x) + sqrt(2 + sin(2*x))))

-(1/2)*arctan((cos(x)-sin(x))/(2+sin(2*x))^(1/2))-(1/2)*ln(cos(x)+sin(x)+(2+sin(2*x))^(1/2))

combine(simplify(expand(rationalize(diff(H,x)))));

sin(x)/(2+sin(2*x))^(1/2)

Download backwds.mw

@C_R The second argument to the indets command specifies a type, and that is documented. That is why Tom's answer doesn't use the word "type" explicitly-- it's implied by that particular choice of command.

And type suffixed is documented.

note: The top-level (global) name suffixed is not protected (Maple 2022.1) and so could be assigned some value. Some modest defensive programming could avoid accidental failure in such a case, eg. by using unevaluation quotes as Carl did.

   indets(A, 'suffixed'(t, :-nonnegint))


By the way, if you wish to use select here then you can get by without the extra layers of a user-defined anonymous operator (arrow) and an `if` call, both shown in an earlier suggestion. You had,

   select(X -> `if`(type(X, 'suffixed(t, integer)'), true, false), lst)

The `if`(...,true,false) layer is not needed because type itself returns true or false. And the anonymous operator is not needed because any additional arguments (3rd onward) passed to select will get passed along to the 1st argument (as predicate). So you can get by with the terser and more efficient,

   select(type, lst, 'suffixed'(t,:-nonnegint))

That kind of use of (only) kernel builtins can bring a small absolute time savings on average. But the relative time savings can be large, and so it can often scale better to large examples. So it can be worthwhile to program in such a way when possible.

@nm Your odetest example induces the following call to solve, whose result is different on the second attempt (with Carl's redefinition in play...).

restart;

kernelopts(version);

`Maple 2022.1, X86 64 LINUX, May 26 2022, Build ID 1619613`

#from https://www.mapleprimes.com/questions/230035-Error-in-SolveToolsCancelInverses
CI__orig:= eval(SolveTools:-CancelInverses):
unprotect(SolveTools:-CancelInverses):
SolveTools:-CancelInverses:= e->
local _A;
    eval(CI__orig(eval(e, _Z= _A), _rest), _A= _Z)
:
protect(SolveTools:-CancelInverses, CI__orig):

P := (-42*((-2*x^2+3*x*y(x)+y(x)^2)/x^2)^(1/2*17^(1/2))*2^(-3/2*17^(1/2))*((-11/21*17^(1/2)-17/7)*x^(2*17^(1/2)+1)+y(x)*x^(2*17^(1/2))*(17^(1/2)+85/21))+4*(1/8*(-2*x^2+3*x*y(x)+y(x)^2)/x^2)^(-1/2*17^(1/2))*((2*y(x)+3*x)*17^(1/2)+17*x))/(-5/4*x^(2*17^(1/2))*2^(-3/2*17^(1/2))*((-2*x^2+3*x*y(x)+y(x)^2)/x^2)^(1/2*17^(1/2))*(17^(1/2)+21/5)+(1/8*(-2*x^2+3*x*y(x)+y(x)^2)/x^2)^(-1/2*17^(1/2))),
y(x):

a1 := solve(P): # first call

a2 := solve(P): # second call

nops([a1]);

1

nops([a2]);
a2[2];

2

-(1/2)*(17^(1/2)+3)*x

# The above call to `solve` happens here, for the given odetest example.
#
showstat(`ODEtools/Solve/EnvDropMultiplicity`,29);


`ODEtools/Solve/EnvDropMultiplicity` := proc(ee, X := NULL, {keepalreadysolveduntouched::truefalse := false, removelabel::truefalse := false})
local EE, sol, N, sys, zn, vars, sysaux, tmp, to_jet, j, k, _sum, Q, Q_eqs, P,
  copy_P, PL, P2, PL2, PL21, PQ, ee_signum, sol_signum;
       ...
  29                   sol := :-solve(ee,X,_rest)
       ...
end proc
 

Download cancelinverses_rum_ex.mw

@MalakMMK Here is something like the previous simple (manually written) looped code. Of course it now has to store the converged value since that's the kind of image you requested.

So I adjusted the looped code to store the converged values as a side-effect in a new Array. That Array is then used for the hue values in the image, according to classification according to nearest actual root. The iteration counts are also (still) returned, and those are extracted (in bulk) from the plot3d result and used for the intensity values in the image.

The classification by root takes slightly longer than the iterative process (which is slower in this looped code than it is using Escape, contrary to your claim).

Of course one could improve the performance of the code that classifies by root. I don't have the time for that. Perhaps you could do it; this is your project work, after all.

King_iter_Ma2_umm.mw

[edit: there are also examples for which symmetry can provide additional savings.]

First 96 97 98 99 100 101 102 Last Page 98 of 591