acer

32303 Reputation

29 Badges

19 years, 310 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by 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

The procedure `Z`, shown below, will replace ScientificConstants:-Constants calls by multiplying them each by their own unit. Then `Z` will simplify the expression by combining the units.

> restart:
> with(ScientificConstants):

> Z := a -> combine(subsindets(a,'specfunc'('anything',
>                                           ScientificConstants:-Constant),
>                              t->t*ScientificConstants:-GetUnit(t)),
>                   'units'):

> A := ((Constant(m[p])*Constant(m[e]))/(Constant(m[e]) + Constant(m[p]))
>       *(Constant(e)^4))/(2*Constant(hbar)^2):

> A := Z(A):

> evalf(A);
                                             [ 6  4]
                                         -37 [s  A ]
                          0.2697191002 10    [-----]
                                             [    4]
                                             [kg m ]
 
> convert(A,'unit_free','z'): z;
                                    [ 6  4]
                                    [s  A ]
                                    [-----]
                                    [    4]
                                    [kg m ]

acer

This is just a guess, based on your mention of the back-solver.

Given expr and expression in several variables, separate procedures are created. Each of those procedures numerically solves expr=0 in terms of a single variable, where all the other variables have been assigned values from the procedure arguments. For example,

> expr := cos(x*y)-z*x^2*y^3:

> f[x]:=proc(Y,Z) fsolve(eval(expr=0,[y=Y,z=Z]),x); end proc:
> f[y]:=proc(X,Z) fsolve(eval(expr=0,[x=X,z=Z]),y); end proc:
> f[z]:=proc(X,Y) fsolve(eval(expr=0,[x=X,y=Y]),z); end proc:

> f[x](1.0,1.0); # solves cos(x*1.0)-1.0*x^2*1.0^3
                                 0.8241323123
 
> f[y](1.0,1.0);
                                 0.8654740331
 
> f[z](1.0,1.0);
                                 0.5403023059

If this isn't what you're after, then please give us more detail. If this is indeed what you're after (or is close) then it should even be possible to programatically emit such procedures given an arbitrary expression in an arbitrary number of variables (provided an order for the variable names is specified).

One the other hand, maybe you want something quite different. Perhaps the Maple routine unapply is all that you're after.

acer

You might wish to check out these help pages,

examples,WorksheetPackage
XMLTools
Worksheet
Worksheet[Schema]
Worksheet[DTD]

acer

> e1 := 3*x^2+3*y-a*(2*x-6):
> e2 := 3*y^2+3*x-a*(2*y-6):
> e3 := x^2+y^2-6*x-6*y+9:

> S1 := fsolve({e1, e2, e3}, {a,x,y});

         S1 := {a = -1.167261890, x = 0.8786796564, y = 0.8786796564}
 
> S2 := fsolve({e1, e2, e3}, {a,x,y}, avoid={S1});

           S2 := {a = 22.16726189, x = 5.121320344, y = 5.121320344}
 
> fsolve({e1, e2, e3}, {a,x,y}, avoid={S1,S2});

           2                         2
fsolve({3 x  + 3 y - a (2 x - 6), 3 y  + 3 x - a (2 y - 6),
 
     2    2
    x  + y  - 6 x - 6 y + 9}, {a, x, y}, avoid = {
 
    {a = -1.167261890, x = 0.8786796564, y = 0.8786796564},
 
    {a = 22.16726189, x = 5.121320344, y = 5.121320344}})

The (last) unevaluated return means that it did not find another purely real root.

> S3 := fsolve({e1, e2, e3}, {a,x,y}, avoid={S1,S2},complex);

S3 := {a = 0.2535721577, x = 0.5845240526 - 1.155216020 I,
 
    y = 0.5845240526 + 1.155216020 I}

> fsolve({e1, e2, e3}, {a,x,y}, avoid={S1,S2,S3},complex);

           2                         2
fsolve({3 x  + 3 y - a (2 x - 6), 3 y  + 3 x - a (2 y - 6),
 
     2    2
    x  + y  - 6 x - 6 y + 9}, {a, x, y}, avoid = {
 
    {a = -1.167261890, x = 0.8786796564, y = 0.8786796564}, {a = 0.2535721577,
 
    x = 0.5845240526 - 1.155216020 I, y = 0.5845240526 + 1.155216020 I},
 
    {a = 22.16726189, x = 5.121320344, y = 5.121320344}}, complex)

Now, the last (again, unevaluated) result above indicates that no other complex root was found. However, using an intitial point gave this,

> fsolve({e1, e2, e3}, {a=17,x=6.5-2.5*I,y=6.5+2.5*I},
>         avoid={S1,S2,S3},complex);

                                  -21
{a = 17.74642784 - 0.5645571778 10    I, x = 6.415475947 - 2.676840665 I,
 
    y = 6.415475947 + 2.676840665 I}

You might also look at the results from solve. The following gave 6 solutions.

_EnvExplicit:=true:
_EnvAllSolutions:=true:
solve({e1, e2, e3}, {a,x,y});
evalf([%]);

acer

You've posted this question three times. Perhaps the administrators can delete some of the duplicates (including those of my answer).

You didn't say whether you wanted the first or second row to be taken as the x-coordinate.

f := proc(M) plots:-pointplot(M^%T); end proc:
m := Matrix(2,6,(i,j)->i*j):
f(m);

acer

Examples with names like f_1, f_2, etc, can be a little confusing, since if typed in literally in the Standard GUI those produce indexed name references like f[1]. f[2], etc. So, combined with your post's title, it makes me wonder whether you want a Vector or Array of functions.

> f:=Vector(5,i->x->i);
                                      [x -> 1]
                                      [      ]
                                      [x -> 2]
                                      [      ]
                                 f := [x -> 3]
                                      [      ]
                                      [x -> 4]
                                      [      ]
                                      [x -> 5]
 
> f[3](x);
                                       3

acer

Have a look at the ?rtable_scanblock help-page. (For fun, and possibly appropriate given your description, is to use rtable_scanblock to cause side-effects on data Arrays while scanning them/others.)

If you want this process to run fast, on images that are not small, then you could consider writing a set of procedures which be handled by Maple's evalhf or Compiler:-Compile functions. Such routines might possibly still utilize Maple's built-in `max`, but wrapped inside a call to `eval`.

acer

Are those really calls to simply Transpose, or are they supposed to be calls to LinearAlgebra:-Transpose?

Did you intend the computations to take place over exact or floating-point values?

If r[k] is a Vector then how can you compare it to scalar 0 in the while condition? Did you mean something more like while LinearAlgebra:-Norm(r[k])>epsilon for some small positive tolerance epsilon (eg.. 10e-5)?

Are you typing in `.` or `*` for the Matrix-Vector multiplications?

I might be able to say more, but the poor rendering of the source code as 2D Math makes it difficult. Perhaps you could code it in a Worksheet rather than a Document, and then post the code as 1D Maple input?

acer

> expr := k1*sin(x) - k2*sin(2*x);
                        expr := k1 sin(x) - k2 sin(2 x)

> convert(expr,cos);
                                 Pi                   Pi
                    -k1 cos(x + ----) + k2 cos(2 x + ----)
                                 2                    2

> convert(factor(expand(convert(expr,cos))),cos);
                                Pi
                       cos(x + ----) (-k1 + 2 k2 cos(x))
                                2

> expr2 := tan(x) + k1*sin(x) - k2*sin(2*x);
                   expr2 := tan(x) + k1 sin(x) - k2 sin(2 x)

> convert(expr2,cos);
               Pi                 Pi                          Pi
     -cos(x + ----) - k1 cos(x + ----) cos(x) + k2 cos(2 x + ----) cos(x)
               2                  2                           2
     --------------------------------------------------------------------
                                    cos(x)

> subsindets(expr2,specfunc(anything,sin),x->convert(x,cos));
                                     Pi                   Pi
                tan(x) - k1 cos(x + ----) + k2 cos(2 x + ----)
                                     2                    2

You didn't say whether you wanted other things convert to cos, so I gave examples where `tan` can be included or excluded. You could also have fun with `frontend` for that. Also, as you can see above, there can be some choice about pieces of the form cos(A+B).

acer

I don't have a copy of that ebook at hand, so I'm not sure what files come with it. Does it come with a .hdb file, or is it all just .mw or .mwz?

You might be able to add something to the context-sensitive menus. Those are the pop-up menus that you get when you right-click on output in your worksheet.

For example, you could try replacing that foo.mw with (the full path to) that Table of Contents file in this code below,

pCM := ContextMenu:-CurrentContext:-Copy():
pCM:-Entries:-Add("my fave worksheet",
        "INTERFACE_WORKSHEET('display','file'=`foo.mw`)",
        'anything'
                 ):
ContextMenu:-Install(pCM);

After issuing those commands, then whenever I right-click on any output there is a new item in the context-menu that appears. (It doesn't appear if I right-click on the blank background, which is too bad.) Selecting it causes foo.mw to be opened in a new tab. Maybe that will work for your file too. If it does, you could consider adding that code to your Maple initialization file.

Alternatively, you could add an alias or simple command to your initialization file, which just runs that INTERFACE_WORKSHEET command. So you wouldn't have to search for the file every time. You could just type in that short call.

Of course, neither approach will work if INTERFACE_WORKSHEET does not cause that special file to be loaded. (I don't know for a fact that your file is a worksheet, or even that some part of your ebook opens as a worksheet. Maybe it opens in a special reader.

I would have thought that the top menubar's Tools dropdown menu might get a submenu (named, say, ebooks) which would then show what was available. BTW, did your ebook's installation prompt for a preferred location?

acer

First 304 305 306 307 308 309 310 Last Page 306 of 336