acer

32343 Reputation

29 Badges

19 years, 327 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Here's an improvement on my earlier Answer. It's pretty fast.

restart:

with(Statistics):

G := RandomVariable(NegativeBinomial(R, P)):

foo:=CDF(G, t):
special:=foo assuming t::posint, R>0, P>0;

1-GAMMA(R+t+1)*P^R*(1-P)^(t+1)*hypergeom([1, R+t+1], [t+2], 1-P)/(GAMMA(R)*GAMMA(t+2))

 

# Use the values r=1.965, p=0.003
r := 1.965:
p := 3e-3:

targ := 0.98:

 

func:=unapply(simplify(eval(special,[R=r,P=p])),t) assuming t>1:

plot(func-targ, 1..3000, size=[600,200]);

ans := ceil(RootFinding:-NextZero(t->func(t)-targ,1,maxdistance=3000));

1920

X := RandomVariable(NegativeBinomial(r, p)):
CDF(X, ans-1, numeric), CDF(X, ans, numeric);

.9799688804, .9800204152

restart:

with(Statistics):

G := RandomVariable(NegativeBinomial(R, P)):

foo:=CDF(G, t):
special:=foo assuming t::posint, R>0, P>0:

 

# Use the values r=1.965, p=3*10^(-10)
r := 1.965:
p := 3e-10:

targ := 0.98:

 

func:=unapply(simplify(eval(special,
                            [R=r,P=convert(p,rational,exact)])),t)
      assuming t>1:

Digits:=16;
plot(func-targ, 1..3*10^10, size=[600,200]);

16

# Find value to start NextZero's search
for i from 1 to 40 do
  res:=evalf(eval(special,[R=r,P=p,t=2^i])-targ);
  if res>0 then
    st:=i; break;
  end if;
end do:
2^(st-1);

17179869184

ans := ceil(RootFinding:-NextZero(t->func(t)-targ,
                                  2^(st-1),
                                  maxdistance=2^st-2^(st-1)));

19239732630

#X := RandomVariable(NegativeBinomial(r, convert(p,rational,exact))):
#CDF(X, ans-1, numeric), CDF(X, ans, numeric);  # too slow!

evalf(eval(special,[R=r,P=p,t=ans-1])),
evalf(eval(special,[R=r,P=p,t=ans]));

.9799999999992235, .9800000000043679

 

Download invbinom2.mw

[edit] Only after I submitted this have I seen Carl's response, which also uses ceil@NextZero, albeit with a numeric integral rather than a generic formula involving hypergeom. But for r=1.965, p=3e-10, P=0.98 that numeric integration approach seems very slow, or gets stuck.

The first thing to realize is that in Maple it's refered to as "plotting" rather than "graphing". And each is a "plot" rather than a "graph".

You could start with the Plotting Guide, which may help you figure out which sort of "plot" you want. It is in the Help system of your Maple. Here's an online link.

Here is something, for somewhat smaller p=0.003 and r=1.965 .

Download negativebinomial.mw

So perhaps there is an issue with the Sum and a non-integer upper limit. But perhaps a continous root-finder is a not great choice.

[edit] I originally typo'd that as "a great choice", which negated my whole point. Sigh.

 

It sounds like you may have inadvertantly downloaded the older first version of the DirectSearch package from the Application Center, which has only the older .hdb format of its Help Database file.

If so then you have a few choices:

1) Manually remove the files you added from the 1st version, and download version 2 from the Application Center. That contains the .help format Help Database file for its version of the DirectSearch package (which is also improved).

2) Manually remove the files you added from the 1st version, and download and install version 2 as a "toolbox" package from the MapleCloud. That contains the newer .help format Help Database file for its version of the DirectSearch package (which is also improved).

3) Remove the files you added from the 1st version, and install DirectSearch version 2 from the MapleCloud directly from within Maple 2018 GUI (required Maple version). You do this using the "cloud" icon at the top-right of the GUI's top icon Toolbar. (Also see View->Toolbar which should be checked in the main menu.)

4) Keep version 1 of the DirectSearch package and migrate its .hdb format Help Database file to the newer .help format using HelpTools commands.

I would recommend choice 3) if you have Maple 2018, or 2) if your Maple version is older.

Important: After installing the later version you may need to completely close all open instances of the Maple GUI, and relaunch, in order for the newly added help pages to be accessible.

This is very similar to your earlier Questions in this theme. But it's easier than before, if now you want to collect powers of r.

restart:

with(DETools):

with(IntegrationTools):

u[1](r,z):=(C[o]^2*exp(2*lambda*z)-D[o]^2*exp(-2*lambda*z))
           +(lambda/2)*(C[o]*exp(lambda*z)
           -D[o]*exp(-lambda*z))*(1-r^4)+A[1](z)*r^2:

 

M1:=Expand(int(u[1](r,z), z)):

 

map(factor,collect(M1,[r,lambda],combine));

-(1/2)*(C[o]*exp(lambda*z)+D[o]*exp(-lambda*z))*r^4+r^2*(int(A[1](z), z))+(1/2)*C[o]*exp(lambda*z)+(1/2)*D[o]*exp(-lambda*z)+(1/2)*(C[o]^2*exp(2*lambda*z)+D[o]^2*exp(-2*lambda*z))/lambda

 

Download yet_another.mw

You can do that using the printf command.

Eg.,

for x in [1,2,3,4] do
printf("%a ",x);
end do:
See its help page for more details.

I don't know a huge amount about the PolyhedralSets package (except that it seems to be slightly complicated for the simple tasks for which I sometimes try to use it).

But if you are good with floating-point data then how about ComputationalGeometry:-ConvexHull instead, which is new to Maple 2018 and seems to use qhull.

It sounds to me as if you might prefer float results for your float data, in which case using PolyhedralSets (which requires rationals) is going to involve much slower exact arithmetic done by the Maple kernel. In contrast qhull will work using compiled external code on hardware floats.

I am guessing that you want the indexed names, eg, AE[i] rather than the name `AE[i]` .

In other words, I suppose that you want to index into the names, rather than append `[i]` to the names. (You originally wrote "append" in your Question, but I suspect that you want it mutable wrt i.)

GST := AE + AI - ANB - AR - CP;

AE+AI-ANB-AR-CP

subsindets(GST,name,`?[]`,[i]);

AE[i]+AI[i]-ANB[i]-AR[i]-CP[i]

lprint(%);

AE[i]+AI[i]-ANB[i]-AR[i]-CP[i]

 

Download fcnindex.mw

You could also do this example with,
  map(u->sign(u)*`?[]`(sign(u)*u,[i]),GST);
or,
  subsindets(GST,name,u->u[i]);
or,
  map(u->sign(u)*(sign(u)*u)[i],GST);

And if you're going to be doing this kind of change many times (for a variety of polynomials of subsets of these names),
  R:=map(u->u=u[i],indets(GST,name));  # once
  eval(GST,R);  # or similar

restart;

with(IntegrationTools):

Int(exp(-a^2-b^2-c^2),
    [a=b^2/(4*c)..infinity, c=0..infinity, b=-infinity..infinity]);

Int(exp(-a^2-b^2-c^2), [a = (1/4)*b^2/c .. infinity, c = 0 .. infinity, b = -infinity .. infinity])

value(%);

-(1/8)*(-2*Pi^2+MeijerG([[3/4, 3/4], [5/4]], [[1, 1/2, 1/4], []], 4))/Pi^(1/2)

evalf(%);

.9786008288

 

Download numerictripleint.mw

For the first term in A2 did you mean lambda^2*P[o](z)*(1+r^2) instead of P[o](z)*(1+r^2) ?

restart:

kernelopts(version);

`Maple 2018.0, X86 64 LINUX, Mar 9 2018, Build ID 1298750`

with(DETools):

 

P[o](z):=C[o]*exp(lambda*z)+D[o]*exp(-lambda*z):
u[o](r,z):=(1-r^2)*diff(P[o](z),z):
v[o](r,z):=(2*r-r^3)*diff(P[o](z),z,z):

 

H:=proc(ee)
     local temp;
     temp:=sort([op(indets(ee,And(polynom(integer,r),
                                  satisfies(u->degree(u,r)>0))))],
                (a,b)->degree(a,r)>degree(b,r) and length(a)>length(b));
     subs(map(u->u=freeze(u),temp),ee);
end proc:
     

A1:=P[o](z)*u[o](r,z);

(C[o]*exp(lambda*z)+D[o]*exp(-lambda*z))*(-r^2+1)*(C[o]*lambda*exp(lambda*z)-D[o]*lambda*exp(-lambda*z))

targ1:=lambda*(C[o]^2*exp(2*lambda*z)-D[o]^2*exp(-2*lambda*z))*(1-r^2);

lambda*(C[o]^2*exp(2*lambda*z)-D[o]^2*exp(-2*lambda*z))*(-r^2+1)

ans1:=thaw(factor(combine(expand(H(A1)))));

lambda*(C[o]^2*exp(2*lambda*z)-D[o]^2*exp(-2*lambda*z))*(-r^2+1)

A2:=lambda^2*P[o](z)*(1+r^2)+v[o](r,z);

lambda^2*(C[o]*exp(lambda*z)+D[o]*exp(-lambda*z))*(r^2+1)+(-r^3+2*r)*(C[o]*lambda^2*exp(lambda*z)+D[o]*lambda^2*exp(-lambda*z))

targ2:=lambda^2*(C[o]*exp(lambda*z)+D[o]*exp(-lambda*z))*(1+r^2+2*r-r^3);

lambda^2*(C[o]*exp(lambda*z)+D[o]*exp(-lambda*z))*(-r^3+r^2+2*r+1)

ans2:=thaw(factor(combine(expand(H(A2)))));

lambda^2*(C[o]*exp(lambda*z)+D[o]*exp(-lambda*z))*(-r^3+r^2+2*r+1)

simplify(ans1-targ1);

0

simplify(ans2-targ2);

0

targ2+targ1;

lambda^2*(C[o]*exp(lambda*z)+D[o]*exp(-lambda*z))*(-r^3+r^2+2*r+1)+lambda*(C[o]^2*exp(2*lambda*z)-D[o]^2*exp(-2*lambda*z))*(-r^2+1)

ans2+ans1;

lambda^2*(C[o]*exp(lambda*z)+D[o]*exp(-lambda*z))*(-r^3+r^2+2*r+1)+lambda*(C[o]^2*exp(2*lambda*z)-D[o]^2*exp(-2*lambda*z))*(-r^2+1)

 

Download somesimplification.mw

Compare what you have done, with these choices for the tickmarks option:

tickmarks = [tickList, tickList, default]

tickmarks = [tickList, tickList, [0=0,1=1]]

tickmarks = [tickList, tickList, [op(map(rhs=rhs,rtable_elems(B))), 0=0]]

(The last two of those should give the same effect, for your B. I mentioned the last once only in case you later start putting in other values within B and want it to pick them up automatically.)

restart;

fseqn := (Se, f) -> Se^(f+1):

Vector(5, j->fseqn(2.1, j));

                      [  4.41   ]
                      [         ]
                      [  9.261  ]
                      [         ]
                      [ 19.4481 ]
                      [         ]
                      [40.84101 ]
                      [         ]
                      [85.766121]

Please try working with methods suggested for your earlier, very similar Questions, before asking even more on this theme.

restart;

kernelopts(version);

`Maple 2015.2, X86 64 LINUX, Dec 20 2015, Build ID 1097895`

randomize():

 

ee := InertForm:-MakeInert( 'log[a]'(b*x+c) ):

InertForm:-Display(ee, inert=false);

log[a](b*x+c)

value(ee);

ln(b*x+c)/ln(a)

rand1:=rand(2..9):

a,b,c := rand1(),rand1(),rand1();

2, 7, 3

InertForm:-Display(ee, inert=false);

log[2](7*x+3)

value(ee);

ln(7*x+3)/ln(2)

 

Download another.mw

It's interesting that this works:

int(diff(f(x,y),x)*g(x)+f(x,y)*diff(g(x),x), x);

                          f(x, y) g(x)

For your goal, could you get dsolve to do it for you?

de := diff(K(x,y),x) = diff(f(x,y),x)*g(x,y)+f(x,y)*diff(g(x,y),x):

raw := dsolve({de}):

raw[1];

           {K(x, y) = _F1(y), f(x, y) = 0, g(x, y) = g(x, y)}

raw[2];

   /                                                K(x, y) + _F1(y) \
  { K(x, y) = K(x, y), f(x, y) = f(x, y), g(x, y) = ----------------  }
   \                                                    f(x, y)      /

solve(raw[2], K(x,y));

                  {K(x, y) = g(x, y) f(x, y) - _F1(y)}
First 169 170 171 172 173 174 175 Last Page 171 of 336