acer

32500 Reputation

29 Badges

20 years, 11 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

There is a line,

alpha=evalf(alpha);

Making it into an assignment appears to work. At the beginning, alpha is aliased to LambertW(exp(-1)) which is exact.

But perhaps exact LambertW(exp(-1)) is a problem during the numeric dsolving...  Does someone see a better way, which allows instances of alpha to remain with its symbolic appearance throughout? I mean, something more graceful than either assigning alpha as a float or substitution of alpha=evalf(alpha) into each or the problematic DE system arguments to DEplot?

acer

Your code has this incorrect syntax,

  with*Optimization;

which should probably be

  with(Optimization);

Also, if that's the package you are trying to use then the command within it is `Minimize` not `minimize`. Note that Maple is case-sensitive.

If you fix those two items, and still have problems with it, then please just add a followup comment in this current thread.

acer

It might be tempting to believe that the answer could be (2*n*2^a*Pi^(a+1)+2*a+2)/((a+1)*n).

And a hint might be seen by the crude substitution of values,

restart:
seq( [int(abs(sin(n*x)-x^i),x=0..2*Pi),
      normal(2/(i+1)*(2^i*Pi^(i+1)*n+i+1)/n)],
     i=2..10 ) assuming n::posint;

But there is a difference of 2/n whioh I don't understand in the following,

restart:

unprotect(series): oldseries:=eval(series):
unprotect(limit): oldlimit:=eval(limit):
series:=MultiSeries:-series:
limit:=MultiSeries:-limit:

cand:=int(abs(sin(n*x)-x^a),x=0..2*Pi) assuming a>1, n::posint;

    1     /   (a + 1)   (a + 1)   /     /      /             a\ 
--------- \n 2        Pi        - \limit\signum\-sin(n x) + x / 
n (a + 1)                                                       

                     /             a\  (a + 1)  
  cos(n x) a + signum\-sin(n x) + x / x        n

           /             a\                       \\        \
   + signum\-sin(n x) + x / cos(n x), x = 0, right// + a + 1/

series:=eval(oldseries):
limit:=eval(oldlimit):

simplify(cand) assuming a>1, n::posint;

                        (a + 1)   (a + 1)
                       2        Pi       
                       ------------------
                             a + 1   
    
simplify( (2/(a+1)*(2^a*Pi^(a+1)*n+a+1)/n) - % );

                               2
                               -
                               n

I suppose that it might not necessarily be valid to apply (and simplify under) an assumption like n::posint to `cand` above while it still contains a pending unevaluated limit (as x->0+).

acer

Explore(plot(A*sin(w*x+c),x=-2*Pi..2*Pi,view=-10..10),
        parameters=[A=1.0..10,w=1.0..20,c=Pi/6..11*Pi/6]);

You could also do,

plots:-interactive(A*sin(w*x+c));

and use the uppermost drop-menu in the PlotBuilder dialogue which pops up, and select interactive plots with one/two parameters.

You can also use `plots:-interactiveparams` and get a Maplet popup view with sliders.

And some of these can also work by calling `plots:-animate` as their plotting command.

See the help-pages for all these commands, for more examples.

acer

There are several things that would make life easier here.

Use `*` on your keyboard for multiplication, even if you are in 2D Math input mode. Using that cross symbol (from a palette, presumably) gets something that evaluates ok, sure. But it is ugly, and conversion to 1D Notation goes pretty wrong as Patrick mentioned.

Your lowercase letter L displays almost exactly like the numeral one, which makes it very confusing visually and leads to visual ambiguity (and perhaps even mistakes). For example, there is no lowercase L appearing in the integrand of your second expression. Is that right? Hard to tell what you intended. Oh, wait, that upper limit of integration is... yes.. a lowercase L and not the number 1. It's confusing, since on my Windows 7 Maple 17 those  prettyprint almost identically for your input expression. So I will use capital L from here on.

Next, for unknown `d` and `L` your integral will not compute exactly (well, it might under assumptions, but let's keep it simple for now). This is the second time in 24 hours that this topic has arisen: plotting an integral using the active `int` command which fails to evaluate exactly can be slow. It can be slow because -- after the integration of the argument involving active `int` fails  -- the plotting routine receives and unevaluated `int` call as its argument. But then, for every substituion of numeric values of the plotting variables, this integral gets attempted over and over. Now, you might get lucky if your integration range also happens to be numeric (since a float range will make `int` do numeric quadrature), but really the whole topic is too confusing for the new user at this point.

... so it's often much simpler and faster to use inert uppercase `Int` for integral expressions that are to be plotted.

Another possibility, which I do not show below, is to try and get the exact value of the integral under assumptions on `d` and `L` which match the plotting ranges you've supplied.

Now, we've seen a hint that you may be relying on the palettes for entering 2D Math expressions (as an unfortunate consequence of over-enthusiam in the help portal for Clickable Math, perhaps). And the Expression palette only provides the active (dark black integral symbol) `int`. Well, you can still get a nicely typeset inert integral `Int` by using command-completion. Just start typing Int as 2D Math input, and then do  command-completion (Ctrl-spacebar on MS-Windows.) The second entry in the menu the pops up will be the template for an inert definite integral.

Notice that inert `Int` gets typset in a lighter shade of gray for the integration symbol.

There is another possible reason why you might want an inert integral. Your plotting and integration variables take on values in the region near 10^(-6), and the integrand takes 4th powers in the denominator and scales  heavily by numeric factors in the numerator. This might be bad scaling. Which might be why you encountered some numeric difficulties, ...but then I didn't really test for that. Anyway, if you want to then you can rescale either `d` or `L` or both. It's quite possible that your original is better scaled, and better left as is. I really didn't check.

Here's a worksheet that might help.

If you decide to rescale then you may wish to use axis labels which show the scaling factors. At the end of the sheet are a few different ways to get such products to be typset. None is the (perfect, IMHO) visual form like `d 10^-6`, however.

 

plot3d((128*1.2)*10^(-3)*10^(-14)*L*10^(-6)/(Pi*(d*10^(-6)+2*L*10^(-6)*0.85e-1)^4), d = .1 .. 1.5, L = 5 .. 50, axes = box, font = [TIMES, ROMAN, 13])

plot3d(Int((128*1.2)*10^(-3)*10^(-14)/(Pi*(d+2*x*.176)^4), x = 0 .. L), d = .1*10^(-6) .. 1.5*10^(-6), L = 5*10^(-6) .. 50*10^(-6), axes = box, font = [TIMES, ROMAN, 13])

plot3d(Int((128*1.2)*10^(-3)*10^(-14)/(Pi*(d*10^(-6)+2*x*.176)^4), x = 0 .. L*10^(-6)), d = .1 .. 1.5, L = 5 .. 50, axes = box, font = [TIMES, ROMAN, 13])

R := Int((128*1.2)*10^(-3)*10^(-14)/(Pi*(d+2*x*.176)^4), x = 0 .. L)

Int(0.1536000000e-14/(Pi*(d+.352*x)^4), x = 0 .. L)

Rnew := IntegrationTools:-Change(eval(R, [d = d*10^(-6), L = L*10^(-6)]), t = x*10^6)

0.1193662073e12*(Int(1/(125.*d+44.*t)^4, t = 0 .. L))

plot3d(Rnew, d = .1 .. 1.5, L = 5 .. 50, axes = box, font = [TIMES, ROMAN, 13], labels = [sprintf(

sprintf(

 

 

Download dropmodif.mw

acer

Does this make something like what you're after? (It requires m>=2, n>=2 which you could put in as argument checking if you have the need.)

 

G:=proc(m,n)
   local minmn, maxmn;
   minmn:=min(m,n); maxmn:=max(m,n);
   LinearAlgebra:-BandMatrix([[1$`if`(n>=m,minmn-2,n-1),2],
                              [3$minmn],
                              [2,1$`if`(n>m,m-1,minmn-2)]],1,m,n);
   end proc:

G(5,4);
G(10,7);
G(2,2);
G(6,6);
G(4,5);
G(7,10);

 

If it's not quite what you want, in the case of nonsquare n<>m, then you could try adjusting the code after looking over the BandMatrix help page. Note that this makes a `band[1,1]` storage Matrix. You can change that, or the datatype if you need it for speed efficiency, as options to that constructor command.

acer

This doesn't recover subsection 2.1, but it does seem to get back the earlier part of section Lek 2.

BETmodif.mw

acer

You seemed to be missing a closing bracket, and so I made a guess as to which variable you wanted as the dummy variable of integration. (Adjust, if I guessed wrongly.)

How about something like this? It forces purely numerical integration and restrains its requested accuracy because you might not need so many digits of accuracy, just for plotting.

restart:

Z := theta->sin(theta+2.3)+sin(2*theta+2*(-1.5))+sin(3*theta+3*(-0.94e-1)):
Zbar := (theta, phi)-> Z(theta+phi)-Z(theta):

H:=Int(signum(Zbar(theta, phi)+l)*abs(Zbar(theta, phi)+l)^(1/4),
       theta=0 .. 2*Pi, epsilon=1e-5, method=_d01ajc):

evalf(subs(phi=1/2,l=1/2,H));

plot3d(H, phi=0..1, l=0..1, grid=[20,20], axes=box);

acer

Two main things come to mind.

1) There are a few other ways to get similar results, some of which might already be acceptable (for some people).

For example, given your 20-by-20 Matrix `A`,

A[..,[seq(j, j=1..20, 2)]];

A[[seq(i, i=1..20, 10)],1..3];

2) Maple has some nice facilities for rtable indexing. But less is documented about being efficient, and yet it seems to me that quite often people are surprised when their easy-to-use, convenient code does not scale best as the problem sizes are ramped up high. If I had to make lots of such plots then I would be tempted to re-use structures rather than index into existing structures. For example I might create an m-by-2 float[8] Matrix `M` just once, and then ArrayTools:-Copy various rows or columns into `M` whenever I wanted to produce another such plot. It doesn't have to be done exactly that way, of course, and the methodology could reflect the situation. But for very large sizes I might be tempted by the idea of producing less work for the garbage collector, with each plot. Of course, such approaches might only be worth it if the interface (commandline, say) is also efficient in producing/exporting plots.

2) is also related somewhat to this (in which Joe's comment about ArrayTools:-Alias is worth noting.)

restart:
with(Statistics): 

P := Sample(RandomVariable(Normal(10, 10.)), 10^6):
F:=proc(x) `if`(ilog10(x)>-2,parse(sprintf("%.2f",x)),NULL); end proc:

X := RandomVariable(EmpiricalDistribution(map(F,convert(P,list)))):

plot(t->ProbabilityFunction(X,evalf[2](t)),-20..40);

plot(t->ProbabilityFunction(X,F(t)),-20..40);

acer

Someone can likely improve on the thresholding.

restart:
randomize():

R:=proc() local g, P;
      g:=6*(rand(100)/100.0-0.5):
      P:=add(mul(sqrt((x-g())^2+(y-g())^2),i=1..j)/
          mul(sqrt((x-g())^2+(y-g())^2),i=1..j),j=1..5);
      plots:-display([
        z->plots:-densityplot(z,x=-5..5,y=-5..5,
                    colorstyle=HUE,grid=[30,30],style=patchnogrid),
        z->plots:-contourplot(max(1,min(60,z)),x=-5..5,y=-5..5,
                    contours=40,grid=[100,100],thickness=0)](P),
                axes=none,view=[-5..5,-5..5]);
   end proc:

R();

R();

acer

The Matrix/Vector/Array option datatype=complex(float) may be what you are after. That will produce something whose datatype is either complex[8] or complex(sfloat), according to the values of UseHardwareFloats and Digits.

If you want to force the complex hardware (double precision) restriction then you could pass the option datatype=complex[8].

If you want to force the complex "software float" restriction then you could pass the option datatype=complex(sfloat).

acer

First note that you are trying to add a subexpression with unit m^3 to one with with m^2. I don't see how it can make sense to make that unitless without knowing where the "hidden unit" is in the expression, that allows it be regarded as nondimensional.

If the units are compatible, you can use combine,units and then convert,unit_free.

V[dis]:=(3/100000)*Unit('m')^3
        +0.1e-2*Pi*Unit('m')^3*(.112-0.28e-1*cos(theta)
                 -sqrt(0.7e-2-0.1e-2*sin(theta)^2)):

convert(combine(V[dis],units),'unit_free');

                            /                        
            3               |                        
          ------ + 0.001 Pi \0.112 - 0.028 cos(theta)
          100000                                     

                                          (1/2)\
               /                        2\     |
             - \0.007 - 0.001 sin(theta) /     /

acer

1) Try `eval` instead of `showstat`. The former returns something, while the latter merely displays something (and returns NULL).

2) See senior Maple Kernel developer Darin's comment here, perhaps, where he seems to state pretty clearly that what you've asked about cannot work in then current Maple. You cited that very same thread in the earlier post from which you branched off this Question. Do you expect that it might have all changed, for Maple 17?

acer

Yes it is possible, but there are restrictions, and it is tricky. You cannot specify any arbitrary position for the insertion (think of how plots follow plotting commands, as output, as an analogy).

But perhaps that's not what you really need. (Details would help on your goal, please.) Would it suffice to use and re-use a single TextArea that you had inserted earlier at a single location of choice, which you can repeatedly programmatically hide/reveal and clear/populate?

acer

First 253 254 255 256 257 258 259 Last Page 255 of 337