Programming Challenge
by - Thursday, January 1, 1970 at 12:00 AM
Write C++ or Python program to Find the root which between 0.5 and 1 for this function f(x) = tan(x*x)-x . You can import tan from the math library
No one has been able to solve it for 48 hours so I will post the answer
from math import floor

from math import log
from math import tan

def func(t):
    return tan(t*t) -t                             
def average(x,y):
    return (x+y)/2

x = float(input("the left interval num  (0.5) :"))
y = float(input("the right interval num (1) :"))
precision = float(input("Donner la precision (0.00000000001 for ex): "))
for k in range(floor(log(y-x)-log(precision)/log(2))):
    if(func(x)*func(average(x,y))>0):
            x = average(x,y)
    if(func(x)*func(average(x,y))<0):
            y = average(x,y) 
    else:
        result = average(x,y) 
print(f"Alors resultat est = {result} ") 
Reply
(September 9, 2022, 05:19 PM)japanvps0 Wrote: Write C++ or Python program to Find the root which between 0.5 and 1 for this function f(x) = tan(x*x)-x . You can import tan from the math library
Anyone who want to submit the answer or want to know the answer contact me at https://t.me/japanvps0 NOTE it will be a reward for the first person who submit the right answer
 Thanks 


hello not a programmer, nor mathematician but around 0.83?
Reply
I'm fairly certain I have the answer, but I'm not going to contact you on Telegram - feel free to private message me.
Reply
whats the point of that question? :D
Reply
hold my beer
Reply
(September 9, 2022, 05:19 PM)japanvps0 Wrote: Write C++ or Python program to Find the root which between 0.5 and 1 for this function f(x) = tan(x*x)-x . You can import tan from the math library
No one has been able to solve it for 48 hours so I will post the answer
from math import floor

from math import log
from math import tan

def func(t):
    return tan(t*t) -t                             
def average(x,y):
    return (x+y)/2

x = float(input("the left interval num  (0.5) :"))
y = float(input("the right interval num (1) :"))
precision = float(input("Donner la precision (0.00000000001 for ex): "))
for k in range(floor(log(y-x)-log(precision)/log(2))):
    if(func(x)*func(average(x,y))>0):
            x = average(x,y)
    if(func(x)*func(average(x,y))<0):
            y = average(x,y) 
    else:
        result = average(x,y) 
print(f"Alors resultat est = {result} ") 

Yep too retarded
Reply


 Users viewing this thread: Programming Challenge: No users currently viewing.