Template talk:Square root

From Meta, a Wikimedia project coordination wiki

This template reproduces a substitution call with an approximation of the square root of a number, producing one with a new approximation, and logging the result. Successively pressing edit/save gives convergence to plus or minus the square root, according to the sign of the starting value. The latter should not be zero.

{{subst:square root|5|-1}} gives successively (from bottom to top):
-2.2360679775
-2.2360679775
-2.2360679775
-2.23606889564
-2.2380952381
-2.33333333333
-3
-1


{{subst:square root|1024|1}} gives after multiple steps: {{subst:square root|1024|32}}
32
32
32
32.0000071648
32.021420905
33.1924874169
42.009585631
69.2273240544
130.61480157
257.24902439
512.5
1

{{subst:square root|3|1}} gives after multiple edit/save: {{subst:square root|3|1.73205080757}}
1.73205080757
1.73205080757
1.73205081001
1.73214285714
1.75
2
1

{{subst:square root|5|0}} gives after multiple edit/save:
Expression error: Unrecognised word "expression"
Expression error: Unrecognised word "expression"
Expression error: Unrecognised word "expression"
Expression error: Unrecognised word "division"
Division by zero
0

Square root templates[edit]

  • Template:Square root - one step at each save
  • Template:Square root A - with absolute error stop criterion, one or two saves produce all approximations and the differences between consecutive ones
  • Template:Square root B - with absolute error stop criterion, one or two saves produce the final approximation and the differences between consecutive ones
  • Template:Sqr - one or two saves produce the final approximation, with fixed stop criterion of relative error <1e-11 (based on use of a server with 12-digit results); gives a single value, a call can be put in an expression
  • Template:Sqri - one or two saves produce all intermediate results and the final approximation at the top (so backward), with fixed stop criterion of relative error <1e-11 (based on use of a server with 12-digit results)
  • Template:Sqrif - ditto, forward
  • Template:Square root with defaults
  • Template:Square root with defaults A

See also: