Okay I was just mucking around on python. I have no programming experience at all, and I havent yet finished school anyhow, but I was interested in python and many say that it is great and everything... So I was trying to make a code that would solve this problem
This is not homework BTW
I KNOW that it is a very messy, ugly code, with wastefull lines and stuff, but I have no experience in any programming language whatso ever so im dumb :)

Here is the problem its just an extra question from maths homework that I thought I might try

Explore other triangles for which where sintT=cosaT where a is a positive integer.
so, this is whole code: Several things to note first!
I only need to find out what the angle is in degrees, which is x so I have everything as blah, but for myself i just though

``````from math import sin, cos, radians
global x
x = .1
def math():
global x

if x < 180:
if bla == blah:
print(x)
x = x+.1
math()
else:
x = x+.1
math()
else:
print("done")

math()``````

It gives me the location of an error alot of time then says:

``````line 17, in math
if x < 180:
RuntimeError: maximum recursion depth exceeded in comparison``````

I suppose this means that it wont allow 1800 repeats to find out the stuff.

any suggestions?

also any suggestions on specific thingies to clean up the code and make numbers like sqrt(3) be able to be detected, as thats one of the answers

thanks
Dragazarth

Just some quick observations:
1) replace recursion with a while loop
2) the way you calculate blah, it will always be that last calculated line
3) don't use math for a function name since it is a module name in Python
this will bite you sooner or later
4) global variables are generally a bad idea, particularly with simple names like x
5) you are trying to compare floating point numbers directly, they do have minute round off errors which makes this somewhat difficult

A possible solution ...

``````# find values of x (degrees) where sin(x) equals cos(a*x)

from math import sin, cos, radians

def find_match(x):
# create a list of possible cos values
blah_list = []
# a goes from 2 to 9
for a in range(2, 10):
print(blah_list)  # test
# endless loop that breaks at x > 180
while True:
if x > 180:
break
# check if bla is in the blah_list
if bla in blah_list:
print(x)
x = x + 0.1  # simpler x += 0.1
print("done")

x = 0.1
find_match(x)``````

vegaseat pretty much says it all...

I second about looking our discussion on comparing floating point numbers for equality.

I got different understanding of the task than vegaseat:

I understood that you need to find any x so that sin(x)==cos(a*x) for some a,x

Vegaseat wrote code for:
not to find sin(y) for y in [0.1,180], where y is in degrees so that there exist a for which cos(a*0.1)==sin(y)

What is really the exact task from book and even the model answer to check correctness of interpretation?

mmmmmm, well thanks for the help any how

here is the exact question:
Explore other triangles for which sinT = cosaT; where a is a positive integer. There are no brackets either
where there is the T there is meant to be the theta (a zero with a line in the middle)