Preben Alsholm

13728 Reputation

22 Badges

20 years, 242 days

MaplePrimes Activity


These are answers submitted by Preben Alsholm

Here is another version.  (Note: I briefly had a slightly different version).

restart;
with(IntegrationTools):
f:=t^2*exp(-t)/ln(t);

J:=Int(f,t=0..infinity);
Change(J,t=exp(s));
Split(%,[-eps,eps]);
J1,J2:=op(1,%),op(3,%);
J1a:=Flip(subs(t=s,Change(J1,s=-t)));
Ja:=normal(combine(J1a+J2));
J:=eval(Ja,eps=0);
## Justifying putting eps=0:
g:=GetIntegrand(J);
series(g,s=0);


Your R is just an expression in t, not a function. Compare sin(t) with sin. The first is an expression in t the other is a function.
Thus the ode should not have R(t), but just R.
restart;
R := piecewise(t < 0.1e-7, 57, t > 0.1e-7, 57-48*exp(-t+0.1e-7)/(0.1e-7));

res:=dsolve({diff(y(t), t)-R*y(t)^2 = 0, y(0) = 1}, numeric);

plots:-odeplot(res,[t,y(t)],0..10^(-7));

############
To your comment in the last question:
I know that the laplace transform is a very useful tool; shouldn't Maple also know that?


Maple obviously knows that as you are also perfectly aware since you used method=laplace in dsolve and it worked (according to you).

Try this:
eq:=11.00=11.244522435+log(x) ;
solve(eq,x);
## The answer .7830784198 should come instantaneously.

You should give us your actual example.
I made up a simple one:
restart;
abs(1-exp(I*t))<1; #The one I want to solve, t being real
u:=evalc(abs(1-exp(I*t))); # evalc assumes that variables are real
res:=solve(u<1,t); #Three ranges (there are infinitely many)
plots:-complexplot(1-exp(I*t),t=0..2*Pi); #The whole curve (circle) in the complex plane
res2:=eval([res],{Open=(x->x),RealRange=`..`}); #For use in the plots below.
plots:-complexplot(1-exp(I*t),t=res2[1],scaling=constrained);
plots:-complexplot(1-exp(I*t),t=res2[2],scaling=constrained);#Just a repeat
plots:-complexplot(1-exp(I*t),t=res2[3],scaling=constrained);#Just a repeat

You can use:
ListTools:-Search([3,5],A);

I see two obvious reasons for the failure.

1. At each loop iteration the loop variable updates. At the end of the loop the variable i thus has the value nops(datalist)+1.

2. sum(enerList[i],,i=1..2) will give you a real problem: the arguments to sum are evaluated and i now has the concrete value nops(datalist)+1. So enerList[i] will complain (as it does), but had it not done it first, sum would have complained.

The solution is to use add instead of sum. That is by the way the recommended way for finite concrete sums as yours.
So use add(enerList[i],,i=1..2) instead. add has special evaluation rules; it is not bothered by the fact that i has a value.
Of course you could just have used a different variable (like j) or used unevaluation quotes around i as in 'i', but use add!

You are creating a new matrix inside the loop a:=J[1].J[1]; (i=1,j=1)
That new matrix has the same elements as J[1], but it is a separate mutable object: Thus you can change the one without changing the other.
Try this:
restart;
A:=Matrix([[1,0],[0,1]]);
B:=Matrix([[1,0],[0,1]]);
evalb(A=B); #False
A-B; # A zero-matrix
is(A=B); #False
LinearAlgebra:-Equal(A,B); #Elemenwise check: true
## A and B reside in different locations in memory:
addressof(A);
addressof(B);
##
## So you can try
printlevel:=2:
for i to 1 do for j to 2 do a := J[i].J[j]; map2(LinearAlgebra:-Equal,a,J) end do end do;
##and
for i to 8 do for j to 8 do a := J[i].J[j]; k:=ListTools:-Search(true,map2(LinearAlgebra:-Equal,a,J)); print(i,j,k,a) end do end do:
####
## Finally about not being of type matrix inside the loop. Of course it is! What happens is illustrated here outside any loop:
whattype(A); #Answer: Matrix
print(%); #Answer: A procedure is printed, the matrix constructor procedure.
showstat(Matrix); #To see all the lines in that procedure.


There are several problems:

1. In w:=laplace(I3,t,s): you need to have inttrans[laplace] instead of just laplace.

2. In w2:=limit(sz,t=infinity): you need limit(value(sz),t=infinity):

3. If you do type(w2,range); you get the answer true.
   Trying with w2MS:=MultiSeries:-limit(value(sz),t=infinity);
    you get undefined. Thus it appears that the limit doesn't exist.
##In fact the limit doesn't seem to exist. Just try:
 plot(value(sz),t=10..10.00001);

Or look at the output of
evalf(combine(expand(value(sz))));
If you choose to ignore the wiggles (which are there) and replace w2 by -1/3 as it seems to oscillate about, then you can plot easily:

plot(Re(w1)*(-1/3),d=0..5,tickmarks=[2, 2],thickness=2,linestyle=1,color=black,axes=boxed,titlefont=[SYMBOL,14],font=[1,1,18],tickmarks=[2,3],thickness=2);

Here is an answer to the first problem.

restart;
Expr:=a*diff(x(t),t)+b*x(t)+r*diff(x(t),t,t)+a*diff(y(t),t)+b*diff(y(t),t,t)+c*y(t);
L:=convert(indets(Expr,specfunc(diff)),list);
res:=coeffs(Expr,L,k);
k;
S:=seq(res[ListTools:-Search(L[i],[k])]*L[i],i=1..4),res[ListTools:-Search(1,[k])];
Expr:='Expr';
gc();
Expr:=add(i,i=S);

##Please see my comment to Kitonum's answer for the need for the two important lines in bold face.

You should look into formatted printing. See ?printf

printf("The solution to %a = %d mod %d is x = %d\n", a^x ,b, p, 1323);

In Maple 2016:

restart;
A:=Int( arctan(x) * ln(1+1/x^2), x = 0..infinity );
value(A); #No
evalf(A);
identify(%); #Pi^2/6
IntegrationTools:-Parts(A,arctan(x));
value(%); #Pi^2/6

eval(lhs(eq),{sin=0,cos=1});
eval(lhs(eq),{sin=1,cos=0});

Consider these 4 procedures, the first 3 with seq, the 4th with $ :

p1:=proc(n) local j,a,b; a:=j; b:=seq(a,j=1..n); b end proc;
p1(3); # j,j,j

p2:=proc(n) local j,a,b; a:=j; b:='seq'(a,j=1..n); b end proc;
p2(3); #Unevaluated seq.
%; #now fully evaluated

p3:=proc(n) local j,a,b; a:=j; b:=seq(eval(a),j=1..n); b end proc;
p3(3); # 1,2,3
## And now using $ :
q:=proc(n) local j,a,b; a:=j; b:=a$j=1..n; b end proc;
q(3); # 1,2,3

## You can replace seq with add or mul to get the same behavior in p1,p2,p3.
## You can replace $ with sum or product in q to get the same behavior.

I think this seq behavior is a combination of evaluation rules in procedures and the special evaluation rules for seq (similarly for add and mul).
### Try in p3 the following variation, where evaluation is only done to 1 level:
p3:=proc(n) local j,a,b; a:=j; b:=seq(eval(a,1),j=1..n); b end proc;
p3(3); #now j,j,j
Try replacing eval(a,1) by eval(a,2) and you have 1,2,3.
##########################
Now try at the interactive level:
restart;
a:=j;
eval(a,1); #Just to see
seq(eval(a,1),j=1..3); #j,j,j
## This latter behavior mimics the behavior of seq in the procedure p1.
###
### In the help page for seq you can find a description of how seq works, where it is constructed as a loop.
Adapting that to the situation in a procedure, where evaluation is done to one level only, we get for our present example:
restart;
a:=j;
S:=NULL;
old:=j;
for j from 1 to 3 do S:=eval(S,1),eval(a,1) end do;
j:=eval(old,1);
S;  #j,j,j






It may help to compare to sin^2 as done here:

f:=x^2;
f(3);
g:=sin^2;
g(3);
### It may also be illuminating to try this:
x^2(3);

The explanation for the output x^2 is that 2(3) is computed first. Numbers can act as constant functions, thus 2(3) = 2.

To get around the latter example use parentheses:
(x^2)(3);


We first show that the expression u below is independent of the variables:
u:=-Omega*a*sqrt(2)*sqrt(-Omega^2*a^2-2*k*m+sqrt(Omega^2*a^2*(Omega^2*a^2+4*k*m)))/(-Omega^2*a^2+sqrt(Omega^2*a^2*(Omega^2*a^2+4*k*m)));

## Clearly u only depends on the products Omega*a and k*m, so we need only consider:
w:=subs(Omega=1,m=1,u);
simplify(diff(w,a));
simplify(diff(w,k));
# Thus w is independent of a and k.
# Thus its value is:
simplify(eval(w,{a=1,k=1}));

First 48 49 50 51 52 53 54 Last Page 50 of 160