acer

32747 Reputation

29 Badges

20 years, 111 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

See the help-page evalf,Int which is also cross-referenced from the 5th bullet point in the Description section of the help-page for int.

For some other  examples you could look again at a response to your question from last week.

acer

In Maple 16.00 running on Windows 7 with 6GB RAM available, I get results as follows from kernelopts(bytesalloc),  for a single set of attempts.

32bit Maple: n=100  171MB

64bit Maple: n=100  264MB

acer

You could use plots:-odeplot,

gamma1:=1:
gamma2:=1:

l:=t->sqrt((x1(t)-x2(t))**2+(y1(t)-y2(t))**2):

DE:=[diff(x1(t),t)=(-1/(2*Pi))*gamma2*(y1(t)-y2(t))/l(t),
     diff(y1(t),t)=(-1/(2*Pi))*gamma1*(x1(t)-x2(t))/l(t),
     diff(x2(t),t)=(-1/(2*Pi))*gamma2*(y2(t)-y1(t))/l(t),
     diff(y2(t),t)=(-1/(2*Pi))*gamma1*(x2(t)-x1(t))/l(t)]:

plots:-odeplot(dsolve({DE[],x1(0)=1,x2(0)=-1,y1(0)=1,y2(0)=0},numeric),
               [[x1(t),y1(t)],[x2(t),y2(t)]],t=0..50,frames=25,
               color=[gold,gold],thickness=2);

acer

Don't break the long name that looks like `#mrow...`

with(Statistics):
BoxPlot([seq(Sample(Normal(ln(i), 3), 100), i = 1..20)],
title = `#mrow(mi("Jan 2011",mathcolor="#ff00ff"),mi(" --- "),mi("Dec 2011",mathcolor="#005555"))`,
color="ff00ff".."005555",deciles = false);

Statistics:-BoxPlot([seq(Statistics:-Sample(Normal(ln(i), 3), 100), i = 1..20)], title = `#mrow(mi(

Another example, building up that long TypeMK name (which you could also do with a procedure),

clr1:="#999900":
clr2:="#009999":

Statistics:-BoxPlot(
    [seq(Statistics:-Sample(Normal(ln(i),3),100),i=1..10)],
    title = cat(`#mrow(`,
            `mi("Jan 2011",mathcolor=\"`,clr1,`\")`,
            `,`,
            `mi(" --- ")`,
            `,`,
            `mi("Dec 2011",mathcolor=\"`,clr2,`\")`,
             `)`),
    color = clr1..clr2, deciles = false);

Statistics:-BoxPlot(     [seq(Statistics:-Sample(Normal(ln(i),3),100),i=1..10)],     title = cat(`#mrow(`,             `mi("Jan 2011",mathcolor=\"`,"#999900",`\")`,             `,`,             `mi(" --- ")`,             `,`,             `mi("Dec 2011",mathcolor=\"`,"#009999",`\")`,              `)`),     color = "#999900".."#009999", deciles = false)

acer

The explanation is confusing. Did you mean to say instead that the entries of N1, N2... are expressions in terms of `eta`?

Are you trying to map the `int` or `Int` commands over N1,N2... with eta=eta0..eta2 being the extra argument? If so that the syntax is not right. It should be something like map(int,N1,eta=eta0..eta2) or map(Int,N1,eta=eta0..eta2), in that case.

Do you have somethin like this, but for 3x3 Matrices,

N1:=Matrix([[eta,eta^2],[sin(eta),cos(eta)*eta]]);

                             [                 2    ]
                             [  eta         eta     ]
                       N1 := [                      ]
                             [sin(eta)  cos(eta) eta]

L:=[eta0=8.3,eta2=666];

                        L := [eta0 = 8.3, eta2 = 666]

# First way: inert integral with parameters substituted by
# values, then numerical integration performed.
# Be careful with syntax. And note Int not int.
E1:=map(Int,N1,eta=eta0..eta2):
eval(E1,L):
evalf(%);

                     [              5                7]
                     [2.217435550 10   9.846924140 10 ]
                     [                                ]
                     [   -1.431221219     -17.80614111]

# Alternatively, exact integration attempted, followed by
# floating-point evaluation of that result.
E1:=map(int,N1,eta=eta0..eta2):
eval(E1,L):
evalf(%);

                     [              5                7]
                     [2.217435550 10   9.846924140 10 ]
                     [                                ]
                     [   -1.431221219     -17.80614111]

In both ways, you don't have to assign to `eta0` or `eta2`, or change the names used. You just have to build the various lists L.

acer

You have an E(T) which should likely be E(t). You need to use the infix `union` command to merge the sets `dsys` and `isc`.

I changed e^7 to exp(7) which how one exponentiates the base of the natural logarithm in Maple. Or did you intend to use `e` as a variable parameter?

restart;

dsys := {diff(E(t), t) = -kf*E(t)*S(t)+kr*ES(t)+kcat*ES(t),

                diff(ES(t), t) = kf*E(t)*S(t)-kr*ES(t)-kcat*ES(t),

                diff(P(t), t) = kcat*ES(t),

                diff(S(t), t) = -kf*E(t)*S(t)+kr*ES(t)};
  
kf := 10^6; kr := 10^(-4); kcat := .1;
                        
isc := {E(0) = 2/exp(7), ES(0) = 0, P(0) = 0, S(0) = 5/exp(7)};
        
dsol := dsolve(dsys union isc, numeric, method = gear[polyextr],
                initstep = 0.15e-1, minstep = 10^(-11),
                abserr = 0.1e-4, relerr = 0.1e-5);

acer

It's a square.

factor(dell);

                                         2
                      /          (1/2)  \ 
                      \-a + 9 + 6      b/ 

acer

You have X with 8 entries and Y with 9 entries.

Does it help if you reduce the number of entries of Y by one, so as to match that of X?

acer

M := Matrix([[1,2],[3,4],[5,6]]);


                                      [1  2]
                                      [    ]
                                 M := [3  4]
                                      [    ]
                                      [5  6]

M . Vector([1/2,1/2]);

                                    [ 3]
                                    [ -]
                                    [ 2]
                                    [  ]
                                    [ 7]
                                    [ -]
                                    [ 2]
                                    [  ]
                                    [11]
                                    [--]
                                    [2 ]

M . Vector([0.5,0.5]);

                             [1.50000000000000]
                             [                ]
                             [3.50000000000000]
                             [                ]
                             [5.50000000000000]

acer

Here is a version that runs in Maple 12.

The difficulty is the quickly oscillating semi-infinite integral involving BesselJ(1,..) which is decaying slowly. I split the range from 0..infinity to 0..1 and 1..infinity, and then changed variables on the second of those. That gets a sum of two oscillating integrals on 0..1, and these can be handled by method=_d01akc.

It's not particularly fast to compute. The plot takes about a minute on a fast Intel i7, because each evaluation of func is not very fast. I made func a procedure (both to try and get some more speed when doing the outer integral after the plot, but also to try and control the working precision forcibly).

The inner integral involving the Bessel J1 needs to be computed accurately enough that its results allow the final outer integral to converge.

 

restart:

func:=proc(r) option remember;
  .2359951354e-4/Pi*exp(-800000000.0*(r-.375e-4)^2) *
  (evalf(Int(k->-k^2*BesselJ(1.,k*r)*exp(-.1757812500e-9*k^2)/(.66e-2*k^2+2423.07),
             0. .. 1, digits=14, epsilon=1e-11, method=_d01akc)) +
   evalf(Int(K->-BesselJ(1., r/K)*exp(-0.1757812500e-9/K^2)/(K^4*(0.66e-2/K^2+2423.07)),
             0. .. 1., digits=14, epsilon=1e-11, method=_d01akc)));
end proc:

 

st:=time():
plot(func, -0.200e-3 .. 0.200e-3); #, adaptive=false, numpoints=20);
time()-st;

 

78.547

(1)

st:=time():
evalf(Int(func,-0.100e-3 .. 0.100e-3,digits=14,epsilon=1e-7,method=_d01ajc));
time()-st;

-0.11785650145932e-2

 

54.881

(2)

 

 

Download inty.mw

acer

The syntax which you have used for `eq` has several mistakes.

Did you mean,

eq := x*(0.0178)*tan(sqrt(x)*2e-5)^2 = 2.32e12-x;

instead?

acer

Is this what you're after?

plot(exp((1/3)*x)*sin(2*x), x=-2..2);

plot(exp((1/3)*x)*sin(2*x), x=-2..2)

acer

Yes.

You could replace calls like RowDimension(A) with LinearAlgebra:-RowDimension(A) throughout the procedure.

Or, you could replace calls like RowDimension(A) with op([1,1],A) and calls like LinearAlgebra:-ColumnDimension(B) with op([1,2],B).

By the way, you could also add new local variables rowdimA and coldimB to the procedure. Then assign them their values at the start of the procedure, calling RowDimension and ColumnDimension just once each. The way you have it right now those both get called more than once, which is unnecessary use of resources.

Also, you don't need to explicitly set all of the the C[i,j] to zero inside the the double loop. When you previously create C with the Matrix() constructor then all the entries get preassigned and stored as zero by default.

acer

In the way you tried to create the X[k] in a loop, the operators were not formed using each current value of `k`.

Try it this way, instead,

restart:

for k from 1 to 10 do
  X[k]:=Statistics:-RandomVariable(ChiSquare(k));
  f[k]:=unapply(Statistics:-PDF(X[k],x),x);
end do:

f[1](x);

                      /           (1/2)    /  1  \\
                      |          2      exp|- - x||
                      |                    \  2  /|
             piecewise|x < 0, 0, -----------------|
                      |              (1/2)  (1/2) |
                      \          2 Pi      x      /

f[2](x);

                        /          1    /  1  \\
               piecewise|x < 0, 0, - exp|- - x||
                        \          2    \  2  //

A simpler example of the issue,

restart:
k:=2:
f:=x->k*x;
                           x -> k x
k:=11:
f(x);
                              11 x

restart:
k:=2:
f:=unapply(k*x,x);
                           x -> 2 x
k:=11:
f(x);
                              2 x

restart:
k:=2:
f:=subs(U=k, x->U*x);
                           x -> 2 x
k:=11:
f(x);
                              2 x

acer

First 270 271 272 273 274 275 276 Last Page 272 of 341