Preben Alsholm

MaplePrimes Activity


These are replies submitted by Preben Alsholm

@vv Just a comment on infolevel: With  infolevel[Basis]:=3:  (or 2) we do get information, but it may not be of interest to codell.
Since the procedure remembers the information will only come the first time it is run with the given input.

 

I have never heard of acximetric tolerance. Is it spelled correctly?
You could be a little more specific and provide an actual example.
When you say " For example +10/-5" I still don't get what you are talking about.

I read at the top of the pdf file containing the problems as formulated by your teacher:
"Studentene får hver sin oppgave, som skal løses selvstendig."'

Does that not exclude getting help from MaplePrimes? Ask your teacher.

@tomleslie I have noticed before that these problems come up too often for students in Denmark.
I cannot read the uploaded file either.

Personally, I haven't had these problems in years although my computer is made for use with Danish characters and bought in Denmark.
Years ago when I occasionally had problems, I started a habit of never (well, almost never) saving a worksheep with output.
I routinely remove all output from the worksheet before saving it by going to
Edit/Remove Output/From Worksheet.
Another thing is that I never use 2D math input or fancy text. My worksheets are rather plain, but I do use the Standard Interface (with Maple Input and Worksheet mode).
##
acer has been able to rescue some people in the past.

@Markiyan Hirnyk Where do you find HINT=sum documented?
HINT=xxx works the same:
 

restart;
PDE := (y-u(x, y))*diff(u(x, y), x)+(u(x, y)-x)*diff(u(x, y), y) = x-y;
infolevel[pdsolve] := 3: 
ans := pdsolve(PDE, HINT = xxx);

 

@oceanxinlie To answer your question: 
Why do you set "approxsoln=[y(x)=tanh(x)]" ?
let me first say that dsolve/numeric/bvp has to construct a starting solution itself (an approximate solution) if none is given by the user.
To do that it uses the boundary conditions only, i.e. y(0) = 0 and y'(0) = 0. It uses a polynomial of lowest possible degree satisfying those conditions. In this case that is the trivial y(x) = 0.
Since we might have some idea about the form of the solution it is often a good idea to give an approximate solution. It need not be very good. In this case the one I used happens to be rather bad since tanh(x) > 0 for all x > 0.
But it happened to work!
Among nonzero polynomial approximate solutions this one is an example and it works fine:
y(x) = (1/2945)*x^2-2*x.

@oceanxinlie I was a little slow in seeing the obvious: The solution to your ode with the boundary conditions as given can never attained a positive value.
Here is the proof:
First of all notice that if the ode is written as
y''(x) - a*y(x)^0.337 = b*x, a > 0, b > 0,
then for the term y(x)^0.337 to make sense (be real) we must demand y(x) >= 0 for all x.
But from the ode it follows that
y''(x) = a*y(x)^0.337 + b*x
thus y''(x) >= b*x, so by integrating from 0 to x we get y'(x) - y'(0) >= (b/2)*x^2.
But y'(0) cannot be negative since then y(x) would be negative for some x near 0.
Thus it follows that y'(x) >= y'(0) + (b/2)*x^2  >= (b/2)*x^2 > 0 for x > 0.
So the solution cannot satisfy y'(2945) = 0.
## Suppose then that the ode is rewritten as y''(x) - a*abs(y(x))^0.337 = b*x.
Then there it isn't different from the first one if y(x) >= 0 all x. Thus the same conclusion.
Now suppose that there is an x1 with y(x1) < 0. If the solution is to assume a positive value for some x2 > x1 then we may assume that also y'(x1) > 0 since if no such x1 < x2 existed y(x2) couldn't be positive.
Thus we have y''(x) = a*abs(y(x))^0.337 + b*x >= b*x.
So by integrating from x1 to x > x1 we get
y'(x) - y'(x1) >= (b/2)*(x-x1)^2
and therefore
y'(x) >= y'(x1) + (b/2)*(x-x1)^2  >= (b/2)*(x-x1)^2 > 0 for x > x1,
which makes y'(2945) = 0 impossible.

Using another revised version still gives a negative result and one that is about 1.75*10^5 times smaller in absolute value than the one where abs is used:

restart;
Digits:=15:
u:=piecewise(y(x)>=0,y(x)^0.337,0);
ode2:=diff(y(x),x,x)-0.00003019*u=9.542*10^(-13)*x;
bcs:=y(0)=0,D(y)(2945)=0;
res2:=dsolve({ode2,bcs},numeric,method=bvp[midrich],approxsoln=[y(x)=tanh(x)]);
plots:-odeplot(res2,[x,y(x)]);

## NOTE: This 'desperate' attempt to get a positive solution by rewriting the ode ends up just giving the same as the one where u = 0.

@Christopher2222 Yes, in my experience you can set libname only once in a session and expect it to work.

@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]])

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