acer

32480 Reputation

29 Badges

20 years, 6 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


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

It has been suggested in the past that changing the current binding for a name (almost always) doesn't affect routines In Maple's own Library, since those get saved with the binding at their creation time. Sometimes this is a pain, but perhaps in this case it might help.

> myD:=module() option package; export D; end module:
> with(myD): unprotect(D):

> D:=4: 17*D;
                                      68
 
> :-D(sin);
                                      cos
 
> convert(diff(f(x),x),:-D);
                                    D(f)(x)
 
> eval(%,f=tan);
                                            2
                                  1 + tan(x)

Notice that in the above, where it looks like I am assigning to D, I am really just assigning to myD:-D.

Also, regardless of what else you've assigned, or loaded, etc, you should always be able to call :-VectorCalculus:-D. So, continuing from on the above, in the same session,

> V := Vector[row]([sin,ln]);
                                V := [sin, ln]
 
> :-VectorCalculus:-D(V);
                                [cos, z -> 1/z]

acer

Are you looking for a Maple program for this? You should be able to do this simply, with one for..do loop within another, using the isprime routine and a few loop control variables.

Is this for an assignment in an academic course? If so then how far have you gotten so far?

acer

> f:= (m,n) -> Array(1..m,1..n,[seq(combinat:-randperm(n),i=1..m)]):

> f(3,5);
                            [2    4    5    1    3]
                            [                     ]
                            [2    4    3    1    5]
                            [                     ]
                            [5    3    1    2    4]

acer

Who recommends using textplot and the SYMBOL font, when using Maple's Standard GUI?

Can you not simply use the techniques described on the ?plot,typesetting help-page?

See ?plot,device and ?plot,setup if you are not familiar with how to programatically export plots to gif, jpeg, etc.

acer

Could someone please explain the syntax used in stating this problem? Thanks.

[updated] Please ignore the above. I've got it now.

acer

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