0% found this document useful (0 votes)
9 views3 pages

FT Py

Uploaded by

abhf645
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
9 views3 pages

FT Py

Uploaded by

abhf645
Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 3

import math as mt

import turtle as tt

tt.screensize(800, 800)

def fx(x):
funcfx = 0 + mt.cos(x) + mt.cos(3 * x) - mt.cos(2 * x) + 2 * mt.cos(x / 2)
return funcfx

c = 0
cs = 0

def ttset(x):
x.speed(0)
x.shape("circle")
x.turtlesize(0.1)
x.color("white")
x.pencolor("black")
x.screen.bgcolor("white")

xy = tt.Turtle()
x_axis = tt.Turtle()
y_axis = tt.Turtle()
grap = tt.Turtle()
grap2 = tt.Turtle()

ttset(xy)
ttset(x_axis)
ttset(y_axis)
ttset(grap)
ttset(grap2)

grap.pencolor("red")
grap2.pencolor("blue")

x_axis.pu()
y_axis.pu()

x_axis.goto((400, -400))
y_axis.goto((-400, 400))

x_axis.pd()
y_axis.pd()

x_axis.goto((-400, -400))
y_axis.goto((-400, -400))
x_axis.left(90)

for i in range(-8, 9):


x_axis.goto((50 * i, 0))
y_axis.goto((-400, 50 * i))
x_axis.forward(2)
x_axis.back(4)
x_axis.forward(2)
y_axis.forward(2)
y_axis.back(4)
y_axis.forward(2)

def resettinggrap():
xy.pu()
grap.pu()
grap2.pu()
xy.goto((-400, -400))
grap.goto((-400, 0))
grap2.goto((-400, 0))
xy.pd()
grap.pd()
grap2.pd()
xy.clear()
grap.clear()
grap2.clear()

resettinggrap()

def rexsfx(x: list, y: list, n):


a = 0
for i in range(len(x)):
if abs(y[i]) >= 1 / 4:
a += (y[i]) * mt.cos(x[i] * n)
return a

rex = []
rey = []
rerex = []
rerey = []

def silhaeng(o, p, l: int):


global c, cs, rex, rey
for x in range(0, 800):
sum = 0
for n in range(-1000, 1000):
if l == 0:
an = (fx(n) - rexsfx(o, p, n)) * mt.cos((n / 100) * x) / 20
if l == 1:
an = (
(fx(n) - rexsfx(rex, rey, n) - rexsfx(o, p, n))
* mt.cos((n / 100) * x)
/ 20
)
sum += an
if abs(sum) >= 1 / 4:
if abs(sum) < abs(cs):
o.append(c)
p.append(round(cs / 50, 1))
c = 0
cs = 0
c = x / 100
cs = sum
grap.goto((-400 + (x), 5 * fx(x / 50)))
if l == 0:
grap2.goto((-400 + (x), 5 * (fx(x / 50))))
if l == 1:
grap2.goto(
(
-400 + (x),
5 * (fx(x / 50) - rexsfx(rex, rey, x / 50)),
)
)
xy.goto((-400 + (x), (sum)))

silhaeng(rex, rey, 0)
resettinggrap()
silhaeng(rerex, rerey, 1)

for i in range(len(rex)):
if round(abs(rey[i]), 1) >= 1 / 3:
print(rex[i], (rey[i]), "\n")
print("\n")

for i in range(len(rerex)):
if round(abs(rerey[i]), 1) >= 1 / 3:
print(rerex[i], (rerey[i]), "\n")

tt.done()

You might also like