Preben Alsholm

13471 Reputation

22 Badges

20 years, 213 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

I don't know what you mean by wanting to create a vector x.
But in order to find out you could look at this code:
 

restart;
n:=3:
Theta:=<0.2,0.3,1.5>;
A:=<2,6,3>;
F:=<10,4,7>;
f:=unapply(add(A[i]*cos(F[i]*x+Theta[i]),i=1..n),x);
f(.9);
plot(f(x),x=-3..10);

Guessing: Could this continuation be it?
 

N:=10000:
X:=Vector(N,i->0.001*i);
Y:=f~(X);
plot(X,Y); # Just for illustration

 

I made som changes:
 

restart;
pde:=diff(<u1(x,t),u2(x, t)>, t) = Matrix([[0, mu*k^2/2], [2*A^2 - mu*k^2/2, 0]]).<u1(x,t),u2(x, t)>;
pdsolve(pde);

 

You could use subs as in this code:
 

A:=Int(r^2, m);
B:=subs(m=(m=a..b),A);

 

On my Maple 2022.2 I just added simplify:
 

restart;
g := piecewise((1/2)*t < 1/2, 0, (1/2)*t < 3/2, 1, 0)*piecewise(z/t < 1, 0, z/t < 2, 10080-60480*z/t+156240*z^2/t^2-226800*z^3/t^3+202230*z^4/t^4-113400*z^5/t^5+39060*z^6/t^6-7560*z^7/t^7+630*z^8/t^8, 0)/t;

Int(g, t=1..3);
value(%); 
simplify(%);

That brought an explicit answer. I don't have Maple 2015 on the computer I have available here, but it works on Maple 2021.2 too.

You can see the code for `evalf/constant/Pi` by doing showstat(`evalf/constant/Pi`);

There you see that there are 4 cases.
The global variable called _bigPi initially has 1000 digits.
Try this:

restart;
showstat(`evalf/constant/Pi`);
length(op(1,_bigPi)); # 1000
_bigPi;
evalf[2000](Pi);
length(op(1,_bigPi)); # 10000
_bigPi;

If you continue the session above with evalf[10001](Pi) you will find that now
length(op(1,_bigPi)) = 10001.
After a restart it will be back at 1000.

You may have expected something else than what comes out of the following slightly corrected version, if so let us know:
 

restart;
n:=5;
R:=Matrix(5,n);

for i from 1 to n do 
  R[..,i]:=sin(i*x);
end do;
R;
for i from 1 to 5 do
  #i:=i; # This line doesn't do anything useful, but isn't harmful
  x:=i;
  R[i,..] := sin(x);
end do;
R;

 

dsolve assumes that c and g are constants, so the first 4 solutions are constant solutions and 2 of these are imaginary when c and g are positive, which you assume.

I assume that you aren't interested in constant solutions. Thus the fifth solution is the one you want.

I don't think you can convert the JacobiSN function into a trigonometric function.

Here is an attempt to explain the situation when using assume.MaplePrimes22-09-29_assume.mw


 

restart;

A := Omega;          # A now evaluates to Omega
assume(0 < Omega);   # Omega will now evaluate to the local variable Omega~
B := Omega;          # B will now evaluate to Omega~ by the default full evaluation: first Omega then Omega~

Omega

Omega

type(Omega,`local`); # true

true

# All of the following 'is' commands result in 'true':

is(A>0);

true

is(Omega>0);

true

is(0 < B);

true

is(B=Omega);

true

is(A=B);

true

is(A=Omega);

true

about(A);

Originally Omega, renamed Omega~:
  is assumed to be: RealRange(Open(0),infinity)
 

about(Omega);

Originally Omega, renamed Omega~:
  is assumed to be: RealRange(Open(0),infinity)
 

about(B);

Originally Omega, renamed Omega~:
  is assumed to be: RealRange(Open(0),infinity)
 

Omega:='Omega';      # This assignment makes Omega just evaluate to its own name Omega

Omega

about(Omega);

Omega:
  nothing known about this object
 

about(A);            # A will first evaluate to Omega and Omega now just evaluates to its own name

Omega:
  nothing known about this object
 

about(B);            # B was assigned to Omega when full evaluation gave Omega~, thus B evaluates to Omega~.

Omega:
  is assumed to be: RealRange(Open(0),infinity)
 

is(B,`local`);       # true

true

 


 

Download MaplePrimes22-09-29_assume.mw

@acer I notice in Carl's second example that unwith followed by forget will restore the default diff.
That doesn't explain what's going on, but at least a restart is not necessary.

restart;
expr:=A/B+C;
#combine(expr);
normal(expr);

In Maple gamma is Euler's constant (see ?gamma), which is approximately equal to 0.5772156649. Try evalf(gamma).
Either of the remedies proposed by vv or tomleslie will work, however, in your case since either one is unaffected by that fact as only alpha*gamma appears. I also pointed that out in my answer to your previous question dealing with the same system. (https://mapleprimes.com/questions/234300-How-Can-I-Fix-Error-in-Dsolvenumericprocessinput ).
In general if you want to use gamma as just another name like alpha and beta, you can declare gamma local at the top of your worksheet as in:

restart;
local gamma;
## The rest ......

This only works in recent Maple versions. The one you use, Maple 2018, is included.
 

I deleted all the output that should not have been copied as Tom Leslie says.

Besides I corrected some typos and errors. So in that process I may have made my own errors.
The following appears to be what you want. Notice in particular that alpha*gamma never appears in your original equations, but alpha*m does. I changed that product to a single name: am.
 

restart; 

with(plots):  

U := [W(t), X(t), Y(t), Z(t)]; 
 f := (W, X, Y, Z) -> A-mu*W-delta1*Y-delta2*Z; 
 g := (W, X, Y, Z) -> beta*(W-X-Y-Z)*X-mu*X-X; 

h := (W, X, Y, Z) -> am*X-(mu+delta1)*Y; 

i := (W, X, Y, Z) ->(-am+1)*X-(mu+delta2)*Z; 

sys1 := diff(U, t) =~ [f(op(U)), g(op(U)), h(op(U)), i(op(U))]; 

ic1 := W(0) = W__0, X(0) = X__0, Y(0) = Y__0, Z(0) = Z__0;

equil := solve({f(w0, x0, y0, z0) = 0, g(w0, x0, y0, z0) = 0, h(w0, x0, y0, z0) = 0, i(w0, x0, y0, z0) = 0}, {w0, x0, y0, z0}); 

param1 := {A = 1, beta = 0.9e-3, delta1 = 0.139e-2, delta2 = 0.134e-2, mu = 0.132e-2, W__0 = 750, X__0 = .1, Y__0 = .2, Z__0 = .6, am = 0.4e-2}; 

param2 := {A = 1, beta = 0.9e-3, delta1 = 0.139e-2, delta2 = 0.134e-2, mu = 0.132e-2, W__0 = 755, X__0 = .2, Y__0 = .4, Z__0 = .9, am = 0.4e-2}; 

param3 := {A = 1, beta = 0.9e-3, delta1 = 0.139e-2, delta2 = 0.134e-2, mu = 0.132e-2, W__0 = 760, X__0 = .3, Y__0 = .6, Z__0 = 1, am = 0.4e-2}; 

param4 := {A = 1, beta = 0.9e-3, delta1 = 0.139e-2, delta2 = 0.134e-2, mu = 0.132e-2, W__0 = 765, X__0 = .4, Y__0 = .7, Z__0 = 1.4, am = 0.4e-2}; 

sol1 := dsolve(eval({ic1, op(sys1)}, param1), U, numeric); 

odeplot(sol1,[t,X(t)],0..30);
for j to 4 do
   p[j]:=odeplot(sol1,[t,U[j]],0..30);
end do:
display(Array([seq(p[j],j=1..4)]));

The plot of X(t):
MaplePrimes22-06-06_odesys.mw

This is tricky. That is why Physics:-Assume exists, I believe.
 

restart;
assume(A < B);
S := 2/(B-A);              
about(A);
about(B);
A;
subs(A=5,B=10,S); # 2/5
################
restart;
Physics:-Assume(A < B);
S := 2/(B-A); 
about(A);
A:=5; B:=10;
S; # 2/5

 

In view of the result of solving for the derivatives, it is a weird warning:
 

restart;
ode:={diff(x__1(t),t)*sin(x__2(t))=x__4(t)*sin(x__3(t))+x__5(t)*cos(x__3(t)),diff(x__2(t),t)= x__4(t)*cos(x__3(t))-x__5(t)*sin(x__3(t)),diff(x__3(t),t)+diff(x__1(t),t)*cos(x__2(t))= 1,diff(x__4(t),t)-(1-B)*x__5(t)= sin(x__2(t))*cos(x__3(t)),diff(x__5(t),t)+(1-B)*a*x__4(t)=sin(x__2(t))*sin(x__3(t))};
sys:=solve(ode,{seq(diff(cat(x__,i)(t),t),i=1..5)});
dsolve(sys); # No warning (and likely, no result).

Numerical solution causes no problem.
Note:  Setting infolevel[dsolve]:=5: reveals some of what is going on.

Instead of using surd, you could try RealDomain:

with(RealDomain);
plot(x^(1/3),x=-2..2,thickness=3);
plot(x^(1/3),x=-2..2,thickness=3,adaptive=true);

I did this in Maple 2022.0 and got these two graphs:

and

In Maple 2022 adaptive=true isn't the default. In this case it appears that adaptive=geometric (new in 2022) is used for the default.
It doesn't work so well in this case.
Even surd doesn't work well if you stay within RealDomain.
But if you leave RealDomain it works fine:
 

restart;
with(RealDomain);
plot(x^(1/3),x=-2..2,thickness=3); # Not good
plot(x^(1/3),x=-2..2,thickness=3,adaptive=true); # OK
plot(x^(1/3),x=-2..2,thickness=3,adaptive=geometric); # Not good
plot(surd(x,3),x=-2..2,thickness=3); # Not good
unwith(RealDomain);
plot(surd(x,3),x=-2..2,thickness=3); #OK

I shall report this, although it might already be known.

3 4 5 6 7 8 9 Last Page 5 of 158