Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

plots[semilogplot] with negative y values (Maple)

35 views
Skip to first unread message

Joseph A. Giaime

unread,
Jul 30, 1997, 3:00:00 AM7/30/97
to

I find that in Maple V, rel 4 (with and without latest patches),
making a semilog plot (i.e., log x-axis, linear y-axis) produces a
complaint that there are negative y values. Shouldn't this work?

> plots[semilogplot](-x, x=1..10);
Error, (in plots/dologplot) no positive y values

any ideas?

-Joe


Douglas B. Meade

unread,
Jul 31, 1997, 3:00:00 AM7/31/97
to

What do you EXPECT the plot to look like? The logarithm of negative
numbers is complex-valued.

If you want to plot these complex-valued functions, see the complexplot
and complexplot3d commands in the plots package (you'll probably have to
work hard to get a true logarithmic plot for complex-valued functions/data).

I'll close with an excerpt from a Maple session that shows some of the
different possibilities. I hope some of this is of some use, but first
you need to decide exactly what you are trying to plot.

Doug
----------------------------------------------------------------------------
Douglas B. Meade Phone: (803) 777-6183 FAX: (803) 777-6527
Department of Mathematics E-mail: me...@math.sc.edu
USC, Columbia, SC 29208 URL: http://www.math.sc.edu/~meade/
----------------------------------------------------------------------------

> plots[semilogplot]( log(x), x=1..10 );
> X := [ $1..10 ];

X := [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]

> Y1 := map( evalf@log, X );

Y1 := [0, .6931471806, 1.098612289, 1.386294361, 1.609437912,

1.791759469, 1.945910149, 2.079441542, 2.197224577, 2.302585093]

> Y2 := map( evalf@log, -X );

Y2 := [3.141592654 I, .6931471806 + 3.141592654 I,
1.098612289 + 3.141592654 I, 1.386294361 + 3.141592654 I,
1.609437912 + 3.141592654 I, 1.791759469 + 3.141592654 I,
1.945910149 + 3.141592654 I, 2.079441542 + 3.141592654 I,
2.197224577 + 3.141592654 I, 2.302585093 + 3.141592654 I]

> plots[complexplot]( Y2, style=POINT );
> Y3 := zip( (x,y)->[x,Re(y)], X, Y2 );

Y3 := [[1, 0], [2, .6931471806], [3, 1.098612289], [4, 1.386294361],
[5, 1.609437912], [6, 1.791759469], [7, 1.945910149],
[8, 2.079441542], [9, 2.197224577], [10, 2.302585093]]

> plots[semilogplot]( Y3, style=POINT );
>
--
----------------------------------------------------------------------------
Douglas B. Meade Phone: (803) 777-6183 FAX: (803) 777-6527
Department of Mathematics E-mail: me...@math.sc.edu
USC, Columbia, SC 29208 URL: http://www.math.sc.edu/~meade/

Joseph A. Giaime

unread,
Aug 1, 1997, 3:00:00 AM8/1/97
to

semilogplot should not evaluate the log of the function value, only of
its argument. I EXPECT the program to plot negative values in y over
a log x-axis. This is a bug in maple, I believe.

Since posting the question, I have found that the following works:

plots[semilogplot](-x, x=1..10, -10..0);

For some reason, maple cannot (at least in my platform, version: OS/2,
Maple V, rel4, with current patches.) find the y range itself if the
range is negative.

-Joe

Joseph Riel

unread,
Aug 1, 1997, 3:00:00 AM8/1/97
to

Joseph A. Giaime (gia...@jila02.colorado.edu) wrote:
: I find that in Maple V, rel 4 (with and without latest patches),

: making a semilog plot (i.e., log x-axis, linear y-axis) produces a
: complaint that there are negative y values. Shouldn't this work?

: > plots[semilogplot](-x, x=1..10);
: Error, (in plots/dologplot) no positive y values

The problem appears to be the line

y1 := select(x -> evalb(0 < x), y1);

This isn't needed for a semilogplot, a possible fix is

if ylog then
y1 := select(x -> evalb(0 < x), y1) fi;

A similar fix needs to be applied for logplot (which also uses dologplot),
that is, to allow negative values for the x-coordinates.

Joe Riel
--
j...@sparc.sandiegoca.ncr.com

Joseph Riel

unread,
Aug 1, 1997, 3:00:00 AM8/1/97
to

Douglas B. Meade (me...@math.scarolina.edu) wrote:

: gia...@jila02.colorado.edu (Joseph A. Giaime) writes:

: >I find that in Maple V, rel 4 (with and without latest patches),
: >making a semilog plot (i.e., log x-axis, linear y-axis) produces a
: >complaint that there are negative y values. Shouldn't this work?

: >> plots[semilogplot](-x, x=1..10);
: >Error, (in plots/dologplot) no positive y values

: What do you EXPECT the plot to look like? The logarithm of negative
: numbers is complex-valued.

But semilogplot uses a log scale on the HORIZONTAL axis, not the VERTICAL axis.
It should not give an error with Joseph's example.


Joe Riel
--
j...@sparc.sandiegoca.ncr.com

Andrew Blaikie

unread,
Aug 7, 1997, 3:00:00 AM8/7/97
to

> : gia...@jila02.colorado.edu (Joseph A. Giaime) writes:
>
> : >I find that in Maple V, rel 4 (with and without latest patches),
> : >making a semilog plot (i.e., log x-axis, linear y-axis) produces a
> : >complaint that there are negative y values. Shouldn't this work?
>
> : >> plots[semilogplot](-x, x=1..10);
> : >Error, (in plots/dologplot) no positive y values

You can avoid this bug by specifying a range for the dependent variable:

plots[semilogplot](-x,x=1..10,-10..0);

Cassidy Gentle
cge...@maplesoft.com


0 new messages