acer

32490 Reputation

29 Badges

20 years, 7 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

@Kitonum If the goal is to fit a linear model then the code as written (to call Statistics:-Fit with model a+b*x supplied literally as first argument) may work unexpectedly if a or b are assigned, say, numeric values at the higher level at which LinModel is called. One easy way to deal with that is to declare a and b as local.

Or LinModel could call CurveFitting:-LeastSquares and omit the model argument.

@Earl The reason that Kitonum's original didn't pretty-print as nicely in your Maple 2016 is that you have its default of standard for interface(typesetting), while in Maple 2019 the default is extended.

If you execute interface(typesetting=extended): in Maple 2016.2 then it too will show as Kitonum's original.

One way to force it -- regardless of typesetting level -- is to make the following adjustment to the code. The inert=false option has the additional effect of making all the (+) plus signs render in usual output blue/black rather than gray.

LongSum:=proc(f,n0,n)
 InertForm:-Display(`%+`(seq(f(k),k=1..n0)),
                    ':-inert'=false)+`...`+f(n);
end proc:

LongSum(n->x[n], 2, n);
LongSum(n->n/(n+1), 3, k);
LongSum(n->n/(n+1), 3, 100);

@ActiveUser I am not going to give you a full introductory tutorial to the subject of signal processing.

You can find plenty of that on the internet. You might even look on Mapleprimes and the App Center.

But you could start by searching for FFT (Fast Fourier Transform).

Even a linear fade-in/out for each note (rather than a merging glissando) reduces the clicks I had previously. Now I hear just a minor click between re-runs, when looping it.

The fade could be constructed more automatically, based on the sample rate and duration.

restart;
with(AudioTools):

MK := proc(f::numeric)
        AudioTools:-Create(duration=0.5,rate=44100,
             x->evalhf(sin(x*2*Pi*f/44100))):
      end proc:

S1:=Array(1..22050,x->evalhf(piecewise(x<0.6*22050,5/3*x/22050,
                                       x<0.8*22050.0,1.0,
                                       5*(1.0*22050-x)/22050.0)),
           datatype=float[8]):
S2:=Array(1..22050,x->evalhf(piecewise(x<0.2*22050,5*x/22050,
                                       x<0.8*22050.0,1.0,
                                       5*(1.0*22050-x)/22050.0)),
           datatype=float[8]):
S3:=Array(1..22050,x->evalhf(piecewise(x<0.2*22050,5*x/22050,
                                       x<0.4*22050.0,1.0,
                                       5/3*(1.0*22050-x)/22050.0)),
           datatype=float[8]):

Cmaj:=Create(Vector([S1.MK(261.62),
                     map(u->S2.MK(u),
                         [293.67,329.63,349.23,
                          392.00,440.00,493.88])[],
                     S3.MK(523.25)])):

Write(cat(kernelopts(homedir),"/mapleprimes/Cmaj.wav"),Cmaj):

But I have yet to adjust for even loudness (for the average teenage listener, say).

@ActiveUser My computer computes the Array and exports it to a 4.0sec duration .wav file very quickly, doing it all in a fraction of a second in real time. These pure tones Arrays could be constructed quickly in a routine that runs wholly under evalhf, even in Maple 12. So I suspect that it could be built faster, using AudioTools only for its Write command.

But I won't have time to look at that before Sunday night at the earliest. And I wouldn't know for sure until next week whether it's all just slower in Maple 12 (or whether you might just have a slow machine).

And of course I have no idea what you mean when you say you've used a for-loop, because you haven't been polite enough to show your code.

@ActiveUser 

Here's a C major scale, from C[4] (Middle C) to C[5] (Tenor C), with A[4]=440.00Hz and equal temperament.

restart;
with(AudioTools):

MK := proc(f::numeric)
        AudioTools:-Create(duration=0.5,rate=44100,
             x->evalhf(sin(x*2*Pi*f/44100))):
      end proc:

Cmajor:=Create(Vector(map(MK,[261.62,293.67,329.63,349.23,
                              392.00,440.00,493.88,523.25]))):

Write(cat(kernelopts(homedir),"/mapleprimes/Cmajor.wav"),
      Cmajor):

When I play the exported .wav file I hear a click between the pure tones. It might be possible to remove it by having a windowing effect to have the power taper at the ends of the notes, ie. a fade-in/out, or a glissando. (I won't use any windowing functionality from the SignalProcessing package because the OP has Maple 12.)

I have not used any equal loudness contour so as to make all these pure tones have the same loudness (in phons).

@Christian Wolinski Yes, I used vi to delete validly enclosed XML blocks, and bisection searched for the problematic part.

The GUI should be more robust in handling an invalid blob of Typesetting, and not fall flat. I will submit a bug report.

@Christian Wolinski In your attachment most of the 2D Input is no longer typeset, and most inputs are changed from executable input to mere text, and some heading styles are gone.

Show us what work you've done so far with this homework task.

Upload it in an attachment (green up-arrow)m in a Reply/Comment.

Show us what work you've done so far with these homework tasks.

Show us what work you've done so far with these homework tasks.

@pgordon1998 Your task is to write procedures and assign them to PowerSet and RandSet. Your output indicates that so far those names are still unassigned. Did you write such procedures? Did you assign them to those names?

@pgordon1998 Your output shows that you have not yet assigned anything to list_to_set (or set_to_list).

Did you write previous code for a procedure for list_to_set? That's the task. Perhaps you've written a procedure for it, but did not assign it properly?

@susanhl I've tried to tell you that I think that your original method (and Tom's "fix" for it) has several dubious aspects to it.

You could use dsolve(...,numeric) to find the first time t at which the displacements match their targets.

I've edited my Answer to illustrate how your original could be used to try and find the solution with smallest positive t.

@susanhl I'm now supposing that you're simply trying to solve eindx and eindy together. That is, to find values for t and v0 which satisfy both those equations.

This can be done directly in your worksheet, without any weird indexing, any use of fixed accuracty approximations of Pi, etc. And especially without any dubious looking RootOfs or float coefficients with very large exponents.

I've used Maple 16 below, like your original.

Perhaps you'd want to supply ranges for t or v0 in the call to fsolve? And there may be more than one solution.

restart

kernelopts(version);

`Maple 16.01, X86 64 LINUX, May 6 2012, Build ID 744592`

mbal := 0.28e-2:

rbal := 0.2e-1:

Cw := .47:

g := 9.81:

A := Pi*rbal^2:

beta := 3.33*Pi*(1/180):

s0x := .2:

s0y := .25:

rho := 1.293:

l := 2:

vx := diff(sx(t), t);

diff(sx(t), t)

vy := diff(sy(t), t);

diff(sy(t), t)

ax := diff(sx(t), `$`(t, 2));

diff(diff(sx(t), t), t)

ay := diff(sy(t), `$`(t, 2));

diff(diff(sy(t), t), t)

v0x := cos(beta)*v0;

cos(0.1850000000e-1*Pi)*v0

v0y := sin(beta)*v0;

sin(0.1850000000e-1*Pi)*v0

`&Sigma;Fx` := -Fdx = mbal*ax;

-Fdx = 0.28e-2*(diff(diff(sx(t), t), t))

`&Sigma;Fy` := -Fz-Fdy = mbal*ay;

-Fz-Fdy = 0.28e-2*(diff(diff(sy(t), t), t))

Fz := mbal*g;

0.27468e-1

Fdx := .5*rho*vx^2*A*Cw;

0.1215420e-3*(diff(sx(t), t))^2*Pi

Fdy := .5*rho*vy^2*A*Cw;

0.1215420e-3*(diff(sy(t), t))^2*Pi

ics1 := sx(0) = s0x, (D(sx))(0) = v0x;

sx(0) = .2, (D(sx))(0) = cos(0.1850000000e-1*Pi)*v0

ics2 := sy(0) = s0y, (D(sy))(0) = v0y;

sy(0) = .25, (D(sy))(0) = sin(0.1850000000e-1*Pi)*v0

verplaatsingx := dsolve({ics1, `&Sigma;Fx`}, sx(t)):

verplaatsingy := dsolve({ics2, `&Sigma;Fy`}):

eindy := rhs(verplaatsingy) = rbal:

eindx := rhs(verplaatsingx) = l:

S1 := fsolve({eindx,eindy}, {t,v0}, {t=0..infinity});

{t = 2.505529244, v0 = .8156407228}

eval(t,S1);

2.505529244

S2 := fsolve({eindx,eindy}, {t,v0}, {t=0..eval(t,S1)}, avoid={S1});

{t = .2655908244, v0 = 7.694586917}

S3 := fsolve({eindx,eindy}, {t,v0}, {t=0..eval(t,S2)}, avoid={S1, S2}):
op(0,eval(S3,1)); # unevaluted return, ie. no earlier root

fsolve

#
# Let's write a loop to try and find the least
# positive value of t which solves {eindx,eindy}.
# This stops when no solution with smaller positive
# value for t is found.

continue := 'continue': found := {}: lastT := infinity:
while continue <> false do
  printf("searching on %a\n",t=0..lastT);
  S := fsolve({eindx,eindy}, {t,v0}, {t=0..lastT}, avoid=found);
  if op(0,eval(S,1)) <> fsolve then
    lastT,lastv0 := eval(t,S),eval(v0,S);
    printf("  solution found for %a\n",t=lastT);
    found := S;
  else
    printf("  no smaller solution found");
    continue := false;
  end if;
end do:

searching on t = 0 .. infinity
  solution found for t = 2.505529244
searching on t = 0 .. 2.505529244
  solution found for t = .2655908244
searching on t = 0 .. .2655908244

  no smaller solution found

t=lastT, v0=lastv0;

t = .2655908244, v0 = 7.694586917

 

Download ttbuddymaple_ac4.mw

Why don't you show us how far you managed to get with this so far.

First 204 205 206 207 208 209 210 Last Page 206 of 594