Jump to content

Template talk:Sqr

Add topic
From Meta, a Wikimedia project coordination wiki
  • {{subst:#if:1|{{subst:sqr|5}}}} gives 2.2360679775 in one edit.

Maximum value of argument:

  • {{subst:#if:1|{{subst:sqr|1999999999997}}}} gives 1414213.56237.
  • {{subst:#if:1|{{subst:sqr|1999999999998}}}} gives "Expression error: Unrecognised word "e"".

Minimum value of argument:

  • {{subst:#if:1|{{subst:sqr|.00000001000000000000001}}}} gives 0.000100000000001.
  • {{subst:#if:1|{{subst:sqr|.000000010000000000000001}}}} gives "Expression error: Unrecognised word "e"".

Golden ratio: {{subst:#expr:({{subst:#if:1|{{subst:sqr|5}}}}+1)/2}} gives 1.61803398875.

The template content on substitution is of the form

{{subst:#ifexpr:boolean_for_"not_finished"|{{subst:sqr|argument_of_square_root|new_approximation}}|old_approximation}}</nowiki>

{{subst:sqr|5}} gives the wikitext

{{subst:#ifexpr:1|{{subst:sqr|5|1}}|{{{2}}}}}

{{subst:sqr|5|2}} gives:

{{subst:#ifexpr:1|{{subst:sqr|5|2.25}}|2}}

{{subst:sqr|5|2.2360679775}} gives:

{{subst:#ifexpr:0|{{subst:sqr|5|2.2360679775}}|2.2360679775}}

Thus the edit history records the number for which the square root is computed and the starting value, if any, with the next approximation (otherwise it gives {{{2}}} as starting value and 1 as the next approximation); in all cases the next edit/save gives 2.2360679775.

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: