acer

32363 Reputation

29 Badges

19 years, 332 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are answers submitted by acer

Use a semicolon rather than a colon at the end of the command which would normally cause the plot to be displayed (ie. in this case the `plot3d` call).

acer

You can use so-called 2-argument `eval` for this.

eval( theta3, sol);

If the choice of variable names are changed then using `eval` in this way will be more robust then referring to some member of the set `sol` by position. For some other choice of variable names the position of the equation for `theta3` might be different (ie. not necessarily the 5th place).

acer

Import as datatype anything to Matrix M. The extract the column of interest, eg. V:=M[..,3] for the third column, say. Extract the column of M that you believe to contain floats.

At this point the entries of V are either all floats, or at least one is not. You wrote that the corresponding column in M does contain all floats. If that is true then so should V.

Then try executing Vector(V,datatype=float[8]) and if it produces an error message then post that here.

Other tests you might possibly find useful are,

type(V,'Vector(float)');

{seq(whattype(x), x in V)}; # could be slow

You wrote, "That fails since my data are now not floats." What was "that" operation that failed?

acer

If you only need a plot (reasonably) quickly, and only require the plotted function to be as accurate as is reasonably discernable by eye, then you can plot the numeric integral using relaxed accuracy requirements. Turning off adaptive plotting can also speed it up, but you may need to adjust the forced number of plotted points as the plotting range of the oscillatory function is increased.

The plot looks smoother in the Std GUI than is shown below. I lose resolution when exporting and uploading here. It doesn't take much longer, with keeping the adaptive plotting turned on.

To reduce the accuracy requirement I pass the epsilon=value option to evalf(Int(...)) , and so I rename your variable `epsilon` to `varepsilon` in order to avoid a naming conflict.

It's not strictly necessary to symbolically take the real part of your original integrand here, but it is a bit faster I think.

restart:  

igrand:=exp(I*epsilon*ln((2+t)/(2-t)))*exp(I*n*t)/sqrt(4-t^2)/Pi:
igrand:=simplify(evalc(Re(igrand))) assuming real, t>-2, t<2:            
newigrand:=subs(epsilon=varepsilon,igrand):                                  

ee:=Int(newigrand,t=-2..2,epsilon=1e-5,method=_d01ajc):                      

st:=time():
plot(eval(ee,[varepsilon=-0.4]),n=-10..10,adaptive=false,numpoints=100); 
time()-st;

                                 0.260

acer

restart:

v:=[seq(0.29+i/100,i=1..8)]:
k:=[seq(2*i,i=1..50)]*0.5*10^(-15):

M:=ExcelTools:-Import("data1.xlsx"):

plots:-surfdata(M, v[1]..v[nops(v)], k[1]..k[nops(k)]);

The `surfdata` command would accept Matrix(M) as well as listlist M, which would let you compare with calling `matrixplot`.

And of course you could just use 8 and 50 instead of nops(v) and nops(k). Or just use the first and last entries of your current v and k (and don't bother to construct either of those two lists unless you need them for something else...). Ie,

 

plots:-surfdata(M, v[1]..v[8], k[1]..k[50]);

plots:-surfdata(M, 0.3..0.37, 1e-15..5e-14);

and so on.

acer

Suppose that you have called dsolve/numeric without the option `listprocedure` and passed the result `sol` to plots:-odeplot, and obtained a warning about a singularity. Even though the warning itself cannot be trapped, you can still invoke `sol` at the farthest (rightmost, say, or "last") t=time point which you hoped to plot and get a trappable error.

For example, suppose that you wanted to plot from 0..1000 and have computed a result `sol` from dsolve,numeric which has a first singularity to the right of 0.0 occuring at approximately 701.02. After plotting, you can invoke,

p:=proc(dsn,val)
   try
      dsn(val); 
      "no singularity found";
   catch "cannot evaluate the solution further":
      eval(t,dsn('last'));
   end try;
 end proc:

> p(sol,500);
                            "no singularity found"

> p(sol,1000);
                               701.022570685642

Hence you can construct a programmatic mechanism for testing whether a singularity was hit, and what the value of the independent varaible `t` was. The technique is easy to adjust if you have used the output=listprocedure option.

What procedure `p` does is trap and manipulate a situation like this,

sol(1000):

Error, (in sol) cannot evaluate the solution further right of 701.02257,
probably a singularity

acer

Suppose that the Buttons have their Names as Button1, Button2...,Button6 and that the list of six values is `L`.

for i from 1 to 6 do
  DocumentTools:-SetProperty(cat(Button,i),'caption',L[i],'refresh'=true);
end do:

If you are planning on doing that repeatedly, for many different values in `L`, then you might consider assigning the button names to its own list and then accessing them without having to re-do the `cat` calls each time. Eg,

# do this just once
ButtonNameList := [seq(cat(Button,i), i=1..6)]:

# ...and then, for each different list of values L,
for i from 1 to 6 do
  DocumentTools:-SetProperty(ButtonNameList[i],'caption',L[i],'refresh'=true);
end do:

acer

Try it with,

   sprintf("C:\\Users\\Sorted_Eigenvectors_%d.txt",i)

as that first argument to ImportMatrix.

acer

With a little extra work, yes. See here for a couple of ways (or varying efficiency vs ease).

acer

Maple 17 does this.

BesselI(0,I*x);

                         BesselJ(0, x)

It's also done in Maple 12 and Maple 14. I didn't try others. Which version do you have?

acer

Your code uses `int`, and `is` which are not thread-safe.

btw, it's very inefficient to have that call to `unapply` be inside the for-do-loop.

acer

Maybe it is related to 0 as the lower index value on the Sum.

> T:=1/(6*0+1)!+Sum(1/(6*k+1)!, k=1..infinity):

> evalf(T);

                                  1.000198413

> simplify(combine(radnormal(value(T))));

    /                   1/2                  1/2
    | 1/2              3                    3
1/6 |3    exp(3/2) sin(----) + exp(3/2) cos(----) + exp(2)
    \                   2                    2

                          1/2                  1/2     \
        1/2              3                    3        |
     + 3    exp(1/2) sin(----) - exp(1/2) cos(----) - 1| exp(-1)
                          2                    2       /

> evalf(%);

                                  1.000198414

acer

I'm not sure which dictionary you mean.

One can easily adjust this code to look for uppercase "FL" and "S" only, or to allow both uppercase and lowercase.

restart:

with(StringTools): with(PatternDictionary):
bid:= Create(`ospd3`): # Create(`builtin):
words:= [seq](Get(bid,i),i=1..Size(bid)-1):

select(proc(s) s[1..2]="fl" and s[-1]="s"; end proc, words);

acer

Depending on the nature of your code it might be possible to parallelize it with the Grid or Threads packages.

acer

Embedded components are great for this kind of thing. You can make it simple, or very fancy.

Here's something simple.

sliderlabel.mw

acer

First 249 250 251 252 253 254 255 Last Page 251 of 336