Joe Riel

9660 Reputation

23 Badges

20 years, 4 days

MaplePrimes Activity


These are answers submitted by Joe Riel

Posting your worksheet would have been helpful.  It isn't clear what the arguments to firint are. Actually, through a bit of trial and error I figured it out; you entered % de2.  Clearer would have been to put an explicit multiplication between the ditto operator (%) and de2.  

The problem is that % evaluates to a sequence of two items. Maple cannot multiply a sequence with an expression. You need to choose one of the two items in the sequence. This can be done with %[1], for the first expression, or %[2] for the second.

Thus

firint(%[1]*de2);

should give you what you want

It's not at all clear what the various numbers and letters correspond to in the worksheet. I'll guess that i and j are supposed to represent unit vectors in the x and y directions. What anges are theta1 and theta2?  What about all the numbers? Regardless, there are clear errors in the equations.  Note that a simple dimensional analysis indicates that there are problems.  For example, the dimension of f is length, but the equation for f has the length parameter (EF) in the denominator.  If theta1 is the angle of the beam EF from horizontal then you want

  f = -EF*(cos(theta1)*i + sin(theta1)*j)

There are similar issues with the other equations.

This can be done, though it requires some modification.  First, copy a row of embededded components consisting of the combo-box, slider, and text areas.  Right click in each embedded component, select "Component Properties" and change the name.  The new names, for the components in the seventh row, should be, ParamList7, Slider7, Value7, To7, and From7.

Next, right click on the Update Parameters in MapleSim Model button, select Component Properties, click Edit, then edit the line of code from

MapleSim[MapleSimTemplate][UpdateMapleSimModel]();

to

MapleSim[MapleSimTemplate][UpdateMapleSimModel](maxcomponent=7);

That should do it.  For more parameters, add more rows of embedded components and update the names accordingly.

 

Is this what you want:

sys := { NULL
, diff(y(t),t) + y(t) = 0
, y(0) = 1
, s(0) = 1
}:

integ := dsolve( sys
, 'numeric'
, 'events' = [[y(t)=10^(-s(t)), [s(t)=s(t)+1]]]
, 'discrete_variables' = [s(t)]
);

plots:-odeplot(integ, [s(t),t], 0..10);

I've just been informed that there is a shortcut key that partially works here, Ctrl-/ (control key with forward slash).  That puts the cursor back on the base line.  That works for simple stuff, say x3, but won't help much when creating large math expressions since it moves all the way out.

With that problem, Maple 15 enters a recursive loop when it calls

`dsolve/numeric/DAE/facgroup`((P[2](t)/P[1](t))^(1/gamma)*gamma-(P[2](t)/P[1](t))^(1/gamma));

Is gamma supposed to be Euler's constant?  It is possible that dsolve is not aware of that.  I tried converting it to a float,

dsolve(evalf(sys), numeric);

That eliminated the error, but maple quickly ate up all the memory on my machine.

The following Maple code can be used to remove invalid characters in a Maple standard worksheet (*.mw file).  Here I called it with

DeleteBadCharacters("opgave_1a.mw");
deleted 1 bad character(s)
wrote updated file to opgave_1a-fixed.mw

DeleteBadCharacters := proc(file :: string)
local base, char, cnt, msg, outfile, str, unicode;
    str := FileTools:-Text:-ReadFile(file);
    for cnt from 0 do
        try
            XMLTools:-ParseString(str);
            break;
        catch "An invalid XML character":
            msg := lastexception[2];
            if not StringTools:-RegMatch("Unicode: 0x([^)]+)", msg, 'all', 'unicode') then
                error;
            end if;
            unicode := sscanf(unicode,"%x");
            char := convert(unicode,'bytes');
            str := StringTools:-SubstituteAll(str, char, "");
        end try;
    end do;

    if cnt = 0 then
        printf("no bad characters in file\n");
    else
        if not StringTools:-RegMatch("^(.*)\\.mw$", file, 'all', 'base') then
            error "problem extracting basename";
        end if;
        printf("deleted %d bad character(s)\n", cnt);
        outfile := sprintf("%s-fixed.mw", base);
        FileTools:-Text:-WriteString(outfile, str);
        printf("wrote updated file to %s\n", outfile);
    end if;
    return NULL;
end proc:

Try the following.  There was an illegal character (^O).

 

Assignment1.5.mw

That generally means that the xml (the format used in the *.mw file) is not syntactically valid. Maybe a closing tag is missing.  Frequently you can fix that be directly editing the *.mw file in a text editor, preferably in one that can parse xml, though isn't a requirement.

The Maple structure array is deprecated; use Array.  With that you can then do 

min(T);

How large are the Vectors? What are the Vector components? Numeric? Symbolic?  If appropriate, that is, the components are considered real, then pass the option conjugate=false.

I'm not quite sure what you want.  Maybe something like the following,

dydt := 3.7*b*d*exp(-0.4/c):

F := Array(-1..3, 1..5
           , [[t,      a,      b,     c,      d   ],
              [0,    0.5,     38,     0,   0.9e-5 ],
              [1,    5.2,     45,   0.1,   1.2e-5 ],
              [2,    7.8,     51,   0.7,   1.6e-5 ],
              [3,   12.3,     74,   0.8,   2.1e-5 ]]):


eqs := [seq(F[-1,j]=f[i,j], j=op([2,2],F))]:

Dy := unapply(subs(eqs, f='F', dydt), i);
                                                        0.4
                 Dy := i -> 3.7 F[i, 3] F[i, 5] exp(- -------)
                                                      F[i, 4]


Dy(0);
Error, (in Dy) numeric exception: division by zero
Dy(1);
                               0.00003659464650

 

read "latool.m":
LibraryTools:-Save('latool', "latool.mla"):

This works because the only thing saved in latool.m is the table latool.

The book is dated.  The double quote in op(2,") is the ditto operator from Maple V; the equivalent in modern Maples is op(2,%).

Using William's suggestion:

getbit := proc( num :: posint )
local code,content,headers,uri;
    uri := sprintf("http://www.mysterytwisterc3.org/cgi-bin/mtc3-ramae-11-homomorphic.cgi/?c=%d", num);
    (code,content,headers) := HTTP:-Get(uri);
    if content = "0\n" then
        return 0;
    elif content = "1\n" then
        return 1;
    else
        error "problem with content: %1", content;
    end if;
end proc:


map(getbit, [seq(1..20)]);
     [1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0, 1, 0]

The pattern is rather simple




First 52 53 54 55 56 57 58 Last Page 54 of 114