Joe Riel

8049 Reputation

22 Badges

15 years, 13 days

MaplePrimes Activity

These are answers submitted by Joe Riel

That is a demo of the Intermediate Axis Theorem, which can be readily modeled using MapleSim, see IAT.msim.  MapleSim uses Maple as the engine. While it is possible to extract the Maple equations that are generated, for this example they are not particularly enlightening and too large to post here.

Internally, Maple reduces the first, (x^2 + y^2 = 1)^2, to x^2 + y^2 - 1.  It doesn't modify the second, (x^2 + y^2 -1)^2 , and solving that is considerably more difficult for a numerical solver as the expression never crosses zero.

This is explained in the help page worksheet,documenting,styles.  Here's a summary

Click Format > Styles and then modify the character styles appropriately.

Click Format > Manage Style Sets and then Export your style set.  After doing so, click User-defined Style Set radio button and select the mw file to which you exported the style.  Click OK and it should then be used as the style set for new worksheets.

You have to use the tensor product to create the metric, and use, say, dtheta, to refer to the base one-form, not d(theta).

  g1 := evalDG(dr &t dr + r^2*dtheta &t dtheta);

There is a minor issue with calling rand directly in your dice procedure; each call generates a separate procedure. Doing so is more expensive than necessary.  It also isn't clear how this affects the random sequence obtained. Here's an approach that uses an appliable module to ensure that rand is only called one time.

dice := module()
local ModuleApply, ModuleLoad, die;
    ModuleLoad := proc()
        die := rand(1..6);
    end proc:
    ModuleApply := proc()
        (die(), die());
    end proc:
    ModuleLoad(); # needed because this module isn't being loaded from a library
end module:
seq([dice()], 1..4);
    [5, 2], [5, 6], [2, 3], [4, 4]

Note that the ModuleLoad isn't needed here, rather die could be directly assigned rand(1..6) in the module body, however, if this were being written to a Maple archive (library) it would probably be better to delay the assignment to when the module is loaded, versus when it is assigned.

Another possibility is to use select:

L1 := [[1],[2]]:
L2 := [[3],[1]]:                                                                                                                                                                                    L2 := [[3],[1]]:
select(member, L1, L2);

Note that the handling of repeated items is problematic, both with this and the set approach.

While there is nothing wrong with using a Vector, another approach is to use a list. For example

iterativepower := proc(base, index, n :: nonnegint)
local k;
  [seq(base^(index^k), k=0..n)];
end proc:

Unless you're interested in the discrete steps, it might be better to look at base^p, as p increases. This can be easily plotted, here with base=1+I:

plots:-complexplot((1+I)^p, p=0..25);

Before using subsindets or evalindets, it's usually a good idea to call indets to see what expressions are being operated on. Thus

x := u(i, j)^2*v(i, j)+u(i-1, j):
E := indets(x, 'specfunc(symbol, u)');         # --> {u(i, j)}
F := indets(x, 'specfunc(`+`, u)');            # --> {}
G := indets(x, 'specfunc({`+`, symbol}, u)');  # --> {u(i, j), u(i - 1, j)}

That makes sense to me (see Carl's comments for details). A variation of this is to use an unassigned symbol for the applied function in the call to subsindets:

subsindets(x, 'specfunc(symbol, u)', Z);

I'll suggest the following.  Create a Maple module, with option package, and with exports of the desired constants, procedures.  Save this to an mla as a  Maple toolbox.  You will then be able to access any of the procedures/constants from any worksheet by using the module.  Here is example code of how you might do this (it both creates a trivial module and saves it to a toolbox).

# Code to create a simple Maple toolbox for storing constants and whatever (the exports)

MyConstants := module()
option package;
export SpeedLimit;
    SpeedLimit := 65;
end module:

# Temporary procedure to create, if needed, the toolbox directory

MakeToolbox := proc(toolbox :: string)
local dir;
uses FT = FileTools;
    dir := FT:-JoinPath([kernelopts('homedir'),"maple","toolbox", toolbox, "lib"]);
    if not FT:-Exists(dir) then
        FT:-MakeDirectory(dir, 'recurse');
    end if;
end proc:

# Create directory and path to toolbox mla
dir := MakeToolbox("MyConstants"):
path := FileTools:-JoinPath([dir, "MyConstants.mla"]);

# Save the module (MyConstants) as a toolbox.
LibraryTools:-Save(MyConstants, path);

You can then access any of the exports (here just one, SpeedLimit) via MyConstants:-SpeedLimit, or do with(MyConstants): and then use SpeedLimit alone. In a procedure you should use a uses statement. If you save all the code above in a worksheet, and then edit the module as desired, you should be able to reexecute it to update the toolbox.

I'm assuming you have a new enough Maple that automatically picks up toolboxes put in the appropriate place.  If not, then you'll probably need to create a Maple initialization file and use it to assign the global variable libname to include the path to an mla file. That was always a sticking point for people new to Maple; the use of toolboxes simplifies the operation. 

It's not too hard to see that the only real solution for eq6 occurs at the limit when Dmax=0.  It's then easy enough to substitute that into eq7 and eq8 and solve for deltaH and de.

limit(eq6, Dmax=0);
              {de = -2.638478742, deltaH = 6.260000000}

I suspect that Dmax=0 is not an allowable solution, in which case there are no real solutions.

Use the :: operator rather than = to assign a property name to a variable.  While I don't know why using 'real' doesn't work, the 'realcons' property does. 

Use the method that Carl suggested, but append additional t's to the call to diff. For example,

f:= (t,y)-> -y + t*y^(1/2);
diff(f(t, y(t)), t);   # first derivative
diff(f(t, y(t)), t,t); # second derivative

Alternatively, use

diff(f(t, y(t)), [t$3]); # third derivative

You could use subs, however, you'll have to substitute for both the term and 1/term. Here's a slightly different approach, which replaces the expression of interest with the variable tmp

subsindets(X, 'anything^And(rational,(Not(integer)))', p -> tmp^signum(op(2,p)));

As a practical matter, you'd first want to inspect the elements that match the type in the subsindets call. Do that with

   {1/sqrt((n__x^2+n__y^2+n__z^2)*c^2), sqrt((n__x^2+n__y^2+n__z^2)*c^2)}

Maybe the better way is to first assign the expression of interest to a variable, then use subs

expr := sqrt((n__x^2+n__y^2+n__z^2)*c^2):
subs([expr=tmp, 1/expr=1/tmp], X);

In addition to Carl's suggestions, I think it would be clearer if you used a separate line to extract the rhs of the output of dsolve, when assigning to Y.  That way a reader could see what dsolve returned and would understand the reason for using rhs.


            [a(x), b(x), c(x)]

Arguments applied to a list are distributed to each element in the list. If any elements are lists, the distribution applies to them, as well. Consequently, L2(x) is converted to [[1(x)],[2(x)]].  Arguments applied to a number evaluate to the number, for example 3(x) evaluates to 3.  Your result follows from that.

5 6 7 8 9 10 11 Last Page 7 of 103