This site is supported by donations to The OEIS Foundation.

Template:Golden ratio

From OeisWiki
(Redirected from Template:Phi)
Jump to: navigation, search

The {{Golden ratio}} (or {{phi}}) mathematical constant function template returns the positive root or negative root of , the positive root (+) being the Golden ratio, which is returned if no argument is given. An error message is returned if an argument other than + or - is given.

The Golden ratio is used in Binet's closed-form formulae for the Fibonacci numbers and Lucas numbers.

Usage

{{Golden ratio|+ or -}} or {{phi|+ or -}}

to get the positive root (+) or negative root (-) of , or

{{Golden ratio}} or {{phi}}

to get the Golden ratio (positive root (+) of as default).

Valid input

+ (default) or - as argument.

Examples

Examples with valid input

Code Result
{{phi}} 1.6180339887499
{{Golden ratio}} 1.6180339887499
{{phi|+}} 1.6180339887499
{{Golden ratio|+}} 1.6180339887499
{{phi|-}} −0.61803398874989
{{Golden ratio|-}} −0.61803398874989

Examples with invalid input

Code Result
{{Golden ratio|*}} Golden ratio error: Argument must be + or -
{{Golden ratio|phi}} Golden ratio error: Argument must be + or -

Code


{{#switch: {{{1|+}}}
 | + = {{expr| (1+5^(1/2))/2 }}
 | - = {{expr| (1-5^(1/2))/2 }}
 | {{error| Golden ratio error: Argument must be + or - }}
}}

See also