acer

32485 Reputation

29 Badges

20 years, 7 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

These all just showed as blank pages in my firefox browser. Did they work for anyone else?

acer

It's unclear whether you are looking for a floating-point numeric result or not. It may be that you want Int rather than int, but the 2D Math shown here obscures what you're already trying.

Judging by an earlier post of yours, there may also be some misunderstanding about passing functions versus expressions to int (premature evaluation issues, etc).

I suggest posting some 1D (non graphically marked up math) input, with as much of an explicit example as you can.

That error message that you received is likely tied to the particular definition of your integrand. And without more details on f, it's hard to offer concrete advice.

acer

One could create a procedure to do this, perhaps utilizing StringTools:-ParseTime.

The code below could be corrected to adjust more accurately for leap years. (Ie. correct it for years evenly divisible by 100 and by 400, and not simply for years divisible by 4.)

> with(StringTools):
> dt1:=ParseTime("%x","01/01/76"):
> dt2:=ParseTime("%x","01/01/77"):
> dt2:-year*365 + signum(irem(dt2:-year,4))
>   - dt1:-year*365- signum(irem(dt1:-year,4))
>   + dt2:-yearDay - dt1:-yearDay;
                                      366

There is also some accurate data to be had from the Units package. See the ?Units,year help-page, including its Examples section.

acer

You can also solve it using LinearAlgebra commands.

> with(LinearAlgebra):
> A,b := GenerateMatrix([2*x+3*y+z=8,-x+2*y-z=3,3*x-4*y+z=-5],[x,y,z]);
                                [ 2     3     1]  [ 8]
                                [              ]  [  ]
                        A, b := [-1     2    -1], [ 3]
                                [              ]  [  ]
                                [ 3    -4     1]  [-5]
 
> S := Matrix([A,b]); # augmented Matrix, represents system
                               [ 2     3     1     8]
                               [                    ]
                          S := [-1     2    -1     3]
                               [                    ]
                               [ 3    -4     1    -5]
 
> RowOperation(S,[2,1]); # exchange 1st and 2nd rows
                            [-1     2    -1     3]
                            [                    ]
                            [ 2     3     1     8]
                            [                    ]
                            [ 3    -4     1    -5]
 
> RowOperation(%,1,-1); # scale 1st row by -1
                             [1    -2    1    -3]
                             [                  ]
                             [2     3    1     8]
                             [                  ]
                             [3    -4    1    -5]
 
> RowOperation(%,[2,1],-2); # add -2 times 1st row to 2nd row
                             [1    -2     1    -3]
                             [                   ]
                             [0     7    -1    14]
                             [                   ]
                             [3    -4     1    -5]

You should be able to do the rest, if you know how Gaussian elimination works.

You mentioned `solve`.

> solve([2*x+3*y+z=8,-x+2*y-z=3,3*x-4*y+z=-5],[x,y,z]);
                            [[x = 1, y = 2, z = 0]]

> LinearSolve(A,b);
                                      [1]
                                      [ ]
                                      [2]
                                      [ ]
                                      [0]

acer

How you go about it depends on the actual data structures that contain your data. (In Maple lists are not arrays, and are not Vectors, etc.) Your post seems to indicate that you want the data put in the form of a list of lists.

Also, there are often a few ways to do such things.

> X,Y:=<1,2,3>,<7,8,9>: # two Vectors
> <X|Y>;
                                   [1    7]
                                   [      ]
                                   [2    8]
                                   [      ]
                                   [3    9]
 
> convert(<X|Y>,listlist);
                           [[1, 7], [2, 8], [3, 9]]
 
> [seq([X[i],Y[i]],i=1..min(op(1,X),op(1,Y)))];
                           [[1, 7], [2, 8], [3, 9]]
 
> X,Y:=[1,2,3],[7,8,9]: # two lists
> zip((a,b)->[a,b],X,Y);
                           [[1, 7], [2, 8], [3, 9]]
 
> [seq([X[i],Y[i]],i=1..min(nops(X),nops(Y)))];
                           [[1, 7], [2, 8], [3, 9]]
 
> kernelopts(version);
            Maple 9.03, IBM INTEL LINUX, Oct 1 2003 Build ID 141050

acer

I have this problem with using my own ISP's own (yahoo-based) webmail service from home, or when accessing my workplace's (Outlook) webmail. The only solution of which I'm aware it to ask people to resend their attachments, compress/zipped/gzip'd.

Doug mentioned a severe case of this here.

This could be fixed by Maplesoft, by implementing automatic compression/decompression in the Maple product (Standard GUI) itself. It's not clear how that would affect functionality which depended on worksheets' being in plaintext. Perhaps the GUI could be changed to handle both compressed and uncompressed instances of worksheets.

acer

If one uses plaintext files to store the Maple source code then it is possible to set this up using the $include, $define, and related directives. The basic idea is this:

  • set up code in separate text files
  • have master text code file $include them
  • use $define to set values (like your fix_A) in source files
  • have master file `savelib` procs to .mla, using libname
  • access .mla in other (eg.GUI) sessions using libname

The benefits of this are several. For one thing, the source code is very safe, as plaintext. (Have you ever had a corrupt worksheet, from which you could not extract your code?) Also, a revision control system such as RCS works much better with code as plaintext. And also it gives the main benefit that you've described -- the source can be well-organized.

The trick is that those directives only work in the commandline interface of Maple. In MS-Windows this is called cmaple.exe, and normally runs in what looks like an old DOS window. The commandline interface of Maple is a joy on Linux, but less pleasant on Windows. It can be made easier by using cygwin on Windows to get a nice shell.

I have been wanting to write a tutorial on this, for the mapleprimes book section, for a while now. But it's hard to find the time.

acer

That quoted sentence does seem to be offering to compute and return the L. I agree that the pair of nouns "factor" and "Matrix" are a little grammatically dubious there, side by side. I see where this comes from now -- it's the tooltip on a context-sensitive submenu item that shows when one right-clicks on a Matrix as output.

You may already know the following, and since I'd already typed it out...

PLU is Gaussian elimination in mild disguise. Normally, when one does GE one does not keep track of the row swaps or the pivoting  divisions/addtions. One usually just keeps the  Matrix on which those actions take place. That Matrix  ends up being the U of PLU.

But the other information can be stored too (but isn't usually, in the GE that one learns in a first course). The row swaps (when there is a choice of pivot, when working on given leading column) can be stored in the P. The pivoting actions can be stored in the L.

What makes PLU extra attractive is that, having expended the O(N^3) cost of factorizing A=PLU once, one can then apply that to solving multiple RHSs which is only a further O(N^2) cost of forward- and back- substituting. One can backwards substitute by using the U, and then forwards substitute using the L.

In Maple, the ConditionNumber, MatrixInverse, and LinearSolve routines accept the P and LU in lieu of Matix A. They allow one to capitalize on doing the factorization  (just) once.

ps. I believe that, if one looks at it the right way, Cholesky can be seen as a form of LU as well.

acer

Here's another way,

> with(Units:-Standard,sin,cos):

> sin(30*Unit(degrees));
                                      1/2
 
> cos(30*Unit(degrees));
                                      1/2
                                     3
                                     ----
                                      2

Note that this approach doesn't make inverse trig operations return results in terms of degrees.

 

> Units:-Standard:-arcsin(1/2);
                                      Pi
                                     ----
                                      6

acer

This can be done is several ways. Here is one way, which allows one to use the name sin while retaining the original as :-sin.

> T := module() option package;
> export sin, cos;
>   sin := proc(x) :-sin(x*Pi/180); end proc:
>   cos := proc(x) :-cos(x*Pi/180); end proc:
> end module:

> with(T);
                                  [cos, sin]
 
> sin(30);
                                      1/2
 
> :-sin(Pi/6);
                                      1/2
You could fill in module T with definitions for other trig functions.

acer

The best choice of method can depend on the form of the expression. The double-exponential method _Dexp may be appropriate for one integrand, while _d01akc may be more appropriate for an oscillatory integrand, etc.

The default can be obtained as method=_DEFAULT, not method-DEFAULT as you wrote it.

`evalf/int` may try to examine the integrand to discover singularities. This may involve expanding the expression. (Your expression had a symbolic quantity to the power 3744.) That expansion might "run away" for large powers of symbolic quantities, but you may be able to defuse that situation by passing in a procedure instead of an expression for the integrand. (I used two-parameter eval to do this below, but you could also use unapply.)

> restart:

> expr := exp(-0.1e-1*t)*(0.999e-3+.999001*exp(-0.1e-3*t))^3744
>         *(9.9999999*10^(-3)+.9999999*exp(-.1*t))^16:

> evalf[20](Int(_t->eval(expr,t=_t),
>               0.0..12.0, epsilon = 1.*10^(20),
>               method=_NoNAG));

                            0.59601992543695024580

Using a procedure as you had (a convenience perhaps for you, to test various parameters),

> restart:

> myIntFunc := proc(func, digits, precision, intMethod)
> local t, t0, tf;
>   t0,tf := 0.0, 12.0;
>   evalf[digits](Int(t->eval(func,:-t=t),
>                   t0 .. tf, epsilon = 1.*10^(-precision),
>                   method=intMethod));
> end proc:
>
> expr := exp(-0.1e-1*t)*(0.999e-3+.999001*exp(-0.1e-3*t))^3744:

> myIntFunc(expr, 20, 18, _NoNAG);
                             2.5780328524575330887
 
> myIntFunc(expr, 20, 18, _CCquad);
                             2.5780328524575330887
 
> myIntFunc(expr, 20, 18, _Dexp);
                             2.5780328524575330887
 
> expr := exp(-0.1e-1*t)*(0.999e-3+.999001*exp(-0.1e-3*t))^3744
>         *(9.9999999*10^(-3)+.9999999*exp(-.1*t))^16:

> myIntFunc(expr, 20, 18, _NoNAG);
                            0.59601992543696367895
 
> myIntFunc(expr, 20, 18, _CCquad);
                            0.59601992543696367894
 
> myIntFunc(expr, 20, 18, _Dexp);
                            0.59601992543696367895

Here's a simpler view of your problem,

> expr := exp(-0.1e-1*t)*(0.999e-3+.999001*exp(-0.1e-3*t))^3744
>         *(9.9999999*10^(-3)+.9999999*exp(-.1*t))^16:

> # This would "go away..."
> #evalf[20](Int(expr,t=0.0..12.0,epsilon = 1.*10^(-18),
> #method=_DEFAULT));

> evalf[20](Int(unapply(expr,t),0.0..12.0,epsilon = 1.*10^(-18),
> method=_DEFAULT));
                            0.59601992543696367895
About your paragraph that mentions IEEE, I'm not sure what the problem is. Perhaps posting a concrete example would help.

acer

As you can see from Alec's response above, using those GUI "equation labels" can only be done interactively. One cannot write code to access them or to generate references to them (in a higher sense). Also, while the GUI is usually smart about altering the references that one has already inserted, when a new labelled line is also inserted or a labelled line is deleted, in some sense the code written is tied to the worksheet at hand.

If you intend on writing re-usable and distributable programs, then I would suggest not using those labels. A popular alternative way to add Matrices, for example, would be to use the := notation to assign them to variables, and then to add those variables.

acer

numapprox:-pade(exp(x),x,[4,2]);
numapprox:-pade(exp(x),x=0,[4,2]);
evalf[20](numapprox:-pade(exp(x),x=0,[4,2]));
numapprox:-pade(exp(x),x=1,[4,2]);
numapprox:-pade(exp(x),x=1.0,[4,2]);

acer

> int(diff(v(x,y),y), y=0..Y, continuous);

                              -v(x, 0) + v(x, Y)

acer

It appears that there may be as many as 10,000.

I'm basing that on the url that gets produced if one tries to send a message to the most recent new members. The last time someone asked that question (and it got answered by the site's admin) that same method produced an answer which turned out to be very close.

acer

First 305 306 307 308 309 310 311 Last Page 307 of 337