# Maple: Only getting partial plot. Something wrong with function I guess!

• May 12th 2009, 04:09 AM
steenreem
Maple: Only getting partial plot. Something wrong with function I guess!
Hello =)
I have the following code:
> fracy := proc (d, r) if r < d then 1 else 1-arccos(sqrt(r^2-d^2))/pi end if end proc;

> plot('fracy(x, 1)', x = 0 .. 2);

But this plots only x=1..2, not x=0..1
It only does part of the plot!
I needed to use to ' ' else it would complain that it cannot evaluate the if.

Thanks,
Remy.
• May 12th 2009, 10:36 AM
Chris L T521
Quote:

Originally Posted by steenreem
Hello =)
I have the following code:
> fracy := proc (d, r) if r < d then 1 else 1-arccos(sqrt(r^2-d^2))/pi end if end proc;

> plot('fracy(x, 1)', x = 0 .. 2);

But this plots only x=1..2, not x=0..1
It only does part of the plot!
I needed to use to ' ' else it would complain that it cannot evaluate the if.

Thanks,
Remy.

It worked for me. See Attachment.
• May 12th 2009, 12:25 PM
Jester
Quote:

Originally Posted by steenreem
Hello =)
I have the following code:
> fracy := proc (d, r) if r < d then 1 else 1-arccos(sqrt(r^2-d^2))/pi end if end proc;

> plot('fracy(x, 1)', x = 0 .. 2);

But this plots only x=1..2, not x=0..1
It only does part of the plot!
I needed to use to ' ' else it would complain that it cannot evaluate the if.

Thanks,
Remy.

Two things
(1) Are you using pi or Pi. It makes a difference.
(2) You can use the piecewise function command

fracy:=(d,r)->piecewise(r<d,1,1-arccos(sqrt(r^2-d^2))/Pi);
plot(fracy(x, 1), x = 0 .. 2);

which gives Chris's picture.