Joe Riel

9530 Reputation

23 Badges

20 years, 28 days

MaplePrimes Activity


These are answers submitted by Joe Riel

I recovered what was readily recoverable, but from the look of it that was just the write-up from the instructor.  That is, there was nothing recoverable past the following caveats:

  Remember to shrink your graphs and save your Maple file frequently as you go!
  Also remember to highlight or italicize your answers when typing in a text box.

Note that Maple periodically saves backups. See ?backup. Possibly you can recover a useful version from that?

You can work around the first limitation by replacing the output of Step(), which returns the Heaviside function, with an explicit piecewise:

ResponsePlot(sys, piecewise(t<0,0,1));

Alternatively you can do the equivalent (see ?Heaviside for details):

_EnvUseHeavisideAsUnitStep := true:
ResponsePlot(sys, convert(Step(),piecewise));

What version of Maple are you using? I'm not seeing the second error (maxfun exceeded). The way to work around that is to do

ResponsePlot(sys, Sine(), duration=40, dsolveargs=[maxfun=0]);

Assuming it exists, Maple can solve for the limit:

req := a(k) = (2/5)*a(k-1)*ln((1/10)*(exp(1)*x/a(k-1))^10)/ln(10^a(k-1)*(exp(1))^4):
# Assuming limit exists, then at limit, a(k) = a(k-1)
leq := eval(req, a=(x->a)):
simplify(leq,'symbolic'):
a_lim := solve(%,a);
                                        x
          a_lim := -----------------------------------------------------------
           exp(LambertW(1/4 x exp(-1/10 ln(10)) ln(10)) + 1/10 ln(10))
evalf(eval(a_lim, x=1));
 0.5716077045

In case it isn't clear, you can also plot expressions of the state-variables.  That allows, say, plotting y vs x:

odeplot(p, [[x(t),y(t)]],-4..4);

Could you upload the .msim fle that has the error?

As specified, the differential equation has two branches.  The easiest thing to do is to rewrite it, forcing one branch.  There is also a problem with the initial conditions, you don't want to specify D(theta)(0), that is not allowed for a first order system.  Is the variable l supposed to be the parameter longueur?  Here is a rewrite that works, but you probably need to tweak it

tipe6 := proc (longueur, thetaInitial, rayonBoule, nombrePoints)
local eq, sol, valeurstheta, x, y, plotseq;
global g,l,t,theta;
    #eq := ((1/2)*longueur^2+(1/5)*rayonBoule^2)*(diff(theta(t), t))^2+g*l*(cos(theta(t))-cos(thetaInitial)) = 0;
    eq := diff(theta(t),t) = (-(10*g*l*cos(theta(t))-10*g*l*cos(thetaInitial))/(5*longueur^2+2*rayonBoule^2))^(1/2);
    sol := dsolve({theta(0) = thetaInitial, eq}, theta(t), numeric);
    valeurstheta := seq(rhs(sol((1/30)*i)[2]), i = 1 .. nombrePoints);
    x := seq(longueur*sin(valeurstheta[i]), i = 1 .. nombrePoints);
    y := seq(longueur*(1-cos(valeurstheta[i])), i = 1 .. nombrePoints);
    plotseq := [seq(plot([[x[i], y[i]]], 'style' = point), i = 1 .. nombrePoints)];
    plots:-display(plotseq, 'insequence' = true)
end proc:

g := 10: l := 1:
tipe6(1,Pi/4,10,100);

While the help page for the WheelAxle component states that the equation for torque is tau = r*f_T*dir, in fact it actually is tau = -r*f_T*dir. The choice of sign depends on how the wheel is defined.

It would be nice if ?FileTools had an export for creating a path to a filename, given its components.  ?AbsolutePath doesn't quite work here because you cannot specify more than two components (you could do AbsolutePath("Destop\\foo.txt", kernelopts('homedir'))).  That is, you'd want to do

FileTools:-CreatePath(kernelopts('homedir'), "Desktop", "foo.txt");

Using cat and manually inserting the directory separator isn't hard, and could be done with ?StringTools[Join] and kernelopts('dirsep'), but an export would be useful when automating this.

If the first argument is not a file ID, then it it must be a path to the file. That can either be relative to the current directory (use ?currentdir to determine what that is) or an absolute path.  I'm not a Windows user, so cannot tell you where the directory Desktop files is located.

What you might do, after figuring out where the Desktop directory lies, is to add the following assignment to your Maple initialization file (which you must create):

MyDesktop := "c:\\path_to_my_destop":

Then you should always be able to do

file := sprintf("%s\\somefile.txt", MyDesktop);
readdata(file, 2);

There appears to be a deficiency in the routine.  I'll submit an SCR.  You can work around it by converting to the TransferFunction form before executing BodePlot:

sys3:=DiffEquation(DGL, inputvariable=[y(t)], outputvariable=[x(t)]):
sys4 := TransferFunction(sys3);
BodePlot(sys4, thickness = 2);

A simple way to debug this is to enclose the script in a procedure and then run the procedure through Maple's syntax checker ?mint, an external program.  You can also use the less-powerful ?maplemint command from inside Maple.  For example:

check := proc()
    gam := 1.4;
    p[L] := 1;
    u[L] := 0;
    rho[L] := 1;
    p[R] := 1;
    u[R] := 1;
    rho[R] := 1;
    p1 = 1/2*(p[L]+p[R]);
    A[L] := 2/((gam+1)*rho[L]);
    A[R] := 2/((gam+1)*rho[R]);
    B[L] := (gam-1)*p[L]/(gam+1);
    B[R] := (gam-1)*p[R]/(gam+1);
    a[L] := (gam*p[L]/rho[L])^(1/2);
    a[R] := (gam*p[R]/rho[R])^(1/2);
    if p1 > p[L] then
        f[L] := (p1-p[L])*(A[L]/(p1+B[L]))^(1/2);
        df[L] := (A[L]/(p1+B[L]))^(1/2)*(1-(p1-p[L])/(2*(p1+B[L])));
    else
        f[L] := 2*a[L]*((p1/p[L])^((gam-1)/(2*gam))-1)/(gam-1);
        df[L] := (p1/p[L])^(-(gam+1)/(2*gam))/(rho[L]*a[L]);
    end if;
end proc:

maplemint(check);
    This equation was used as a statement:
      p1 = 1/2*p[L]+1/2*p[R]
    These names were used as global names, but were not declared:
      L, R, p1
    These local variables were assigned a value, but otherwise unused:
      df, f, u

The output correctly warns the user that an equation was used as a statement.

Using IsAnagram is a practical way to handle this.  However, a canned solution doesn't teach much.  Offhand, the method I'd use, if I had to implement this from scratch, would be to convert the two integers to lists of digits, sort each list, then compare the two lists.

Note that if one number has less digits than the other, you may have to add 0's to the shorter one.  That would allow 10 and 1 (01) to be anagrams.

You could also use the `/` function.  Combined with the ~ operator (Maple 14), you could do

L := [2,6,8]:
`/`~(L);
                               [1/2, 1/6, 1/8]


Actually, timing indicates that the string conversion is considerably faster, so you might want to stick with that. Something like

digitToInt := table([seq(sprintf("%d",d)=d, d = 0..9)]):

ToDigitsStr := proc(m :: posint );
local dig;
global digitToInt;
    [seq(digitToInt[dig], dig = StringTools:-Explode(sprintf("%a",m)))];
end proc:

You could use

convert(1234, base, 10);
                                        [4,3,2,1]

or do it yourself via

ToDigits := proc(m :: posint )
local q,k;
    q := m;
    [seq(irem(q,10,'q'), k=0..length(m)-1)];
end proc:
First 59 60 61 62 63 64 65 Last Page 61 of 114