Ask Your Question
2

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

asked 2021-09-11 22:32:08 +0100

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))

edit retag flag offensive close merge delete

2 Answers

Sort by » oldest newest most voted
2

answered 2021-09-12 08:18:04 +0100

FrédéricC gravatar image

You are seeing the numerical noise around 1.

Try

plot(f,-4,4,ymin=0,ymax=2)
edit flag offensive delete link more

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 ( 2021-09-12 09:24:37 +0100 )edit
0

answered 2021-09-13 13:48:24 +0100

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)

edit flag offensive delete link more

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: 2021-09-11 22:32:08 +0100

Seen: 253 times

Last updated: Sep 13 '21