The Babylonian algorithm (also known as the Heron's method) is an iterative method for approximating the square root of a number. To find the square root of 2 using this algorithm, we start with an initial guess and iteratively refine it until we reach an acceptable level of accuracy. Here are the steps:
Choose an initial guess for the square root of 2, such as 1.
Compute the average of the guess and 2/guess, i.e., (guess + 2/guess)/2.
Use the result from step 2 as the new guess.
Repeat steps 2 and 3 until the guess is close enough to the true square root of 2.
To determine when the guess is close enough to the true square root of 2, we can choose a tolerance level and stop iterating when the difference between the guess and the true square root of 2 is less than that tolerance level. For example, if we choose a tolerance level of 0.0001, we can stop iterating when |guess^2 - 2| < 0.0001.
Here is an example of how the algorithm works:
Guess = 1
New guess = (1 + 2/1)/2 = 1.5
New guess = (1.5 + 2/1.5)/2 = 1.41666666667
New guess = (1.41666666667 + 2/1.41666666667)/2 = 1.41421568627
New guess = (1.41421568627 + 2/1.41421568627)/2 = 1.41421356238
At this point, the difference between the guess and the true square root of 2 is less than 0.0001, so we can stop iterating and conclude that the square root of 2 is approximately 1.41421356238.
Личный опыт питания 16/8 с июня этого года до текущего момента. Вес упал до 78, текущий 73, больше ничего не делал, в спорт зал не ходил. Подтягиваюсь пару раз в неделю 14 раз, было 10. Поставил будильник на завтрак 10:00 и 17-30 ужин. Обедал когда захочется в этом интервале. Исключил сладкое (быстрые углеводы) после пары дней мучений, перестаешь дико хотеть есть. Похоже что организм перестраивается на другой тип питания. Если было не вмоготу пил теплую воду или хлебцы рисовые ел. Визуально жир ушел с щек, с боков на талии, на икрах ног и ляжках. Снова стал влазить в старые джинсы. Отмечу что стал равномерным поход в туалет, улучшилось состояние с кожи и в целом ощущение что стал здоровее
Типичный телевизор для гуманитария, жаль что пока его не приобрел инженер :)
// chatGPT code :)
function calculateMathExpression(expr, ...args) {
const sanitizedExpr = expr.replace(/[^0-9+-*/().]/g, '');
const fnBody =
return ${sanitizedExpr};;const fn = new Function(fnBody);
return fn(...args);
}
ChatGPT тоже знает такой алгоримт:
The Babylonian algorithm (also known as the Heron's method) is an iterative method for approximating the square root of a number. To find the square root of 2 using this algorithm, we start with an initial guess and iteratively refine it until we reach an acceptable level of accuracy. Here are the steps:
Choose an initial guess for the square root of 2, such as 1.
Compute the average of the guess and 2/guess, i.e., (guess + 2/guess)/2.
Use the result from step 2 as the new guess.
Repeat steps 2 and 3 until the guess is close enough to the true square root of 2.
To determine when the guess is close enough to the true square root of 2, we can choose a tolerance level and stop iterating when the difference between the guess and the true square root of 2 is less than that tolerance level. For example, if we choose a tolerance level of 0.0001, we can stop iterating when |guess^2 - 2| < 0.0001.
Here is an example of how the algorithm works:
Guess = 1
New guess = (1 + 2/1)/2 = 1.5
New guess = (1.5 + 2/1.5)/2 = 1.41666666667
New guess = (1.41666666667 + 2/1.41666666667)/2 = 1.41421568627
New guess = (1.41421568627 + 2/1.41421568627)/2 = 1.41421356238
At this point, the difference between the guess and the true square root of 2 is less than 0.0001, so we can stop iterating and conclude that the square root of 2 is approximately 1.41421356238.
Личный опыт питания 16/8 с июня этого года до текущего момента.
Вес упал до 78, текущий 73, больше ничего не делал, в спорт зал не ходил. Подтягиваюсь пару раз в неделю 14 раз, было 10. Поставил будильник на завтрак 10:00 и 17-30 ужин. Обедал когда захочется в этом интервале. Исключил сладкое (быстрые углеводы) после пары дней мучений, перестаешь дико хотеть есть. Похоже что организм перестраивается на другой тип питания. Если было не вмоготу пил теплую воду или хлебцы рисовые ел. Визуально жир ушел с щек, с боков на талии, на икрах ног и ляжках. Снова стал влазить в старые джинсы. Отмечу что стал равномерным поход в туалет, улучшилось состояние с кожи и в целом ощущение что стал здоровее
yurichev.com/writings/SAT_SMT_draft-RU.pdf
исходники github.com/DennisYurichev/SAT_SMT_article