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
{{subst:#if:1|{{subst:#if:1|{{subst:#if:1|{{subst:#if:1|{{subst:#if:1|{{subst:#if:1|{{subst:square root|5|1}}}}}}}}}}}}}}
gives {{subst:square root|5|2.2360679775}}<br>2.2360679775<br>2.2360679775<br>2.23606889564<br>2.2380952381<br>2.33333333333<br>3<br>1
in one save.
{{subst:x10|{{subst:substif1}}}}{{subst:square root|5|1}}{{subst:x10|{{subst:rightbraces}}}} gives {{subst:square root|5|2.2360679775}}<br>2.2360679775<br>2.2360679775<br>2.2360679775<br>2.2360679775<br>2.2360679775<br>2.2360679775<br>2.2360679775<br>2.23606889564<br>2.2380952381<br>2.33333333333<br>3<br>1 in two saves.
[edit] Square root templates
- template:square root ( talk edit history links ) - one step at each save
- template:square root A ( talk edit history links ) - with absolute error stop criterion, one or two saves produce all approximations and the differences between consecutive ones
- template:square root B ( talk edit history links ) - with absolute error stop criterion, one or two saves produce the final approximation and the differences between consecutive ones
- template:sqr ( talk edit history links ) - 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 ( talk edit history links ) - 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 ( talk edit history links ) - ditto, forward
- template:square root with defaults ( talk edit history links )
- template:square root with defaults A ( talk edit history links )
See also: