





import math as m


def        __SCREAMING_SNAKE_CASE	(				__lowercase:		Optional[Any]  ,				__lowercase:		Tuple  ,				__lowercase:		str=0.001):



  '''simple docstring'''






  return (f(a + h) - f(a - h)) / (2 * h)


def        __SCREAMING_SNAKE_CASE	(				__lowercase:		List[str]  ,				__lowercase:		int=0  ,				__lowercase:		Optional[Any]=1_00  ,				__lowercase:		int=0.0001  ,				__lowercase:		List[Any]=1E-6  ,				__lowercase:		Optional[int]=False):



  '''simple docstring'''






  __lowerCAmelCase								=					xa  # set the initial guess
  __lowerCAmelCase								=					[a]
  __lowerCAmelCase								=					abs(f(__lowercase))
  __lowerCAmelCase								=					lambda __lowercase: calc_derivative(__lowercase  ,				__lowercase  ,				h=__lowercase)  # noqa: E731  Derivative of f(x)
  for _ in range(__lowercase):
    if fa(__lowercase) == 0:
      raise ValueError('''No converging solution found''')
    __lowerCAmelCase								=					a - f(__lowercase) / fa(__lowercase)  # Calculate the next estimate
    if logsteps:
      steps.append(__lowercase)
    if error < maxerror:
      break
  else:
    raise ValueError('''Iteration limit reached, no converging solution found''')
  if logsteps:
    # If logstep is true, then log intermediate steps
    return a, error, steps
  return a, error


if __name__ == "__main__":
      from matplotlib import pyplot as plt

      __lowercase				    =      lambda x: m.tanh(x) ** 2 - m.exp(3 * x)  # noqa: E731
      __lowercase    ,							__lowercase    ,							__lowercase				    =      newton_raphson(
          f, xa=10, maxiter=1_000, step=1E-6, logsteps=True
      )
      plt.plot([abs(f(x)) for x in steps])
      plt.xlabel("""step""")
      plt.ylabel("""error""")
      plt.show()
      print(f"""solution = {{{solution:f}}}, error = {{{error:f}}}""")







def        __SCREAMING_SNAKE_CASE	(				__lowercase:		int = 10_00):



  '''simple docstring'''






  __lowerCAmelCase								=					0
  for i in range(__lowercase):
    if i % 3 == 0 or i % 5 == 0:
      result += i
  return result


if __name__ == "__main__":
      print(f"""{solution() = }""")
