Using tangent function in template, unexpected results

I need to use the tangent value of the solar elevation, but in the template testing section of developer tools I get unexpected results. Here is the code:

name: "Solar Shades Light Control Percent"
unique_id: solar_shades_light_control_percent
state: >
  {% set tangent = tan(states('sensor.sun_solar_elevation'))  %}
  
  {{ states('sensor.sun_solar_elevation') }}
  {{ tangent }}

Just now, the solar elevation sensor reports 32.72 and tangent of about 3.66. but the correct tangent of 32.72 is about .64. What is wrong here?

It expects the value you are supplying to be in radians…

{% set tangent = tan(states('sensor.sun_solar_elevation') | float * pi/180)  %}
  
  {{ states('sensor.sun_solar_elevation') }}
  {{ tangent }}

Thank you so much for your prompt help. I did not realize that this function (unlike my simple calculator) required the input to be in radians.

Nerds love radians… :grin: