microsoft / qsharp-runtime

Runtime components for Q#
https://docs.microsoft.com/quantum
MIT License
286 stars 93 forks source link

Consider reimplementing @__quantum__qis__tan__body #532

Open kuzminrobin opened 3 years ago

kuzminrobin commented 3 years ago

Currently tan(x) is implemented as sin(x) / cos(x):

define double @__quantum__qis__tan__body(double %theta) {
    %sin = call double @llvm.sin.f64(double %theta)
    %cos = call double @llvm.cos.f64(double %theta)
    %result = fdiv double %sin, %cos                            ; tg(x) = sin(x) / cos(x)
    ret double %result
}

The std::tan(x) can potentially handle the corner cases better. Consider reimplementing. More details are here.

bettinaheim commented 3 years ago

@kuzminrobin Sounds like a good thing to do. I'll assign it to you to update that as part of implementing the QIR runtime functions.