Ask Your Question
2

Am I doing something wrong in plot or is this a bug?

asked 3 years ago

John Paul Morrison gravatar image

I put this into sagecell online and get a messed up plot. f(x) simplifies to 1.

f(x)=2/3(cos(x)^2 + cos(x-(2/3)pi)^2 + cos(x-(4/3)*pi)^2)

(plot( f , -4,4))

Preview: (hide)

2 Answers

Sort by » oldest newest most voted
2

answered 3 years ago

FrédéricC gravatar image

You are seeing the numerical noise around 1.

Try

plot(f,-4,4,ymin=0,ymax=2)
Preview: (hide)
link

Comments

1

Interestingly, I do not see numerical noise in (2/3*(cos(x)^2 + cos(x-(2/3)*pi)^2 + cos(x-(4/3)*pi)^2)).plot((-1, 1)), but I do see it in (2/3*(cos(x)^2 + cos(x-(2/3)*pi)^2 + cos(x-(4/3)*pi)^2)).plot((-4,4)).

Go figure...

Emmanuel Charpentier gravatar imageEmmanuel Charpentier ( 3 years ago )
0

answered 3 years ago

aszanti gravatar image

Look: u(x)=cos(x)^2

v(x)=cos(x-(2/3)*pi)^2

w(x)=cos(x-(4/3)*pi)^2 and plot

plot((v+w+u)*2/3,-4,4)

Preview: (hide)
link

Your Answer

Please start posting anonymously - your entry will be published after you log in or create a new account.

Add Answer

Question Tools

1 follower

Stats

Asked: 3 years ago

Seen: 282 times

Last updated: Sep 13 '21