Preben Alsholm

13593 Reputation

22 Badges

19 years, 182 days

MaplePrimes Activity


These are replies submitted by Preben Alsholm

As seen (until tomorrow)  in my answer to my own test question "How to determine if 2+2 = 4?" I'm able to select my own answer as the best answer. It ought not be possible in my view! I received 7 points. Nobody is able to give himself 5 points by giving the answer a vote up. Why should it be different for selecting the best answer?
I shall remove my question and my 7 points tommow morning (Sunday).

@Carl Love Thanks, I shall remove the whole thing, including the points, tomorrow morning.

@Preben Alsholm I prefer that it is removed!
(And the 7 points I received are deducted as well!)

I shall do a test question and quickly answer it myself to see what happens.

Surely Maple isn't using textbook methods from typical ode courses in college.
I'm not surprised that different methods lead to different looking results, where both are correct.
The lengthy one, which actually has an inert integral, can be made to look like your simple one:
 

val:=value(y_general_direct_method):
sol:=simplify(evalc(val)) assuming x>0;
length(sol);       # 769
length(y_general); # 643
odetest(sol,ode);  #0

 

I realize that the following "solution" is besides the point, but here it is:

foldr(subsop,expr,1=a,2=b,3=c,4=d);
foldr(subsop,expr,4=d,3=c,2=b,1=a);
foldr(subsop,expr,2=b,3=c,4=d,1=a);
## All return a*b*c*d

foldr also works in the new example by C_R:

foldr(subsop,expr,1=a,2=b);
## a*b*(46*r0 - 41*Delta_r)*r0^5

This appears to be an "ancient" bug: Maple 12 as well as Maple 2021, 2022 has it too.
The problem is the real number (-1) as the first operand. Same problem with any other concrete real number like 7. No problem with sqrt(2).

@nm It appears that the different addresses problem is due to using hardware floats.
So here is another way out using your original example:
 

restart;
ode2:=2*y(t)+t*diff(y(t),t) = t^2-t+1;
p:=DEtools:-DEplot(ode2,y(t),t=0..3.5,y=0..3,
                        linecolor = red,                        
                        arrowsize ='magnitude',
                        numpoints = 200 ,
                        axes = boxed,color = ('magnitude[legacy]')):
###############################################
p0:=Array(1 .. 3,1 .. 2,{(1, 1) = HFloat(undefined), (1, 2) = HFloat(undefined), (2
, 1) = HFloat(undefined), (2, 2) = HFloat(undefined), (3, 1) = HFloat(undefined
), (3, 2) = HFloat(undefined)},datatype = float[8],order = C_order);
####
has(p0,HFloat(undefined)); 
p1:=op([1,2],p);
has(p1,HFloat(undefined)); 
################ Now convert to software floats:
p0S:=convert~(p0,'sfloat');
p1S:=convert~(p1,'sfloat');
has(p0S,Float(undefined));# true
has(p1S,Float(undefined)); # true

 

Just an observation: If you remove the option arrowsize ='magnitude' then you don't get an empty plot, although there are undefined parts.

@nm Whether this is a bug or only a weakness I can't tell.
Here is a procedure which at least handles the present situation:
 

restart;
ode1:=2*y(t)+t*diff(y(t),t) = t^2-t+1;
p1:=DEtools:-DEplot(ode1,y(t),t=0..3.5,y=0..3):

ode3:=3*y(t)+diff(y(t),t) = t^2-t+1;
p3:=DEtools:-DEplot(ode3,y(t),t=0..3.5,y=0..3):
p3;
#####################################
HasUndefined:=proc(p) local L,q,res; 
   L:=select(type,[op([1,1..-1],p)],'hfarray');
   ##########
   q:=proc(a::hfarray) local ar:=type~(a,realcons);
          if convert(ar,set)={true} then true else false end if
   end proc;
   ##########
   res:=remove(q,L);
   if res<>[] then true else false end if
end proc:
HasUndefined(p1); #true
HasUndefined(p3); #false

 

This seems to be a way around the problem: Fishing out the undefined:

###Continuing with A0, A1, and A2:
evalb(op(2,indets(A1,hfloat)[1])=undefined);
evalb(op(2,indets(A2,hfloat)[1])=undefined);
evalb(op(2,indets(A0,hfloat)[1])=undefined);
# All 3 return true.

@Carl Love I haven't installed the Physics Uptates package.

In fact I haven't been able to do that. I had no problems in Maple 2021 or 2022.

@Christian Wolinski Maybe I don't understand what you mean by the whole mechanism of assume.
I certainly think that the `assuming` facility is very useful, but it isn't perfect; nothing is.
My example function f:=x->a*x  was applied to a, not some other name or number. That was the cause of the problem , but solved by using simplify/assume.

In your case there was no reason for me not to use assuming, because assumption are put on x and there is no possibilty for any conflict between two versions of x as there was in my example with a.

restart;
y:=sqrt((x^2*(x^2-4))/(x^2-1));

minimize(simplify(evalc(Re(y))),x=-1..1,location) assuming x<1,x>-1;

maximize(simplify(evalc(Re(y))),x=-1..1,location) assuming x<1,x>-1;

minimize(simplify(evalc(Re(y))),x=2..infinity,location) assuming x>=2;

maximize(simplify(evalc(Re(y))),x=2..infinity,location) assuming x>=2;


 

@Christian Wolinski Not much use is made these days of this version of simplify with assumptions:
 

restart;
f:=x->a*x;
simplify(sqrt(f(a)),assume=[a<0]); # -a
simplify(sqrt(f(a))) assuming a<0; # See below
lprint(%);

The difference is that in the first simplify version sqrt(f(a)) is evaluated to sqrt(a^2) and then simplified under the assumption a<0.
In the second case the assumption is placed on the a we can see, i.e. the argument to f , before anything else is done.
This second case is illustrated by:
 

restart;
debug(`assuming`);
f:=x->a*x;
simplify(sqrt(f(a)))  assuming a<0;

You will see that the first thing that happens is that the a in sight is replaced by a~, the a used in the definition of f is not changed.
Thus there are 2 totally different versions of a. So the evaluation will be of sqrt(a*a~) where nothing is known of the first a.
So it will only result in (a*a~)^(1/2).

Finally after that there is 'cleaning' where the tilde is removed before output resulting in (a^2)^(1/2).

####
If you try the assumption a>=0 you may be surprised that both versions of simplify return a,
To see why try this:

restart;
f:=x->a*x;
simplify(sqrt(f(a))) assuming a>=0; # a
### Explanation:
simplify(sqrt(a1*a)) assuming a1>=0;
subs(a1=a,%);
simplify(sqrt(a1*a)) assuming a1<0;
subs(a1=a,%);

#### Making use of simplify/assume in the present case:
 

restart;
y:=sqrt((x^2*(x^2-4))/(x^2-1));
solve(evalc(Im(y)), x);
minimize(simplify(evalc(Re(y)),assume=[x<1,x>-1]),x=-1..1,location);
maximize(simplify(evalc(Re(y)),assume=[x<1,x>-1]),x=-1..1,location);
minimize(simplify(evalc(Re(y)),assume=[x>=2]),x=2..infinity,location);
maximize(simplify(evalc(Re(y)),assume=[x>=2]),x=2..infinity,location);

 

You seem to have the list:  [x(y), y(x)] which doesn't make much sense here.
An example resembling yours:
 

restart;
ode:=diff(y(x),x,x)+y(x)^2=sin(x);
DEtools:-phaseportrait(ode,y(x),x=0..2,[[y(0)=1,D(y)(0)=3]]);

@MagnusMJ A maple.ini file has to be created by the user. I have one and I put it in the location:
C:\Users\userid\maple.ini, where userid is my user id.
Use an ordinary text editor like Windows' Notepad. Save the file as maple.ini.
For more information see ?
Create maple.ini .
##################
Somebody told me a long time ago to: (now a quote from my maple.ini file)
#Make sure that % = NULL by putting all statements inside a procedure
#that returns NULL.
#####
thus mine starts like this:
proc()
.....
the statements you want
.....
NULL
end proc():

First 6 7 8 9 10 11 12 Last Page 8 of 228