# Calculate Wind Chill

The Australian Apparent Temperature (aka, wind chill) in °C AT is given by this algorithm from the Australian Bureau of Meterology (wp, source):

AT = Ta + (0.33 * e) - (.7 * ws) - 4.0

Where:

Ta = Dry bulb temperature (°C)

e = Water vapour pressure (hPa)

ws = Wind speed (m/s) (at an elevation of 10 meters)

The water vapour pressure in hectoPascals e is given by this algorithm:

e = (rh / 100) * 6.105 * exp( ( 17.27 * Ta ) / ( 237.7 + Ta ) )

Where:

Ta = Dry bulb temperature (°C)

rh = Relative humidity [%]

exp represents the exponential function

The domain of:

• Ta is -273.15°C to 2e7°C.

• e is the real numbers

• ws is 0 m/s to 2e7 m/s

• rh is 0% to 100%

For inputs outside these domains, your code can do anything, including give the right answer.

## Output

Given a dry bulb temperature in °C, a wind speed in metres / second, and a relative humidity in %, your code should give the Apparent Temperature in °C, accurate to 0.1°C.

Assuming your platform or language can represent reals, for correct functions correct_func,

or in C, fabsl( correct_func(Ta, rH, ws) - expected ) < 0.1.

### Test cases

1 value for Ta, rh, ws -> output

0 -> -4
2 -> -3.35346
4 -> -2.69275
6 -> -2.01507
8 -> -1.31719
10 -> -0.595428
12 -> 0.154404
14 -> 0.937065
16 -> 1.75793
18 -> 2.62308
20 -> 3.5393
22 -> 4.51423
24 -> 5.55638
26 -> 6.67525
28 -> 7.88137
30 -> 9.18643

49, 99, 67 -> 36.268

Repl.it for any test case: https://repl.it/H9xL/0

You can use a builtin function for the exponential function, ex, if you like.

This is , so the shortest code wins!

• Is there a single input to the program or are the test cases just weird? – Jonathan Allan May 1 '17 at 17:21
• @JonathanAllan The algorithm takes three inputs, but I was lazy in creating the test cases, using one value for three args. – cat May 1 '17 at 17:24
• This challenge doesn't really have much room for golfing. – mbomb007 May 1 '17 at 19:10
• @xnor The inputs have bounds. "For inputs outside these domains, your code can do anything, including give the right answer." – mbomb007 May 1 '17 at 19:22
• This isn't a problem with the people. There's little room for creativity when the algorithm is straight-up the simplest way to solve it. – mbomb007 May 1 '17 at 19:28

# Python 3, 76 bytes

t=lambda T,r,V:.0201465*r*2.718281828459045**(1727*T/(100*T+23770))+T-.7*V-4

Try it online!

• Welcome to PPCG! – Martin Ender May 1 '17 at 19:05

# Python, 7872 66 bytes

Pretty much a direct implementation of the algorithm provided in the challenge description.

lambda T,r,w:T+.0201465*r*2.7182818284**(17.27*T/(237.7+T))-.7*w-4

Try it online

This was specifically tested with the maximum value of T to find how many digits of Euler's constant were required for the error to be within the allowed amount.

# TI-BASIC, 41 bytes

:Prompt T,R,W
:T-.7W-4+.02014565Re^(17.27T/(237.7+T

Surprisingly, a calculator is really good at crunching numbers.

# Javascript, 56 bytes

(a,r,w)=>a+.0201465*r*Math.exp(17.27*a/(237.7+a))-.7*w-4

var f = (a,r,w)=>a+.0201465*r*Math.exp(17.27*a/(237.7+a))-.7*w-4
var expected = [-4, -3.35346, -2.69275, -2.01507, -1.31719, -0.595428, 0.154404, 0.937065, 1.75793, 2.62308, 3.5393, 4.51423, 5.55638, 6.67525, 7.88137, 9.18643]; for (var i = 0; i < 16; i++) {var g = f(2*i,2*i,2*i); var diff = expected[i] - g; document.getElementById('w').innerHTML += '\n' + ((diff > 0.1 || diff < -0.1) ? 'KO' : 'OK') + '   ' + (expected[i] - g) + '   ' + g + '   ' + expected[i];}
<pre id="w">Passed  |  Diff  |  Actual result  |  Expected</pre>

# Octave, 54 49 bytes

@(T,r,V).0201465*r*e^(17.27*T/(237.7+T))+T-.7*V-4

Try it online!

• (17.27*T/(237.7+T) is shorter. – mbomb007 May 1 '17 at 19:23

# Japt, 40 38 bytes

U+.0#É465*V*MEp17.27*U/(#í.7 +U)-.7*W-4

Try it online!

This is my first Japt answer, so please don't judge it too harshly ;-)

• Hey, thanks for using Japt :-) You can save a couple bytes by replacing 201 and 237 with and , respectively. (It's an odd trick, but it works...) – ETHproductions May 2 '17 at 14:28
• @ETHproductions: that's odd indeed. Thanks though! – Luke May 2 '17 at 15:24

## Perl 6, 52 (possibly non-competing)

{$^a+.0201465*$^c*exp(17.27*$a/(237.7+$a))-4-.7*\$^b}

This can't be evaluated by itself. You either have to pass in arguments, or store the block into a variable.

• What do you mean, “This can't be evaluated by itself”? As I see, it can be called as any anonymous function. (Maybe you should specify that it expects parameters in Ta, ws, rh order.) – manatwork May 2 '17 at 8:59
• If you type it by itself in the REPL, you'll get an error. You either have to pass in the arguments, or assign the block to a variable. – bb94 May 2 '17 at 18:41
• Sure you have to pass it arguments, but no need to assign to variable. pastebin.com/7W3cJSrX This is the same as calling anonymous functions in other languages. – manatwork May 2 '17 at 18:50
• What I meant was that if you typed the expression alone without either, you got an error. – bb94 May 2 '17 at 18:58