<commit_before># Algoritmo ITERAÇÃO LINEAR

def iteracaolinear x0, &g
  x = g.call(x0)
  k = 0
  while ((x - x0).abs > @tol or (g.call(x) - x).abs > @tol) and k <= @nmi do
    x0 = x
    x = g.call(x0)
    k += 1
  end
  if k > @nmi
    then puts "Ultrapassou NMI"
    else puts "RAIZ = #{x}"
  end
end

@tol = 1.0E-3
@nmi = 100
iteracaolinear(0.6){|x| Math::exp(x) / 3}
<commit_msg>Melhorando o código.<commit_after>require "base"
# Algoritmo ITERAÇÃO LINEAR

def iteracaolinear x0, &g
  x1 = g.call(x0)
  @nmi.times do
    x2 = g.call(x1)
    return x1 if (x2 - x1).abs < @tol and (x1 - x0).abs < @tol
    x0, x1 = x1, x2
  end
  return :nmi
end

@tol = 1e-3
@nmi = 100

f = lambda{|x| Math::exp(x) / 3}

aplicar :iteracaolinear, 0.6, &f

{'fraction_non_alphanumeric': 0.1635135135135135, 'fraction_numerical': 0.051351351351351354, 'mean_word_length': 2.5970873786407767, 'pattern_counts': {'":': 0, '<': 6, '<?xml version=': 0, '>': 6, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1183184', 'n_tokens_mistral': 385, 'n_tokens_neox': 365, 'n_words': 98}