Preben Alsholm

13728 Reputation

22 Badges

20 years, 245 days

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@NorwegianStudent A simple way to use both of the packages you mention is this.
Save the 3 procedures from the smaller of the two packages in an .m file under their assigned short names.
Read them in at the beginning of a new session.
Now you can use with(package_name) for the larger and still use the procedures read in from the .m file.
I tried it like this:
 

restart;
libname:=libname,"F:/MapleDiverse/ShortPackage"; #path to the shorter package
exports(ShortPackage); #   procedures named xxx, yyy, zzz
xxx:=eval(ShortPackage:-xxx):
yyy:=eval(ShortPackage:-yyy):
zzz:=eval(ShortPackage:-zzz):
save xxx, yyy, zzz, "F:/MapleDiverse/ShortPackageTEST.m";

Now in a new session (or after a restart) you can do:
 

restart;
libname:=libname,"F:/MapleDiverse/LargerPackage"; # path to the larger package
with(LargerPackage);
read "F:/MapleDiverse/ShortPackageTEST";

Now the procedures in both packages are available to you.
The assumptions used here are that
1. The names used in ShortPackage (xxx,yyy,zzz) do not appear in LargerPackage.
2. The module ShortPackage has no locals.

@Christopher2222 I have already written the author, but have not received any answer yet.
If NorwegianStudent wants the renamed mla-file I suppose I could send it to him directly for his own personal use.

I think all packages in the Application Center have this note at the bottom of the accompanying Maple worksheet:

Legal Notice: The copyright for this application is owned by the author(s). Neither Maplesoft nor the author are responsible for any errors contained within and are not liable for any damages resulting from the use of this material. This application is intended for non-commercial, non-profit use only. Contact the author for permission if you wish to use this application in for-profit activities.

This quote is copied from the Introduction worksheet to the package FourierSeries by Wilhelm Werner.
Not being a lawyer I suppose that the quote implies that you don't have to contact the author if you are only going to use the application for personal non-profit use.
But uploading the rebuilt (and slightly renamed) package to MaplePrimes would make it available to everybody, so that seems to me a different matter. At least common courtesy must be aplied here.
 

@Christopher2222 As you are saying it is easy to rebuild the package and give it a new name since there are only 3 exports and no locals.
I did that and saved the code in a text file (.mpl). Then created an archive file. The renamed package works as the previous on the examples in Amir Khanshan's example worksheet.
I only had to rewrite some lines with `assuming` (for some obscure reason).
The immediate problem is, however, that the worksheet and the application are copyrighted: See the bottom of the worksheet.

@Jason Lee I didn't write "gradient = 1", but "gridrefine = 1", which does what it says: refines the grid.
See ?implicitplot under options.
Also try removing that option

plots:-implicitplot([eqn1,eqn2],x=-10..10,y=-10..10); #Without
plots:-implicitplot([eqn1,eqn2],x=-10..10,y=-10..10,gridrefine=1); #With

The intersections of the two curves are found as sol1, sol2, sol3, sol4 by fsolve in the code I gave.
Showing the points with the curves (also changing to the square -5..5, -5..5):
 

plots:-implicitplot([eqn1,eqn2],x=-5..5,y=-5..5,gridrefine=1); p1:=%:
S:=[seq(subs(sol,[x,y]),sol=[sol1,sol2,sol3,sol4])];
plot(S,style=point,symbolsize=20, color=blue); p2:=%:
plots:-display(p1,p2);

@Aidan01 If you want to define a function f that sends a into the integral, then the best approach in this case is definitely to use 'unapply':
 

f:=unapply(int(exp(-x^2)*sin(a*x),x=0..infinity),a);
f(6); #Example
evalf(%); 

In other cases where Maple cannot find the integral you can use numerical integration.
I shall illustrate it here with the very same integral although Maple can find the integral for symbolic a.
I begin with showing the inert form of int, which is spelled Int.
 

Int(exp(-x^2)*sin(a*x),x=0..infinity); # Notice Int as opposed to int: No computation!
f:= a-> evalf(Int(exp(-x^2)*sin(a*x),x=0..infinity)); # Definition of the function f
f(6); # f evaluates the integral numerically for a = 6.

 

@juju1234 When I execute your worksheet the weird output disappears and is replaced by the expected result:
Matrix(3, 3, [[-7015, -2308, -1306], [3397, -2634, -2278], [-2210, -8546, -5732]])

Is this actually in Maple?
I tried the following and it works as expected:
 

A:=LinearAlgebra:-RandomMatrix(3,generator=-99..99);
B:=LinearAlgebra:-RandomMatrix(3,generator=-99..99);
A.B;
A[2,3]:=777;
A;
A.B;

 

I tried Generate PDF under More ... . I asked that the file be opened in Foxit PhantomPDF. I received the error:
Format Error: Not a PDF or corrupted.

It appears to have 0 bytes.

@Rouben Rostamian  It may be worth while posting a proof that the present bvp problem doesn't have a solution y(x) that is positive for all 0 < x < 2945.
##
Notes:
The inequality ineq4 below will give L__crit when solved for L in terms of b=D(y)(L).
The inequality becomes an equality when D(y)(0) = y1 = 0.
##

## Proof that the given problem ode with the given bcs has no solution y(x) > 0 for all x > 0, x<=2945.

restart;
ode:=diff(y(x),x,x)=a*y(x)^q;
ics:={y(0)=0, D(y)(0)=y1}; # y1 >= 0 is necessary to ensure y(x) > 0 for x > 0.
## We assume q > 0, q < 1, a > 0, and that y(x) > 0 for x > 0.
## Thus y''(x) > 0, and y1 >= 0 is necessary to ensure y(x) > 0 for x > 0.
##
diff(y(x),x)*ode;
eq:=map(int,%,x)+(0=C/2);
eval[recurse](convert(eq,D),ics union {x=0});
eq1:=eval(eq,C=y1^2);
solve(eq1,{diff(y(x),x)})
## We need y'(x) >=0 all x, so pick the first:
ode1:=simplify(op(%[1])) assuming q>0;
## Now estimate
rhs(ode1) > eval(rhs(ode1), y1=0);
## So we have
lhs(ode1)> eval(rhs(ode1), y1=0);
ineq1:=simplify(%) assuming a>0;
## Thus by separation:
diff(y(x),x)*y(x)^(-(q+1)/2)>sqrt(2*a/(q+1));
map(int,%,x=0..X,continuous);
ineq2:=eval(%,{X=x,y(0)=0});
ineq3:=y(x)>(lhs(ineq2)*(1-q)/2)^(2/(1-q));
## So y(L) (L>0) is at least
ymin:=eval(lhs(ineq3),x=L);
eval(convert(ineq1,D),x=L);
## So the following inequality holds:
ineq4:=simplify(eval(%,y(L)=ymin)) assuming q>0,q<1,a>0,L>0;
## Now in the present case we have:
params:={a=0.00003019,q=0.337,x=2945,L=2945};
evalf(eval(ineq4,params)); #Result 0.2984244716 < D(y)(2945)
## But we also have
D(y)(2945)=0.0116;
## A contradiction. So we cannot have y(x) > 0 for 0 < x < 2945.

Now the inequality ineq4 in our case was 0.2984244716 < D(y)(2945), so it could be fun to see if dsolve/numeric/bvp can handle a value for D(y)(2945)  like 0.3 which is not much higher than 0.2984244716:
 

## Trying D(y)(2945)=0.3 (slightly higher than the lower limit found above.
## Using continuation:
ode1:=diff(y(x),x,x)=0.00003019*abs(y(x))^(c*0.337);
res:=dsolve({ode1,y(0)=0,D(y)(2945)=0.3}, numeric,method=bvp[midrich],initmesh=8192,continuation=c,abserr=0.3e-5,mincont=1/300);
plots:-odeplot(res,[x,y(x)],caption=typeset(D(y)(2945)=0.3)); #Looks good!

@Rouben Rostamian  Very nice, and the solution is nonnegative for all x, whereas my numerical solution is negative for all x > 0.
I was just about to give a proof that no solution exists with y(x) > 0 for 0 < x <2945 (in the present case).
Making use of the nonuniqueness of solutions starting with y(x0) = y'(x0) = 0 is a great idea.

 

@Mehdi Khalifeh Reading the description you provide I see that H(t) = (H1(t), 0, 0) and that M'(t) = (0, M2'(t), M3'(t)).
Thus H(t) . M'(0) = 0 for all t and so E = 0.
???

@dineshchawde You gave us an image. Thus to experiment with it we would have to type the whole thing ourselves. Needless to say, we don't like that. So please use text or upload a worksheet using the fat green arrow in the MaplePrimes editor.

@Axel Vogt Yes, following your rewriting we find that the integral over the fourth quadrant is given by 26.3.19 in A&S:
 

AS:=1/4-arcsin(B/sqrt(G))/2/Pi; #rho = -R/sqrt(G) in A&S 26.3.19
## Value from the guess:
v4:=arctan(sqrt(-B^2+G),B)/2/Pi;
##
df:=simplify(v4-AS) assuming G>B^2;
convert(df,arctan);
simplify(%) assuming G>B^2,B>0; # 0
simplify(%%) assuming G>B^2,B<0; # 0

 

@NorwegianStudent If a given function is already periodic you don't have to do anything: just plot it.
If, on the other hand, you intend to extend a function given on some interval a..b to a function periodic with period b-a then you could just use the following procedure PeriodicExtension:
 

PeriodicExtension:=proc (fip, itvl::{range, name = range}) local x, f, a, b, p, pr; 
   description "Input a procedure or an algebraic expression and an interval on the form a..b or x = a..b on which the function is given by the procedure/expression.\nOutput is a procedure/expression that is the periodic extension with period b-a."; 
  if type(itvl, range) then 
    f := eval(fip); 
    a, b := op(itvl) 
  else 
    x := lhs(itvl); 
    f := unapply(fip, x); 
    a, b := op(rhs(itvl)) 
  end if; 
  p := b-a; 
  pr := proc (x) f(x-floor((x-a)/p)*p) end proc; 
  if type(itvl, range) then eval(pr) else pr(x) end if 
end proc;
###
### Two examples:
f:=PeriodicExtension(x^2,x=0..1);
plot(f,x=-3..3,discont=true);
##
f:=PeriodicExtension(arcsin,-1..1);
plot(f,-3..3,discont=true);

To get the description do
Describe(PeriodicExtension);

Could you give a simple example of what you mean by "segregate different terms"?

First 57 58 59 60 61 62 63 Last Page 59 of 230