Preben Alsholm

13603 Reputation

22 Badges

19 years, 205 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

Try this:

restart;

foo1:=overload([                   
                  proc(P1::list,P2::list,P3::list,$)
                      option overload(callseq_only);
                    [P1,P2,P3]
                  end proc,
                  proc(P1::list,P2::list,a::algebraic:=4,$)
                      option overload;
                    [P1,P2,a]
                  end proc
                       ]):
foo1([1,2],[3,4]); 
foo1([1,2],[3,4],x);
foo1([1,2],[3,4],[4,7]);

See ?overload where we read:
"If p1 raises an exception during the parameter type-checking phase only (not inside p1), and option overload(callseq_only) has been specified, then execution will proceed to p2(x,y)."

Note: See below for my comment on Ronan's original foo1.
Also try running my example above with option overload instead of option overload(callseq_only):
The results are the same. Thus the answer to the (revised) title is it didn't matter here.
Option overload(callseq_only) was introduced in Maple 16, but no example where it matters was given.

restart;
f :=piecewise(0 <= x and x <= 1.588125352, (-1)*0.39*x^2 + 1.459*x - y, 1.588125352 < x and x < 4, (x - 1.81)^2 + (y - 0.42)^2 + (-1)*0.94^2);

plots:-implicitplot(f, x = 0 .. 3, y = 0 .. 1.5, scaling = constrained,gridrefine=4,signchange=false);

In order to see that a sign change takes place you could try this:

plot3d([f,0],x = 0 .. 3, y = 0 .. 1.5);

 

Try this:

restart;
interface(typesetting=extended);
exp(-a); # No visible minus sign
interface(typesetting=standard);
exp(-a); #Fine also in Maple 2023.2

This produces the same as your code:
 

restart;
X := Matrix(
   [[1, -X3_3/2 - 1/2, 0, -X2_3], [-X3_3/2 - 1/2, -2*X3_4 - 1, X2_3, 0], [0, X2_3, X3_3, X3_4], [-X2_3, 0, X3_4, 1]]
            );
####
vars := [X3_4, X3_3, X2_3];
w := A^3 - A;

rts:=solve(w,A);
Pols := [(-A^2 + 1)/(3*A^2 - 1), (-A^2 - 1)/(3*A^2 - 1), A*(3*A^2 - 1)*1/(3*A^2 - 1)];
####
vals:=map2(eval,Pols,A=~{rts});
ecs:=[seq](vars=~(vals[i]),i=1..3);
Nelem := [seq(k, k = 1 .. numelems(vals))];
####
Xs:=[seq(eval(X, ecs[i]),i=Nelem)];
####
with(LinearAlgebra):

Eigs := Eigenvalues~(Xs);

BoolEigs:=map((y->is(Im(y) = 0 and 0 <= Re(evalf(y))))~ ,Eigs);

 

Maple can do it for you. It uses a finite difference method.
 

restart;
eq1 := (diff(f(x), x, x, x))*(a*beta*f(x)^2-1)+(diff(f(x), x))^2-2*a*beta*f(x)*(diff(f(x), x))*(diff(f(x), x, x))+(diff(f(x), x))*(M+k[1])-(diff(f(x), x, x))*f(x)-(alpha*theta(x)+delta*phi(x))/rho = 0;

eq2 := -(diff(theta(x), x, x))*K[SB]*(Df-(Rd+k[hnf]/k[bf])/Pr)+N[t]*K[SB]*(diff(theta(x), x))^2-N[b]*(diff(theta(x), x))*(diff(phi(x), x))-(diff(f(x), x))*(diff(theta(x), x))-lambda*theta(x)-mu*Ec*(M*(diff(f(x), x))^2+(diff(f(x), x, x))^2) = 0;

eq3 := diff(phi(x), x, x)+Le*Sr*(diff(theta(x), x, x))+Le*f(x)*(diff(phi(x), x)) = 0;

ics := f(0) = 0, (D(f))(0) = 0, theta(0) = 1, phi(0) = 1;

bcs := (D(f))(100) = 0, theta(100) = 0, phi(100) = 0;


Parameters1 := rho = 2063.905, k[hnf] = .29942, k[bf] = .2520, mu = .38694, a = .1, beta = 5, k[1] = 2.0, M = 10, alpha = 20, delta = 20, K[SB] = .5, Df = 3, Pr = 1.2, Rd = 5, N[t] = 1.2, N[b] = 1.0, lambda = 1.5, Ec = 5, Le = .1, Sr = .1;

 

sys:={eq1,eq2,eq3,ics,bcs};
res:=dsolve(eval(sys,{Parameters1}),numeric);
with(plots):
odeplot(res,[x,f(x)]);
scene:=[  [x,f(x)],[x,theta(x)], [x,phi(x)]  ];
display(Array([seq(odeplot(res,scene[i],thickness=2,color=blue),i=1..3)]));
scenediff:=evalindets(scene,function,fu->diff(fu,x));
display(Array([seq(odeplot(res,scenediff[i],thickness=2,color=red),i=1..3)]));

You may want a better look at the first part of the interval x = 0..100.
Just add the interval as done here for x = 0..20:
 

display(Array([seq(odeplot(res,scene[i],0..20,thickness=2,color=blue),i=1..3)]));
display(Array([seq(odeplot(res,scenediff[i],0..20,thickness=2,color=red),i=1..3)]));

 

restart;
Digits:=40;
plot( x*exp(-x),x=0..20,adaptive=true); 
?adaptive
# Quote: The adaptive = geometric option is used for non-parametric plots in the Cartesian coordinate system

The terrible result you get is caused by the default adaptive=geometric.

You could look at this:

restart;
showstat(`convert/rational`);
interface(verboseproc=2);
eval(`convert/rational`);

Several comments first:
You should use is, not evalb.

You need more assumptions, like positivity of other constants.

The name gamma stands for Euler's constant which is roughly 0.5772156649.
I would recommend using assuming instead of assume.
This works:

restart;
is((a - c)/(3*b) < gamma*(a - c)/(3*b*gamma - 1)) assuming 2*c < a, 0 < a, a/c < 3*b*gamma,c>0,b>0;
### Answer true

There is no error:
After all int(f(x),x=0..1) is exactly the same as int(f(y),y=0..1).
Thus I see nothing wrong here:

J := Int(r[1]^2*phi[1](r[1]), r[1] = -infinity .. infinity)
     *
     Int(r[2]^2*phi[2](r[2]), r[2] = -infinity .. infinity); 

simplify(J);
##Result: Int(r[1]^2*phi[1](r[1]), r[1] = -infinity .. infinity)*Int(r[1]^2*phi[2](r[1]), r[1] = -infinity .. infinity)
## There is only visual difference between the above result and that from:
map(simplify, J);
## The name of the integration variable in a definite integral is irrelevant.


Here is a much simpler looking example:

restart;
J:=Int(f(x),x=0..1)*Int(g(y),y=0..1);
simplify(J);
simplify(value(J));

 

Use unevaluation quotes around the whole expression:
 

'P(X <= 5) = P(-5 <= -X) and P(-5 <= -X) = P(E(X) - 5 <= E(X) - X)';

The evaluation to false will come after a % is executed as in
 

'P(X <= 5) = P(-5 <= -X) and P(-5 <= -X) = P(E(X) - 5 <= E(X) - X)'
%;  # false

 

evalb(2+2=4);
https://mapleprimes.com/questions/237373-How-To-Answer-Your-Own-Question-On-MaplePrimes

This is rather intriguing.
It seems that the difference lies in the different addresses of your tabletop produced array and the one coming out of Maple's DEplot:
 

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):
#####################################
ode2:=3*y(t)+t*diff(y(t),t) = t^2-t+1;
p2:=DEtools:-DEplot(ode2,y(t),t=0..3.5,y=0..3):
#####################################
A0:=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);
#####################################
whattype(A0);
has(A0,HFloat(undefined)) ;
A1:=op([1,2],p1);
whattype(A1);
has(A1,HFloat(undefined)) 
A2:=op([1,2],p2);
whattype(A2);
has(A2,HFloat(undefined))
######################################
H0:=indets(A0,float)[1];
addressof(H0);
H1:=indets(A1,float)[1];
addressof(H1);
H2:=indets(A2,float)[1];
addressof(H2);
addressof(H1)-addressof(H2); # 0
has(A0,H0); #true
has(A1,H1); #true
has(A2,H2); #true
has(A0,H1); #false
has(A2,H1); #true

If you continue in the same session with this:
 

HFloat(1/0.);
addressof(%); 

you get an address different from the previous.

The code:

int( (3*x^2-2*x+1)/sqrt(x^3+x^2-2*x),x);
simplify(%);

The result of the simplification is this:
2*(2*sqrt(-x)*(EllipticE(1/2*sqrt(2*x + 4), 1/3*sqrt(6)) - 1/12*EllipticF(1/2*sqrt(2*x + 4), 1/3*sqrt(6)))*sqrt(-3*x + 3)*sqrt(2)*sqrt(2*x + 4) + x^3 + x^2 - 2*x)/sqrt(x^3 + x^2 - 2*x)

### If you want definite integrals, you do like this:
 

f:=(3*x^2-2*x+1)/sqrt(x^3+x^2-2*x); # For convenience
plot(f,x=-5..5); # Plotting
## Notice that nothing is plotted between 0 and 1.
## That is because f is imaginary in that interval.
int(f,x=0..1); # Exact
evalf(%); #  A numeric approximation
int(f,x=0..1,numeric); # Directly
int(f,x=1..10,numeric);
int(f,x=1..10);
evalf(%);

 

Since this initial value problem has infinitely many solutions it would cost some more work to write down a formula for these.

The solution we receive first y(x) = 0 is the one that dsolve/numeric would have to come up with.

restart;
ode:=diff(y(x), x) = sqrt(y(x))*sin(x);

dsolve([ode,y(0)=0]);

sol:=dsolve([ode,y(0)=0],'implicit');
eq:=isolate(sol,sqrt(y(x)));
sol2:=op(solve(eq,{y(x)})) assuming y(x)>=0; #sqrt(z) returns the principal branch.
plot(rhs(sol2),x=-2*Pi..2*Pi);
## An example of the infinitely many solutions (not identically zero) to the initial value problem:
sol3:=y(x)=piecewise(x>=0 and x<2*Pi,0,rhs(sol2));
plot(rhs(sol3),x=-2*Pi..4*Pi);
####
res:=dsolve([ode,y(0)=0],numeric);
plots:-odeplot(res,[x,y(x)],-2*Pi..2*Pi,thickness=3);

 

There is no problem with invlaplace in my Maple 2023.1:
kernelopts(version);
`Maple 2023.1, X86 64 WINDOWS, Jul 07 2023, Build ID 1723669`

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