Is there a way to do this? [probably a bug]

JacquesC's picture

From an exercise in "Game Physics", we have the following piecewise position vector r. We wish to show that it is well-defined (as well as twice differentiable) at 0. The goal of the exercise is then to show that the Normal vector is not even continuous. So we try:
p1,p2 := <t,t^3,0>, <t,0,t^3>;
r := piecewise( t<0, p1, p2);
limit(r,t=0,left);

and unfortunately that limit gives
RTABLE(149559852,MATRIX([[t], [t^3], [0]]),Vector[column])
as a result!

The obvious thing to try next is to "push in" the piecewise into the components. But the above seems to show a bug, no?

gulliet's picture

The "less than" character of death strike back again!

Jacques,

Your post (especially the piecewise function) has been victim of the "less than" character when it occurs in some HTML code posted on MaplePrimes. Replace any occurrence of "less than" by the HTML safe proof code "<" (without the quotation marks).

Best regards,
--
Jean-Marc

JacquesC's picture

Thanks

I have fixed it.

John Fredsted's picture

Not differentiable?

Most probably this is not answering your question, but I wonder about the formulation of the exercise itself: To me the piecewise position vector r is twice differentiable:

seq(LinearAlgebra:-Equal(
	map(limit,map(diff,p1,t$i),t=0,left),
	map(limit,map(diff,p2,t$i),t=0,right)
),i=1..3);

But maybe by "differentiable" is meant infinitely differentiable!?

JacquesC's picture

Fixed

Sorry, I was typing that too quickly -- I have fixed the post. r is indeed twice differentiable. The point was to show that the Normal was not even continuous. Serves me right for trying to do too many things at once.

piecewise

I don't think Maple understands the piecewise construction in this context.

p1,p2 := <t,t^3,0>, <t,0,t^3>:
> r :=t-> piecewise( t<0, p1, p2);

r := t -> piecewise(t < 0, p1, p2)

> limit(r(t), t=1), r(1), r(-1);

If you look at the output Maple literally uses the vector object as the value of the piecewise function. I tried to paste the output without success. I would love to know how you got that vector output to post.

JacquesC's picture

Vector output

First, I don't think it is piecewise that is the problem, it is a Vector embedded in a 'weird' context that (I believe) is the problem.

To get that vector output, I cut&pasted the lprint-ed version of Maple's output, viz
RTABLE(149559852,MATRIX([[t], [t^3], [0]]),Vector[column])
into <maple> brackets. And it worked...

vector output

I didn't mean to imply that piecewise was a problem. I was only pointing out that the construction

p1,p2 := <t,t^3,0>, <t,0,t^3>:

r :=t-> piecewise( t<0, p1, p2);

does not produce a vector valued function in the usual sense. It produces a function that maps the entire set of nonnegative reals onto the object <t, t^3, 0>, and the entire set of negative reals onto the object <t, 0, t^3>.

r(1) evaluates to <t, t^3, 0> rather than <1, 1, 0>.

It was not clear to me from your post whether or not this was the point you were making. I assumed you were wondering why it did not give <0,0,0> as the limit. Sorry for the confusion.

BTW

BTW this is what I get with cut and paste and tags

Vector(3, {(1) = t, (2) = 0, (3) = t^3})

with lprint

Vector[column](3, {(1) = t, (3) = t^3}, datatype = anything, storage = rectangular, order = Fortran_order, shape = [])

JacquesC's picture

Classic?

I was using classic when I did that. Perhaps that makes a difference?

JacquesC's picture

Of course!

Thank you - that was the real problem, and I did not notice it. So it's not a bug, it is a scoping issue (which I knew about, but did not spot). I really ought to have used unapply instead of an inline function.

I know all this stuff, and still I got caught. Either I am going gaga, or these evaluation rules are sub-optimal.

serendipity

If you are thanking me there is no need. Any useful information I provided was purely accidental, a direct result of my lack of understanding (see comments below). So if any thanks are in order they are from me to you, Robert, DJ, and John, since I understand things a little better now.

Also, I have a mac so I have never seen classic. I know that the experienced users seem to prefer it. I wish there were a mac version.

Thanks again,

Thomas

bug in limit

Here is a simpler example.

p:= piecewise(t<0, <0,t>, <t,0>):
limit(p, t=0, 'left');

The result is <0,t>.

[I cannot get Vectors to display properly either; JacquesC, tell us the incantation!]

Confused

Ok, now I really don't know what is going on. Look at this

restart:
p1,p2 := <t,t^3,0>, <t,0,t^3>:
r := t->piecewise(t<0, p1, p2):

r(1);

the output from r(1) is <t, 0, t^3>

versus

restart:
r:= t-> piecewise( t<0, <t,0,0>, <0,t,0>):

r(1);

the output from r(1) is <0,1,0>

Why did Maple pass the argument to the component functions in the second case and not in the first? I guess my assessment above was premature. I am still thinking piecewise was not intended for vectors, but I don't know. I will leave it to the experts.

Robert Israel's picture

globals and formal parameters

This has nothing to do with piecewise or vectors. The t in p1 and p2 is the global t, which has nothing to do with the formal parameter t in the definition of r. It's just like:

> p := t;
  r := t -> p;
  r(1);

t

Thanks

Now I see it. Just more evidence that I should read more and post less. Sorry for the mess. Thanks!

Comment viewing options

Select your preferred way to display the comments and click "Save settings" to activate your changes.
}