Joe Riel

9520 Reputation

23 Badges

18 years, 224 days

MaplePrimes Activity


These are answers submitted by Joe Riel

In module A, s has to be an export, not a local.

The call `<,>`(a,b,c) is somewhat equivalent to Vector[column]([a,b,c]) and `<|>`(a,b,c) to Vector[row]([a,b,c]). The actual procedures are mainly builtin, but you can inspect the non-builtin part by doing

interface('verboseproc'=3):
print(`<,>`):
print(`<|>`):

The help page for Vector describes the row and column options.

Pi/3 is not an integer (in the range 0..10), so fails in u[i,Pi/3]:=0;

CodeTools:-Profiling takes the procedure you want to profile as an argument. You are passing a call to PickAngles.  Try

with(CodeTools:-Profiling):
Profile(PickAngles):
PickAngles(...);  # appropriate call to exercise the procedure
PrintProfiles(PickAngles);

 

Not clear that this will help, but in the Logic package you can use &iff. To get the desired looking expression you could do

with(Logic):
(&not (P &or Q)) &iff ((&not P) &and (&not Q));

See the help page ?Logic,operators.

You could try using kernelopts('bytesused'). 

It wasn't designed to.  It could be extended but would it be useful?  You can use

Describe~([sin,cos,tan]):

Your example isn't ideal in that Describe(1) also fails, with a different error.

The debug button is only active when Maple is computing.  To test it, run the following code in a Maple worksheet.

proc()
    for local cnt do
       Threads:-Sleep(1);
       print(cnt);
    end do;
end proc();

While it's executing, the debug button should become active.  Press it. The interactive debugger will open.  Click the next button in the debugger a few times to step through the code, then click the quit button.

See the help page for StringTools:-Random.  For example,

Generate('variable("abc",length=10)');
                           cbbbcacbac

 

@Art Kalb You could achieve that with map(expand@expand, N^%H).  The double expansion is to work around the design of `expand/conjugate`.  A different approach is

distribconj := proc(x)
    subsindets(x, 'specfunc({`*`,`+`},conjugate)', c -> map(conjugate, op(c)));
end proc:

distribconj(N^%H);

 

Am not quite sure what you are looking for.  Here I find the value of t so that f(x=1) - f(x=0) = TOL.

tol := 1e-6:
g := exp(-t):
h := unapply((x^2-5*x^3+10*x^5+x+3+.5*x^4)+(1/2)*x^2*(x-1)+2*sin(x),x):
tsol := fsolve((h(1)-h(0))*g = tol, t);
             tsol := 16.03285819

The module action is assigned in the startup region; click the Edit Startup Code button on the toolbar, the button has two filled circles. The module exports procedures used by the embedded components.  The code appears to be working, but I don't understand how to use it. Clicking the "Laes and Plot Data" button prints the equivalent of "you must select at least two points", which wasn't obvious to me.  Ah, I see.  Need to highlight a region in the Data.  That works.

Note the error "unterminated procedure".  The input region (starting with far left ">") ends before the procedure.  Being lazy, I just exported the worksheet as 1D maple input then edited it.  It runs. Note that FirmModelPP does not reference parameter alpha.
 

restart;
with(plots):
c := 1:
cr := 0.0300000000*c:
u := 1:
sExp := 0.0600000000*c:
s := 0.6500000000*c:
v := 3*c:

FirmModelPP := proc(alpha, delta)
local p0, xi0, q0, Firmpf0, G0, Recpf0, Unsold0, Environ0;
option remember;
    xi0 := 1; p0 := min(s + sqrt((v - s)*(c - s)), delta*v + sExp);
    q0 := u*(v - p0)/(v - s);
    f(N) := 1/u;
    F(N) := N/u;
    G0 := int(F(N), N = 0 .. q0);
    Firmpf0 := (p0 - c)*q0 - (p0 - s)*G0;
    Recpf0 := (sExp - cr)*xi0*q0;
    Environ0 := G0 + q0;
    Unsold0 := G0;
    return p0, q0, Firmpf0, Recpf0, Unsold0, Environ0;
end proc:

FirmModelFC := proc(alpha, beta, delta)
local p00, xi00, q00, Firmpf00, G00, Recpf00, Unsold00, Environ00, pr00;
option remember;
    xi00 := 1;
    p00 := s + sqrt((v - s)*(c - s));
    if p00 < delta*v + sExp then q00 := u*(v - p00)/(v - s);
        f(N) := 1/u;
        F(N) := N/u;
        G00 := int(F(N), N = 0 .. q00);
        Firmpf00 := (p00 - c)*q00 - (p00 - s)*G00;
        Recpf00 := `&xi;00*q00*`(sExp - cr);
        Unsold00 := G00;
        Environ00 := q00 + Unsold00;
    else q00 := alpha*u*(v - p00)/(v - s);
        f(N) := 1/u;
        F(N) := N/u;
        G00 := int(F(N), N = 0 .. q00/alpha);
        pr00 := p00 - delta*v;
        Firmpf00 := (p00 - c)*q00 - alpha*(p00 - s)*G00;
        Recpf00 := (beta*(pr00 - sExp) + sExp - cr)*xi00*q00 - 1/2*(pr00 - sExp)*beta^2*xi00^2*q00^2/(u*(1 - alpha));
        Unsold00 := G00;
        Environ00 := q00 + Unsold00;
    end if;
    return p00, q00, Firmpf00, Recpf00, Unsold00, Environ00;
end proc:

CurrentMetrics:= proc(alpha,beta,delta) option remember;
local  p, q, Firmpf,Recpf,Unsold,Environ;

    if (FirmModelFC(alpha,beta,delta)[3]>=FirmModelPP(alpha,delta)[3]) then
        p := FirmModelFC(alpha,beta,delta)[1];
        q := FirmModelFC(alpha,beta,delta)[2];
        Firmpf := FirmModelFC(alpha,beta,delta)[3];
        Recpf:=FirmModelFC(alpha,beta,delta)[4];
        Unsold:=FirmModelFC(alpha,beta,delta)[5];
        Environ:=FirmModelFC(alpha,beta,delta)[6];
    else
        p:=FirmModelPP(alpha,delta)[1];
        q:=FirmModelPP(alpha,delta)[2];
        Firmpf:=FirmModelPP(alpha,delta)[3];
        Recpf:=FirmModelPP(alpha,delta)[4];
        Unsold:=FirmModelPP(alpha,delta)[5];
        Environ:=FirmModelPP(alpha,delta)[6];
    end if ;
    return p,q,Firmpf,Recpf, Unsold,Environ;
end proc:



plot(['CurrentMetrics(alpha, 0.2000000000, 0.2000000000)[3]']
     , 'alpha' = 0.0000000000 .. 1.0000000000
     , 'linestyle' = ['solid']
     , 'legend' = ["Firm's profit with delta=0.2"]
     , 'labels' = [alpha, "Firm profit"]
     , 'labeldirections' = ["horizontal", "vertical"]
     , 'color' = ['blue']
     , 'axes' = 'boxed'
    );

 

I'm not sure I understand your objection.  Assume the first call to randpoly, randpoly([y], terms=1, degree=1, coeffs=rand(-4..1)),  returns -y-4, which it can.  Is the problem the inclusion of the -4 term?  Admittedly it's a bit unexpected when terms=1. You can eliminate it by passing the option 'homogeneous' to randpoly.

A workaround is to disable the start page by checking the "Do not show this page" checkbox in the home page.  To restore it, or change it, use Tools > Options > Interface and change the Open worksheet at startup menu selection. While I've normally have that set to "New, blank", am currently not noticing a slowdown when "Default home page" is selected.

1 2 3 4 5 6 7 Last Page 1 of 114