# Recursive Temperature Converter

## Recursive Temperature Converter

This temperature converter is a proof of concept for the notion of recursive forms (RFs).
Convert Temperatures

### Background

This tool, in the modality of a temperature converter, is a proof of concept for the notion of recursive forms (RFs). The most popular temperature scales are used (Hillger & Toth, 2016; Mathisfun, 2021; NIST, 2016).

RFs automatically submit themselves when a user completes the following steps (see Theory section).

1. Select an initial option or accept the default one.
2. Input a value compatible with said option.
3. Select a new option.

### Examples

The following examples illustrate how this RF works.

A user wants to express the average body temperature, 37 Celsius degrees, in different temperature scales. He selects the "Celsius" option, enters "37", and switches to the "Fahrenheit" option so the RF returns "98.6".

Now switching to the "Rankine" option, said output becomes the new input and the RF returns "558.27".

Again, switching to the "Romer" option, the previous output becomes the new input and the RF returns "26.93".

Therefore,
37 °C = 98.6 °F
98.6 °F = 558.27 °Ra
558.27 °Ra = 26.93 °Ro
26.93 °Ro = 37 °C

### Discussion

We define a recursive form (RF) as an HTML form where the name/value pairs of successful controls are recursively generated through the decision-making process of users.

### Algorithm

The algorithm implemented by this RF represents all possible missing terms of Planck's Equation as a two-dimensional associative array of the form

\$index = [
[
"missing_term_1" =>"new_option_1",
"solution_1_1" => "value_1_1",
"solution_1_2" => "value_1_2",
⋮
],
[
"missing_term_2" =>"new_option_2",
"solution_2_1" => "value_2_1",
"solution_2_2" => "value_2_2",
⋮
],
⋮
[
⋮
...
]
];


This is faster than using nested switch statements, particularly as the size or dimensionality of the array increases.

The index is searched in two steps. First, the subarray that matches the missing term (i.e., the new option) is located. Subarray solutions are then located. If there is a match (i.e., in function of the initial option and input value), the solution is retrieved and displayed in the input field as the new value.

Users can repeat this process as many times as they wish to by simply switching to a new option.

### Exercises

• The freezing and boiling point of water are 0°C and 100°C, respectively. Convert these to values in the Kelvin, Fahrenheit, and Rankine scales.
• The temperature of a cool day, very cold day, and extremely cold day are about 10°C, -18°C, and -40°C in many US states (Mathisfun, 2021). Convert these to the Kelvin, Fahrenheit, Delisle, Reaumur, and Romer scales.
• 16°C is about 61°F. This is an example of between-scale digits transposition. Find two more examples of digit transpositions between these scales.