Joe Riel

9530 Reputation

23 Badges

20 years, 26 days

MaplePrimes Activity


These are answers submitted by Joe Riel

I haven't been able to duplicate your first problem, about the merged yellow regions.  I assume you mean the drawing of tree T = SpanningTree(K33). 

Your suggestion, for enumerating neighbors, isn't workable with a set because the first element is not well-defined. You could create a helper proc:

conn := (node, neighbors) -> `{}`~(node,neighbors):
conn(1, {2,3,4,5});
                                   {{1,2},{1,3},{1,4},{1,5}}

 

It isn't the case that Maple necessarily uses 0 and 1 for false and true when computing conditionals. However, for your purposes, you might be able to use ?evalhf, depending on the boolean expression. For example,

evalhf(3 < Pi);
                      1.0

Note that the result is float, not an integer. 

Possibly the cleanest way to do this is the following

A := r*sin(m):
Aval := unapply('evalf'(A),r,m); 
                                 Aval := (r,m) -> evalf(r*sin(m))

 Enclosing evalf in forward-quotes delays its evaluation so that unapply can then see it and include it in the generated procedure.

@TylerCMW An event corresponds to a condition that halts the integrator.  This is used to modify the state equations that are being integrated.  For example, when the current through an ideal-diode crosses zero, an event occurs and the equations are changed to correspond to the new configuration (say diode off rather than diode on).

It is possible that the new configuration causes another event to immediately fire, which then reconfigures the model to the previous configuration, which trigger the original event, and so on.  The error message you are seeing may correspond to such an occurrence. 

There are usually ways to avoid this.  It would be helpful to have the actual model that is causing the problem.

You have an expression.  Try

x -> your_expression

There is a better way to do what you want; try using the ?min procedure.

Try

int(f, 0..1);
                      1/4 

The way to do this is to expand this in terms of the vector components.  For example,

Y := [y1,y2]:
deq := diff(Y(t),t) = [t^2,exp(t)]:
ini := Y(0) = [-1,1]:
(lhs-rhs)(deq), (lhs-rhs)(ini);
          2   /d       \            /d       \
       [-t  + |-- y1(t)|, -exp(t) + |-- y2(t)|], [1 + y1(0), -1 + y2(0)]
              \dt      /            \dt      /

op~([%]);
           2   /d       \            /d       \
        [-t  + |-- y1(t)|, -exp(t) + |-- y2(t)|, 1 + y1(0), -1 + y2(0)]
               \dt      /            \dt      /

dsol := dsolve(%);
                                     3
                                    t
                  dsol := {y1(t) = ---- - 1, y2(t) = exp(t)}
                                    3

eval(Y(t), dsol);
                                 3
                                t
                              [---- - 1, exp(t)]
                                3

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

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