Preben Alsholm

13613 Reputation

22 Badges

19 years, 236 days

MaplePrimes Activity

These are replies submitted by Preben Alsholm

@Ronan I'm beginning to see that your original foo1 is behaving correctly, though not as you intended:

                     option overload;
                     print("3 lists");
                  end proc,

                     option overload;
                     print("2 lists");
                  end proc
foo1([1,2],[3,4]); #Output correct because P1 and P2 are lists

Now, however, I don't see any need for using option overload(callseq_only).
I have been looking for examples in the documentation, but have not found any.

@Ronan Yes your example foo3 is puzzling.

Contrast the example with this:

end proc;

p1([1,2],[3,4]); # Error message

But if the body of the procedure p1 doesn't make use of P3 there will be no error.

foo3 didn't produce an error message, it just jumped to the second procedure.

@Prakash J As I said above, dsolve/numeric/bvp uses a finite difference method.
So what more do you want?
To follow a little of what's happening you can try setting


just before executing dsolve/numeric/bvp

The initial mesh is by default 8. To see what happens when you set that value yourself, try

@dharr Maybe you are right:
Anyway I had fun making the animations over two ranges for inf.
There are some ranges where dsolve/numeric/bvp doesn't converge. That is why there are two animations.


@Thomas Richard I noticed that simplify remembers:

f := (BesselI(0, alpha)*alpha - 2*BesselI(1, alpha))/(BesselK(0, alpha)*BesselI(1, alpha)*BesselI(0, alpha)*alpha^2 + BesselK(1, alpha)*BesselI(0, alpha)^2*alpha^2 - 2*BesselI(1, alpha));
simplify(f, 'wronskian'); # Not 1
f := (BesselI(0, alpha)*alpha - 2*BesselI(1, alpha))/(BesselK(0, alpha)*BesselI(1, alpha)*BesselI(0, alpha)*alpha^2 + BesselK(1, alpha)*BesselI(0, alpha)^2*alpha^2 - 2*BesselI(1, alpha));
simplify(f, 'wronskian'); # 1

I tried forget(simplify);  just after simplify(f);  but it doesn't seem to work (at least not consistently).
Note: I was using Maple 2023.2.

@acer Thank you very much acer.
Setting _EnvUsePlotThing:=false:  produces a nice plot in Maple 2023.2.
I will put it into my maple.ini file.

Maple 2022.2 also sets _EnvUsePlotThing:=false in `plots/animate`, but it appears not necessary in this case with plot(x*exp(-x),x=0..20) with Digits set very high.
The speed is affected a lot, though, as you also point out.
I tried this in Maple 2022.2:

CodeTools:-Usage([seq(plot(x^n*exp(-x),x=0..20),n=1..20)]): # Roughly 10 times faster.

@fnavarro It is a really bad idea to use plot as a toy model.
As dharr is pointing out there is nothing wrong with evaluation, but plot is rather special for the reasons I mentioned.
Take a look at this code.

max(V); # 0.3678794411714423215955237701614608674458
min(V); # 0.

@sand15 There is some confusion: You write to begin with:
"But it seems that test and `test` do not mean exactly the same thing here:",

but you use unevaluation quotes in select(type, {anames()}, suffixed('test'));

When test:=0 (or assigned to anything else)  'test'; first evaluates to test, then to 0.

'test'; # test
%; # 47
## In contrast:
`test`; # 47


@Carl Love Yes, although ? keywords brings up a help page with the title
Maple Keywords (Reserved Words).

Furthermore the statement really refers to symbols:

type(sin,symbol); #true
type(Pi,symbol);  #true
evalb(`sin`=sin); #true
evalb(`a[1]`=a[1]);  #false
type(`a[1]`,symbol); #true
type(a[1],symbol);   # false
type(a[1],name);     #true


@Carl Love It could be pointed out that in these examples the same holds:

`sin`(Pi/3); # 1/2*sqrt(3)
`exp`(ln(x)); # x
sin(`Pi`/3); # 1/2*sqrt(3)
Pi:=6; # Error

The attempt to assign to Pi results in the error:
Error, attempting to assign to `Pi` which is protected.  Try declaring `local Pi`; see ?protect for details.

Similar errors follow attempts to assign to sin or exp.

In the help page ? names we find this statement:

Any valid Maple name formed without using left single quotes is precisely the same as the name formed by surrounding the name with left single quotes.  Therefore, x and `x` both refer to the same name x. However, a keyword cannot be used as a name unless it is enclosed in left single quotes.


@Axel Vogt You didn't imply that your analysis shows an error and there isn't any.
Since B > 0, A+B*s will be positive if just s is large enough. It is correct that A < 0 under the assumptions.
The requirement is s > -A/B and that is exactly the same as returned by solve in my res[6].
In detail:

Q:=(a - c)^2*y*(3*b*y - 1)/(2*(2*b*y - 1)^2) + 
  (-a*(a + c)/(2*b) + (a - c)^2/(8*b) + s*(a - c)^2/(8*b^2));

theAssumptions:=(2*c < a, a/c < 2*b*y, 0 < a, 0 < b, 0 < c, 0 < s, 0 < y); 


B:=coeff(Q,s,1); # Obviously positive

is(A < 0) assuming theAssumptions; # true

#The requirement for s being positive is:
sol:=s > -A/B; # -A/B is positive

#The result that I found using solve with the assumptions were (in your notation):
res:=solve(Q>0,useassumptions) assuming theAssumptions;

simplify(lhs(sol)-lhs(res6)); # 0


@Axel Vogt Note: I edited this comment.

Yes, s>1 is required, and that follows the result res[6]:

#Using my notation and your example:
eval(res[1..5],[a = 103/49 + sqrt(25776)/98, b=1/4,c=1, y=8]);
is~(%); # {true}
simplify(eval(%,[a = 103/49 + sqrt(25776)/98, b=1/4,c=1, y=8])); # 1<s


@Hahn Hahn If you look at the help page, which explains the workings of is (do ?is), you will see this:

"The is routine determines whether the given proposition is satisfied. It returns true, false, or FAIL.
The is function returns FAIL if it cannot determine whether the proposition is always satisfied. This is a result of insufficient information or an inability to compute the logical derivation."

Thus it will not give you conditions, but solve will:

expr:=(a - c)^2*y*(3*b*y - 1)/(2*(2*b*y - 1)^2) + (-a*(a + c)/(2*b) + (a - c)^2/(8*b) + s*(a - c)^2/(8*b^2));
sol:=solve(expr > 0);

You could also try solve with your assumptions:

res:=solve(expr>0,useassumptions) assuming 2*c < a, a/c < 2*b*y, 0 < a, 0 < b, 0 < c, 0 < s, 0 < y;

You will get 3 warnings, but a warning isn't an error!
The result res has 6 conditions: The first 5 are simple:

## {0 < b, 0 < c, a < 2*c*y*b, 1/b < y, 2*c < a}

The last res[6] is long so I will not give it here.
It can be simplified, however, but is still big.


You will see that the denominator on the left side of the inequality is positive. The right hand side is just s. Thus as long as the simple conditions res[1..5] are satisfied, condition res[6] is satisfied if just s is large enough.

@Hahn Hahn Could you please upload a worksheet?

@mmcdara I would replace Pi and sqrt(2) by evalf(Pi) and sqrt(2.), respectfully.
Then I don't get any errors of any kind in running your worksheet.

I use kernelopts(floatPi=false). If you use the default, which is floatPi=true, you may not need the first replacement;
you will, however, need the second.

5 6 7 8 9 10 11 Last Page 7 of 229