This site is supported by donations to The OEIS Foundation.

Template:Sinc

From OeisWiki
Jump to: navigation, search

The {{sinc}} mathematical function template returns either the normalized sinc function (default) or the unnormalized sinc function of a real number .

Usage

To get the normalized sinc function use

{{sinc|a real number}}

or

{{sinc|a real number|n}}.

To get the unnormalized sinc function use

{{sinc|a real number|u}}.

Valid input

A real number as first argument, n (normalized, default value) or u (unnormalized) as second argument.

Examples

Examples with valid input

Code Result Comment
{{sinc|-5/2|N}} 0.12732395447352
{{sinc|-2|n}} -3.8981718325194E-17 (should be 0)
{{sinc|-1}} 3.8981718325194E-17 (should be 0)
{{sinc|-1/2}} 0.63661977236758
{{sinc|-1/3}} 0.82699334313269
{{sinc|-1/4}} 0.90031631615711
{{sinc|-1/6}} 0.95492965855137
{{sinc|0}} 1
{{sinc|1/6}} 0.95492965855137
{{sinc|1/4}} 0.90031631615711
{{sinc|1/3}} 0.82699334313269
{{sinc|1/2}} 0.63661977236758
{{sinc|1}} 3.8981718325194E-17 (should be 0)
{{sinc|2}} -3.8981718325194E-17 (should be 0)
{{sinc|5/2}} 0.12732395447352

Code Result Comment
{{sinc|-5*pi/2|U}} 0.12732395447352
{{sinc|-2*pi|u}} -3.8981718325194E-17 (should be 0)
{{sinc|-pi|u}} 3.8981718325194E-17 (should be 0)
{{sinc|-pi/2|u}} 0.63661977236758
{{sinc|-pi/3|u}} 0.82699334313269
{{sinc|-pi/4|u}} 0.90031631615711
{{sinc|-pi/6|u}} 0.95492965855137
{{sinc|0|u}} 1
{{sinc|pi/6|u}} 0.95492965855137
{{sinc|pi/4|u}} 0.90031631615711
{{sinc|pi/3|u}} 0.82699334313269
{{sinc|pi/2|u}} 0.63661977236758
{{sinc|pi|u}} 3.8981718325194E-17 (should be 0)
{{sinc|2*pi|u}} -3.8981718325194E-17 (should be 0)
{{sinc|5*pi/2|u}} 0.12732395447352

Examples with invalid input (returns an error message)

Code Result
{{sinc|i}} Sinc error: First argument must be a real number
{{sinc|0|pi}} Sinc error: Second argument must be either n (normalized) or u (unnormalized)

Code


{{#switch: {{lc: {{{2|n}}} }}  
| n = <!-- normalized --> 
  {{ifnum| {{{1|NAN}}}
  | {{#ifexpr: ({{{1}}}) = 0
    | 1
    | {{#expr: (sin (pi * ({{{1}}}) )) / (pi * ({{{1}}}) ) }}
    }}
  | {{error| Sinc error: First argument must be a real number }}
  }}
| u = <!-- unnormalized -->
  {{ifnum| {{{1|NAN}}}
  | {{#ifexpr: ({{{1}}}) = 0
    | 1
    | {{#expr: (sin ({{{1}}}) ) / ({{{1}}}) }}
    }}
  | {{error| Sinc error: First argument must be a real number }}
  }} 
| {{error| Sinc error: Second argument must be either n (normalized) or u (unnormalized) }}
}}