Preben Alsholm

11664 Reputation

22 Badges

15 years, 227 days

MaplePrimes Activity

These are replies submitted by Preben Alsholm

@Hnx I strongly recommend using worksheet mode and 1D math input (aka Maple input):

Go to Tools/Options/Display/Input display: Choose Maple Notation.

After that and without leaving the window that is open go to the menu Interface/Default format for new worksheets: Choose Worksheet.
Then press the button at the bottom labelled Apply Globally. Don't worry about the word "Globally"; these changes can just as easily be reverted.
Any new worksheet that you open will use the chosen format. Old worksheets or worksheets from other people won't change if brought into your copy of Maple.

Personally I never use 2D math input or document mode. I find it frustrating to work with as it seems to be for you.
Here is your code slightly modified (irrelevant though) in 1d-input and worksheet mode (and no equation labels: my personal preference).

@acer The difference in your procedures is seen before the call if they are assigned to a name:

M:=module() option package;
  export e,f,g,h;
  e := overload([
         proc(x::positive) option overload; x^2; end proc,
         proc(x::negative) option overload; x; end proc ]);
  f := overload([
         proc(x::positive) option overload; x^2; end proc,
         proc(x::negative) x; end proc ]);
  g := overload([
         proc(x::positive) option overload; x^2; end proc ]);
  h := overload([
         proc(x::positive) option overload; x^2; end proc,
         proc(x::odd) option overload; x^3; end proc,
         proc(x::negative) x; end proc ]);
end module:
pe:=proc() uses M; e(3); end proc;

pf:=proc() uses M; f(3); end proc;

pg:=proc() uses M; g(3); end proc;

ph:=proc() uses M; h(3); end proc;

We see from the printed ouput that inside the procedures pf and ph f and h are replaced by M:-f and M:-h, respectively.

This doesn't happen with pe and pg.
If with(M) is placed after the definitions of the procedures pe,pf,pg, and pg then there is no problem.
Thus if one's own package makes use of 'uses LinearAlgebra' and that package is loaded before using with(LinearAlgebra) in a worksheet, there should be no problem.

Note: After M is defined and after with(M)  then eval(e) returns just:
overload([e = M:-e])
which doesn't make any sense to me (although e works).
To get the print above use standard typesetting, otherwise the output prints as overload([e = e]) (!!)

In contrast eval(f) evaluates to

overload([proc (x::positive) option overload; x^2 end proc, proc (x::negative) x end proc])
as expected.


@Hnx What odeplot does is to issue a warning, but the plot is fine.
If you want to know the value of tmax before the plot you can simply do:

phi1_numeric := dsolve({deq_numeric, ics_numeric}, numeric, events = [[phi1(t) = phi1_end, halt]],maxfun=0);
res:=phi1_numeric(0.5); # warning only and expected since you asked for a stop.

If you don't even want to see a warning you can turn warnings off (only do this temporarily, not a good idea in general):

@Hnx I added maxfun=0, which really means maxfun = infinity, i.e. no upper bound for the number of function evaluations.

phi1_numeric := dsolve({deq_numeric, ics_numeric}, numeric, events = [[phi1(t) = phi1_end, halt]],abserr = 0.1*10^(-8), relerr = 0.1*10^(-7),maxfun=0);

Then try:

t_max := 0.354;
odeplot(phi1_numeric, [t, phi1(t)], t = 0 .. t_max + 0.1);

You will see that the event occurs.

@Hnx You say that you know the point of singularity in the form of a constant. Is that constant the value of t or of y(t) or y'(t) or what?

Here is a very simple example, where we know in advance that the solution y(x) has a singularity at x = 1.

#Singularity at x = 1.
res(1.1); # Error message is good
eps:=1e-9: # Value dependent on Digits and abserr/relerr
resE:=dsolve({ode,ic},numeric, events=[[x=1-eps,halt]], abserr=1e-9,relerr=1e-8);


@Carl Love  Thanks for reminding me of this weird bug.
The bug as reported concerned Maple 2015. It seems that improvements were made in Maple 2016, and the bug seems to be gone in Maple 2017, and also in Maple 2018 - Maple 2020.

@Hnx The name x_rkf45 is just the formal parameter in the procedure resulting from dsolve/numeric with the default method rkf45 as in

res:=dsolve(ivp,numeric); # formal parameter x_rkf45

The reason for not just using plain x instead of x_rkf45 may be to inform the user that the method used is rkf45 (my guess).

You can find code for rkf45 (Runge-Kutta-Fehlberg) on the internet.
See e.g. this link to Douglas Wilhelm Harder:

But as Georgios is pointing out you could use the events option in dsolve/numeric to do breaks or whatever it is you want to do. The help page for events isn't easy reading, but you could let us know what you are thinking of doing.

@acer You don't need the if statement which takes i = 0 as a special example.

diff(f(x), [] ) returns f(x). So the if statement can be skipped and in the loop we can just do:
U := 'Typesetting:-Typeset'(diff('f(x)',[x$i]));

@dharr I don't understand your statement that k is used in two versions.
I don't think that k is local to sum nor to Sum:

B[1] := BesselI(k - 1, alpha*(u - y));


@mthkvv A good question. With interface(warnlevel=0) it still happens (with 2D input).

This behavior is new to Maple 2020 and is clearly intended.

I can only speculate that the warning is meant to help new users. Furthermore turning off warnings in general would not be good even for experienced users.

I use 1D input exclusively so this problem doesn't affect me.

@Kitonum Notice that ArrayTools reverses rows and columns, where ListTools only reverses the outer list.

We can, however achieve the ArrayTools ordering by an additional Reverse (if desired):

A:=[[0, 4], [1, 3], [2, 2], [3, 1], [4, 0], [0, 3], [1, 2], [2, 1], [3, 0], [0, 2], [1, 1], [2, 0], [0, 1], [1, 0], [0, 0]];
ListTools:-Reverse~(A1); # Elementwise


@Grigoriy Yashin You are right: I didn't see that you were not considering the full system in the first solve command.

Please see my correction at the end of my answer. But the linear system sys6 in the variables vars has no solutions.

Thus solve returns NULL for that system.

@Carl Love Thanks Carl for taking the time to explain these notions. I really appreciate that!

@lcz You get exactly the same error if you drop the list brackets. So those are irrelevant here.
Whether xxx[1] is used to select the first element in a list xxx or the first element of a sequence xxx is irrelevant.
(But notice there will be problems in this regard if the sequence xxx consists of 1 element, but you have 11 graphs).

The important point is that Tom Leslie has added to your code UnderlyingGraph. That is the problem mentioned by the error message.

I'm speaking as somebody who knows next to nothing about graph theory.

By reading the help page for ChromaticNumber I see that it is applied to an undirected unweighted graph. Your graph1 is weighted, but the underlying graph is not:
Take a look at the output from UnderlyingGraph(graphsof4[1]).

@fatemeh1090 My conclusion is that the statement in the paper about the derivative of the trace of the Jacobian is wrong.
( Clearly this doesn't invalidate the whole paper, but it teaches us to be on guard when something is claimed to be obvious. )

Use instead the Maple expression given already in this discussion by dharr above.

You can check his result with the example given by vv above:
So try with TrJ and E__2 from dharr's worksheet

TrJ_explicit:=eval(TrJ, E__2);
dTrJ:=simplify(diff(TrJ_explicit, alpha));
params_vv:=[alpha,beta,gamma,delta]=~[-1/2 + 2*sqrt(3), 1/6, 1, 13/6]; #Parameters from vv
simplify(%); # 0
simplify(%); # 3/4


1 2 3 4 5 6 7 Last Page 2 of 201