acer

32822 Reputation

29 Badges

20 years, 133 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

I resisted changing everything to my own taste, since I believe that the OP is learning by doing.

Otherwise, a somewhat similar effect could be had with, say,

restart;

F:=proc(u,a,b,c,d)
  local expr, x;
  if u="   y = a sin(b x + c) + d " then
    expr := evalf[3](a*sin(b*x + c) + d);
    plot(expr, x=-2*Pi..2*Pi,
         ':-title'=expr,
         ':-view'=-3 .. 6);
  elif u="   y = sin(a x) + cos(b x) " then
    expr :=  evalf[3](sin(a*x) + cos(b*x));
    plot(expr, x=-2*Pi..2*Pi,
         ':-title'=expr,
         ':-view'=-2..2);
  else error u;
  end if;
end proc:

Explore( F(`function :`,a,b,c,d),
         parameters=[ [`function :`=["   y = a sin(b x + c) + d ",
                                     "   y = sin(a x) + cos(b x) "],
                       #controller="listbox",
                       placement=top]
                    ],
         a = 1.0 .. 3.0, b = 1.0 .. 3.0,
         c = 0.0 .. 2*Pi, d = 0.0 .. 3.0,
         placement = right
         #, newsheet, showbanner=false, startupdefinitions=[F]
       );

Could you upload your data here as an attachment (green up-arrow)?

@Ramakrishnan One of the problems with your original was that MyApp did not export ChangeE. So when you called ChangeE() in the code of the Sliders nothing happened.

If you are interested in using different formulas and radio buttons:  doubt2_MathContainer_ac2.mw

@Ramakrishnan You mean you're posting the same question twice? Please don't do that.

The first thing to clarify is the format of your data. It looks like the three columns denote four points of [x,y,z] data, rather than a 3x4=12 collection of [x,y] data points. Is that right?

What version of Maple are you using?

Is this a toy example, and you plan on wanting to do it for larger sets of points (possibly with surface smoothing)? Or do you just need to deal with this kind of simple 3D polygon with a quadrilateral base?

 

@dorna01 Tacking that comment onto a 9 year old message thread is not helpful. Post your example as a new Question.

Don't say that you could upload the worksheet or code later, if needed. Just include the relevant materials and details when you post.

@Carl Love I'm not aware of any mechanism by which Library code could robustly compute the display-width of rendered, 2D prettyprinted output (at 100% zoom, say).

And I have tried pretty hard to find one.

Rough approximations can be constructed, using offset values for fractions, max of numer and denom, offsets for fencing, Int/Sum/Product symbols, radicals, etc.

But really the only thing that might be true to form is the result from a new GUI streamcall. The Typesetting package is not enough.

It's  not clear to me that a rough kluge would be better than nothing. But, I agree that it would be an improvement to have the weighting be set automatically, if it could be done reliably.

There would be other, related uses for the display-width information.

 

@Carl Love Very nice, vote up.

You could get a printing effect with,

Tabulate(Table(
   [Bin(n,p), DiscrUni(a,b), Poiss(lambda), NegBin(p)],
   [Unity, Mean, Variance, Skewness, Kurtosis]
)):

Tabulate(Table(
   [Bin(n,p), DiscrUni(a,b), Poiss(lambda), NegBin(p)],
   [Unity, Mean, Variance, Skewness, Kurtosis]
), weights=[3,1,2,3,3,5]):

(I was a little disappointed that the `lambda` in the row headers isn't typeset when Tabulated, but it doesn't detract too much.)

@mmcdara There are concrete benefits which support this point of view.

The representation is sparse, and so can take less space or memory.

That can hold for line-printing. It can also hold for round trip programmatic recreation, using `rtable`, `rtable_indfns`, `rtable_elems`, and `rtable_options`.

@mmcdara Right. The creating of a temporary rtable, and its processing by the garbage collector afterwards, incurs a relatively small time penalty.

The penalty in memory allocation incurred by the extra rtable is transient, and the collected memory can even be returned to the OS now.

Memory "used" just means memory processed by the garbage collector, and its significant effect is just whatever time that takes.

But, aside from that time overhead, memory "used" is not a penalty in itself.

On a related topic, I would like to see Statistics:-Sample become thread-safe. And I'd like to be able to parallelize it. I suspect it may be assigning to module locals in the usual thread-global way (although there is special syntax available now for thread-local module locals).

@Gabriel samaila So why did you upload an attachment saved with Maple 16 before?

@Gabriel samaila The worksheet you attached was saved using Maple 16, which was released in the year 2012.

That is not the same as Maple 2016, which was released in the year 2016.

The size option for 2D plotting commands was introduced in Maple 18, released in the year 2014.

Maple 16      (2012)
Maple 17      (2013)
Maple 18      (2014)
Maple 2015  (2015)
Maple 2016  (2016)
Maple 2017  (2017)
Maple 2018  (2018)

I look forward to Maple 2019, since there was no Maple 19.

 

@Carl Love Actually, It would only be slightly faster, since Statistics:-Sample is returning a Vector with datatype=float[8].

The elementwise operation cot~ applied over a float[8] Vector uses evalhf, and is already fast.

With map[evalhf,inplace] there is small benefit in avoiding creation of new Vector, with the copy semantics of the elementwise operation.

@Haqphy12015 I don't really see how your uploaded data could make a plot that looks exactly like that image. Leaving aside the integration, did you expect the blue curve of the data itself to loo like the image? The domain of w doesn't even match.

Here's what I get from your uploaded data. Note that I don't know what you expect to happen when w becomes zero (especially given how your uploaded image doesn't show blowup). So I just fudged that case to act like w=1.

I don't see how higher order interpolation could be meaningful results for you large w increments (not to mention the division by small w).

I didn't bother to multiply the integration results by 2, which might be what you were trying to state in your question.

restart;

M := ImportMatrix(cat(kernelopts(homedir),"/mapleprimes/data-w-a2F(w).txt")):

M[1,..];

"[[["w",,,"a2F(w)"]]]"

m := op([1,1],M)-1;

200

W := M[2..,1]:
F := <seq(seq(M[j,i],i=2..4)[1],j=2..m+1)>:

A:=<W|F>;

A := Vector(4, {(1) = ` 200 x 2 `*Matrix, (2) = `Data Type: `*anything, (3) = `Storage: `*rectangular, (4) = `Order: `*Fortran_order})

H := proc(N::posint)
  local i, S1, S2;
  S1:=add(F[i]/`if`(W[i]=0,1,W[i])*(W[i]-W[i-1]),i=2..N):
  S2:=add(F[i]/`if`(W[i]=0,1,W[i])*(W[i+1]-W[i]),i=1..N-1):
  (S1+S2)/2;
end proc:

Hdata := [seq([W[i],H(i)],i=1..m)]:

plots:-display(
  plot(A, color=blue),
  plot(Hdata, color=black),
  size=[500,300]
);

 

Download numint_data.mw

@Preben Alsholm Just a few observations.

numint.mw

First 235 236 237 238 239 240 241 Last Page 237 of 601