1
I have a very simple but functional code. It obeys two mathematical functions, testing different values of x and returning the coordinates of the point if the result of the two functions is the same (y):
def funcs():
for x in range(-100, 100):
funcA = (x**2) + x - 2
funcB = 6 - x
if funcA == funcB:
print("###intersecção enctontrada###")
print(f'({x},{funcA})')
else:
pass
funcs()
output:
###intersecção enctontrada###
(-4,10)
###intersecção enctontrada###
(2,4)
But I have a big problem, it only works when the intersection meets when the value of x is a number whole, when the intersection occurs when the value is broken, it shows nothing.
Python supports up to 16 decimal places, and making a range of all decimal places is completely unfeasible. So I thought maybe it would be possible to make Python stop calculating the decimals after a certain number of decimals, because I believe that if I just round the value it won’t stop Python from counting the other.
And I need a practical solution to solve this problem and return all intersections regardless of whether they are whole or not.
Somebody help me, please, thank you.
Man, you’re amazing, you saved my day
– André Chrisostomo