Message Boards Message Boards

0
|
847 Views
|
4 Replies
|
5 Total Likes
View groups...
Share
Share this post:

Plotting an out of phase wave result: plot is failing when passed zeroes

Posted 4 months ago

I'm expecting to get a horizontal line but I get some random squiggles instead, here is my Plot:

Plot[Sin[x] + Sin[x + Pi], {x, 0,2 Pi}]

I am trying to add together two waves that are perfectly out of phase. If I vary the phase a little it works fine, or if I just plot both waves they look fine. I must be missing something?

POSTED BY: Mark Wigzell
4 Replies
Posted 3 months ago

Thanks guys, but your suggestions usually resulted in a 'U' or 'V' shape with the bottom at the (0,0) point. I found the following to at least yield a flat line as I had been originally trying to get:

ListLinePlot[Table[Sin[x] + Sin[x+Pi],{x,0,2Pi}],PlotStyle ->{Red}]
POSTED BY: Updating Name
Posted 4 months ago

Chop can be used. It replaces numbers very close to zero by an exact 0

Plot[Sin[x] + Sin[x + Pi] // Chop, {x, 0, 2 Pi}]
POSTED BY: Hans Milton

The plot amplifies a very tiny numerical noise. Suppress amplification:

Plot[Sin[x] + Sin[x + Pi], {x, 0, 2 Pi}, PlotRange -> 1]
POSTED BY: Gianluca Gorni
Posted 4 months ago

Try

Plot[Sin[x] + Sin[x + Pi], {x, 0,2 Pi},WorkingPrecision->64]

or

FullSimplify[Sin[x] + Sin[x + Pi],0<=x<=2Pi]

or

TrigExpand[Sin[x]+Sin[x+Pi]]
POSTED BY: Bill Nelson
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract