Having tan(x), how do I get tan(x/2)? in C


handmade wii

I know I can do this:

//With A = tax(x);
return tan(arctan(A)/2);

But I want a more efficient way.

Sergey Kalinichenko

When xbetween -π/2 and π/2, the following formula can be used:

t / (1 + sqrt(1 + t*t))

This is hardly an improvement over the original formula, but it uses one function call instead of two.

Note: I found this formula here . The Wikipedia page is in Russian and the equivalent English page does not contain the same formula.

Related


Having tan(x), how do I get tan(x/2)? in C

handmade wii I know I can do this: //With A = tax(x); return tan(arctan(A)/2); But I want a more efficient way. Sergey Kalinichenko When xbetween -π/2 and π/2, the following formula can be used: t / (1 + sqrt(1 + t*t)) This is hardly an improvement over the

How do I get this C code to work?

Caesar 381 My knowledge is limited so bear with me, but I'm trying to create functions and this is what I've got so far and it's not. Thanks for all suggestions! Try creating a function that collects user input #include<stdio.h> int GetIntFromUser(int grades[

How do I get C:/ on the command line

username I am on Windows 10. I'm trying to load Adobe Dreamweaver extension via command line on Windows. I want to navigate to C:\Program Files\Adobe\Adobe Extension Manager CSx\ I am following the instructions here . If I select command prompt (admin), I getC

How do I get C:/ on the command line

username I am on Windows 10. I'm trying to load Adobe Dreamweaver extension via command line on Windows. I want to navigate to C:\Program Files\Adobe\Adobe Extension Manager CSx\ I am following the instructions here . If I select command prompt (admin), I getC

I'm having trouble installing gazebo, how do I fix it?

designer I'm having trouble installing Bower, I've installed it and even used "yo + grunt + bower" to work on some projects. However, today when I created a new project, I had a problem implementing Bower and I ran the command to install again giving the error

I'm having trouble installing gazebo, how do I fix it?

designer I'm having trouble installing Bower, I've installed it and even used "yo + grunt + bower" to work on some projects. However, today when I created a new project, I had a problem implementing Bower and I ran the command to install again giving the error

How do I get GTK includes to work with C++?

Gillis I'm trying to start learning to develop GTK+ applications on Ubuntu 17.04 64bit using C++ and the Eclipse CDT IDE, and I'm having trouble trying to include the GTK library. I'm wondering why the include doesn't work. I've installed gtk 2.0 (DEV) and rec

Nancy (C#): How do I get my post data?

Westerlund I am using Corona SDK to post data to my C# server: headers["Content-Type"] = "application/x-www-form-urlencoded" headers["Accept-Language"] = "en-US" local body = "color=red&size=small" local params = {} params.headers = headers params.body = bod

How do I get the procedure for opening the file in C#

Tim Moss I'm trying to open different files with their associated application like this: ProcessPath = @"C:\Users\Public\Pictures\Sample Pictures\Tulips.jpg"; ProcessStartInfo processStartInfo = new ProcessStartInfo();

How do I get GTK includes to work with C++?

Gillis I'm trying to start learning to develop GTK+ applications on Ubuntu 17.04 64bit using C++ and the Eclipse CDT IDE, and I'm having trouble trying to include the GTK library. I'm wondering why the include doesn't work. I've installed gtk 2.0 (DEV) and rec

How do I get GTK includes to work with C++?

Gillis I'm trying to start learning to develop GTK+ applications on Ubuntu 17.04 64bit using C++ and the Eclipse CDT IDE, and I'm having trouble trying to include the GTK library. I'm wondering why the include doesn't work. I've installed gtk 2.0 (DEV) and rec

How do I get c# to write quotes?

Callum Glenn Brankin I want c# to write a piece of HPKP code into a textbox. A piece of Apache HKPK code looks like this: Header always set Public-Key-Pins "pin-sha256=\"base64+primary==\"; pin-sha256=\"base64+backup==\"; max-age=5184000; includeSubDomains" W

In Objective C, how do I get the class name of self at runtime?

Robert L In Objective C, "self" is an instance of some class. How can I find out which class it is an instance of? IOW I want an NSString that contains the class name. I know about isKindOfClass, but this only tests if it's a specific class whose name I have t

Nancy (C#): How do I get my post data?

Westerlund I am using Corona SDK to post data to my C# server: headers["Content-Type"] = "application/x-www-form-urlencoded" headers["Accept-Language"] = "en-US" local body = "color=red&size=small" local params = {} params.headers = headers params.body = bod