/* Calculate arctan using the identity : x arctan (x) == arcsin [ --------------- ] sqrt(1 + x^2) */ void m_apm_arctan(M_APM rr, int places, M_APM xx) { M_APM tmp8, tmp9; if (xx->m_apm_sign == 0) /* input == 0 ?? */ { M_set_to_zero(rr); return; } if (xx->m_apm_exponent <= -4) /* input close to 0 ?? */ { M_arctan_near_0(rr, places, xx); return; } if (xx->m_apm_exponent >= 4) /* large input */ { M_arctan_large_input(rr, places, xx); return; } tmp8 = M_get_stack_var(); tmp9 = M_get_stack_var(); m_apm_multiply(tmp9, xx, xx); m_apm_add(tmp8, tmp9, MM_One); m_apm_sqrt(tmp9, (places + 6), tmp8); m_apm_divide(tmp8, (places + 6), xx, tmp9); m_apm_arcsin(rr, places, tmp8); M_restore_stack(2); }
/* Calculate arcsin using the identity : x arcsin (x) == arctan [ --------------- ] sqrt(1 - x^2) */ void M_arcsin_near_0(M_APM rr, int places, M_APM aa) { M_APM tmp5, tmp6; tmp5 = M_get_stack_var(); tmp6 = M_get_stack_var(); M_cos_to_sin(tmp5, (places + 8), aa); m_apm_divide(tmp6, (places + 8), aa, tmp5); M_arctan_near_0(rr, places, tmp6); M_restore_stack(2); }