acer

32328 Reputation

29 Badges

19 years, 317 days
Ontario, Canada

Social Networks and Content at Maplesoft.com

MaplePrimes Activity


These are replies submitted by acer

Can you use fprintf or printf? Those won't insert a line break unless you explicitly include it ("\n").

acer

I don't see exactly what you are trying to do. But there are quite a few issues in the code.

The situation is the same for n. It is declared local and gets used, but is unassigned , in both procedure cycvel and procedure treach.

In the test section, you call cycvel(pos,speed,L,vmax) but vmax is not assigned. Did you mean to pass some value instead?

There is a line in the posted code that is missing something. Possibly a cut'n'paste problem with this site. Namely,

else if pos[n] > end if; end if;

acer

I don't see exactly what you are trying to do. But there are quite a few issues in the code.

The situation is the same for n. It is declared local and gets used, but is unassigned , in both procedure cycvel and procedure treach.

In the test section, you call cycvel(pos,speed,L,vmax) but vmax is not assigned. Did you mean to pass some value instead?

There is a line in the posted code that is missing something. Possibly a cut'n'paste problem with this site. Namely,

else if pos[n] > end if; end if;

acer

Right. Of course. Thanks. So, charfcn[0] it is.

acer

> ztrans(charfcn[0](t),t,z);
                                       1


> ztrans(Heaviside(t),t,z);
                                       z
                                     -----
                                     z - 1

I'm not sure why it doesn't like Dirac(t).

That was all in Maple 6.

acer

Isn't the idea that it's better not to give full explicit answers to course work questions?

Anyway, the above is not correct. It is returning a[i] for the latest value of i. The result should be a[i+2] for the latest value of i, using the code given above.

acer

Isn't the idea that it's better not to give full explicit answers to course work questions?

Anyway, the above is not correct. It is returning a[i] for the latest value of i. The result should be a[i+2] for the latest value of i, using the code given above.

acer

This worked for me, using Maple 11.02.

> for i from 1 to 5 do
> plotsetup(ps, plotoutput="/tmp/test"||i||".eps",
>   plotoptions=`color,portrait,noborder,width=16cm,height=12cm`);
> plot(cos(i*x), x = -5..5);
> plotsetup(inline);
> end do;

I did it on Linux, and used /tmp/ as the base location. Modify the location for Windows accordingly. (Try backslash, perhaps?) The .eps files that came out were OK.

acer

This worked for me, using Maple 11.02.

> for i from 1 to 5 do
> plotsetup(ps, plotoutput="/tmp/test"||i||".eps",
>   plotoptions=`color,portrait,noborder,width=16cm,height=12cm`);
> plot(cos(i*x), x = -5..5);
> plotsetup(inline);
> end do;

I did it on Linux, and used /tmp/ as the base location. Modify the location for Windows accordingly. (Try backslash, perhaps?) The .eps files that came out were OK.

acer

"Substituting x=a^3, factoring, and then inverting that substitution on x."

It is similar to doing this,

> subs(a=x^(1/3), factor( subs(x=a^3,x-1) ) );
                        (1/3)        (2/3)    (1/3)
                      (x      - 1) (x      + x      + 1)

> subs(x=a^3,x-1);
                                     3
                                    a  - 1

> factor(%);
                                       2
                             (a - 1) (a  + a + 1)

> subs(a=x^(1/3),%);
                        (1/3)        (2/3)    (1/3)
                      (x      - 1) (x      + x      + 1)

See also the help-page ?@ for help on the composition operator.

acer

Someone suggested to me the following syntax and result,

   RootOf(sin(_Z), condition={cos(_Z)<0}) ,

   RootOf(sin(_Z)*_Z^2+sin(_Z)-2*_Z, condition={cos(_Z)>=0})

It uses a slightly different "fake syntax" from Doug's above. I like it because it looks even simpler as an encapsulation of the whole solution.

Checking the graphs is one way to see that both this and Doug's suggestion cover all the correct roots. Or do the algebra.

p1 := plot(signum(cos(x))-signum(x*sin(x)-1),x=-20..20,thickness=5,color=red):
p2 := plot(signum(cos(x)),x=-20..20,color=green):
g := sin(x)*x^2+sin(x)-2*x:
f := cos(x)-x*sin(x)+1:
pf := plot(f,x=-20..20,color=blue):
pg := plot(g,x=-20..20,color=black):
plots[display]([pf,pg,p1,p2]);

How can Maple have gotten by for so long without such a construct? Is there already some better formulation available?

acer

Sure, I did see where the other wrong answers were coming from. However, I was looking at (only) the sentence "Here, it appears that the only real problem is avoiding the zeroes where sin(x)=0, i.e. all multiples of Pi." I didn't see context to suggest that those other roots weren't covered by this. Sorry, if that was a misunderstanding.

How about RootOf(cos(_Z)-_Z*sin(_Z)+1) as a result? Isn't that at least better than RootOf(sin(_Z)*_Z^2+sin(_Z)-2*_Z)) being returned?

acer

Hi Doug,

There is a root of sin(x)*x^2+sin(x)-2*x near -2.3311223704. It is not a root of cos(x)-x*sin(x)+1 and it is not a root of sin(x).

Have I misunderstood you?

acer

I don't see the same error in Maple 11. Using Maple 11.02 on Linux I see the worse answer, sin( RootOf(sin(_Z)*_Z^2+sin(_Z)-2*_Z)) .

Now, how can Maple sensibly and usefully represent only those values of  RootOf(sin(_Z)*_Z^2+sin(_Z)-2*_Z) which satisfy f, so that the answer is both complete and correct when _EnvAllSolutions=true? I don't see that any current RootOf notation in Maple is going to cover this. Am I missing something?

acer

In addition to adding increased confidence and assurance in the product for the Maple user, a large published test suite would allow talented experts to produce patches for the Maple language library.

Without a comprehensive test suite, any patches  (fixes, or enhancements) would be insufficiently tested.

Now, look at the help-page ?UndocumentedNames and scan down to the one named TestTools.

> eval(TestTools);
module()
export Try, Trynocrash, i, _pexports, TestOptions, Info, ResetInfo,
SetRecord, PlotStructure, StatisticsTests, HadFailure, PrintOnFail,
calcver;
description "a package for test tools"
     ...
end module

Now examine the output of eval(TestTools:-Try) . This is for testing purposes. Has anyone here (eg. package authors) tried using it for that? Should it be documented?

acer

First 520 521 522 523 524 525 526 Last Page 522 of 591