typst-intro/sincos.jl
2026-01-04 01:36:13 +01:00

14 lines
No EOL
300 B
Julia

"""
s, c = sincos(x)
Izračunaj vrednost funkcij `sin` in `cos` za dano vrednost `x`.
"""
function sincos(x)
if (abs(x)< 0.05)
x2 = x^2
return x*(1 + x2*(-1/6 + x2/120)), 1 + x2*(-0.5 + x2/24)
end
x = mod(x, 2pi)
s, c = sincos(x/2)
return 2*s*c, c^2 - s^2
end