# Using Play command and polynomial tia sal2

Discussion in 'Mathematica' started by ratulloch, Mar 1, 2009.

1. ### ratullochGuest

Greetings All

I know the play command uses sin, cos, etc. But I would like to use
the Play command to listen to a polynomial. Example below of
polynomial

Plot[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6
, 1 = x < 3}}], {x, 0, 3}]

I replace the Plot command with Play
Play[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6
, 1 = x < 3}}], {x, 0, 3}]

but mathematica 6 just comes back with errors and
just says running..

I think it's syntax but I haven't found an example of using the Play
command and Piecewise. Should I be doing this another way?

tia sal2

ratulloch, Mar 1, 2009

2. ### David BaileyGuest

You had used = instead of == in one of the tests inside Piecewise.
Curiously, this did not cause an error using Plot. Here is a corrected
version:

Play[Piecewise[{{4*x^2 - 4*x, 0 <= x <= 1}, {-2*x^2 + 8*x - 6,
1 == x < 3}}], {x, 0, 3}]

Note that = means assignment, and therefore 1=x doesn't make sense -
which is what the message was trying to tell you - whereas == is a
comparison.

However, I am not sure I would pay to attend a concert in which the
result was playing

I think the result would sound more interesting if instead of playing
f[x], you played Sin[2 Pi f[x] x] with f scaled into the range of (say)
200-1000. The pitch of the resultant sound would represent the value of f.

David Bailey
http://www.dbaileyconsultancy.co.uk

David Bailey, Mar 2, 2009

3. ### dhGuest

Hi,

your speaker cannot reproduce sound below some frequency. Your ear has a

threshold too. Therefore, you must define (for the PC speaker) something

that has at least say 100 "wiggles" a second.

hope this helps, Daniel

dh, Mar 3, 2009