Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9202781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 17, 20262026-06-17T23:19:55+00:00 2026-06-17T23:19:55+00:00

Is there a function for solving transcendental equations in R? For example, I want

  • 0

Is there a function for solving transcendental equations in R?

For example, I want to solve the following equation

x = 1/tan(x)

Any suggestions? I know the solution has multiple roots so I also want to be able to recover all the answers for a given interval

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-17T23:19:56+00:00Added an answer on June 17, 2026 at 11:19 pm

    You can use uniroot to find roots of any 1D equations within a given range. However, getting multiple roots seems like a very hard problem in general (e.g. see the relevant chapter of Numerical Recipes for some background: chapter 9 at http://apps.nrbook.com/c/index.html ). Which root is found when there are multiple roots is hard to predict. If you know enough about the problem to subdivide the space into subregions with zero or one roots, or if you’re willing to divide it into lots of regions and hope that you found all the roots, you can do it. Otherwise I look forward to other peoples’ solutions …

    In this particular case, as shown by @liuminzhao’s solution, there’s (at most? exactly?) one solution between n*pi and (n+1)*pi

    y = function(x) x-1/tan(x)
    curve(y,xlim=c(-10,10),n=501,ylim=c(-5,5))
    abline(v=(-3:3)*pi,col="gray")
    abline(h=0,col=2)
    

    enter image description here

    This is a bit of a hack, but it will find roots of your equation (provided they are not too close to a multiple of pi: you can reduce eps if you like …). However, if you want to solve a different multi-root transcendental equation you might need another (specialized) strategy …

    f <- function(n,eps=1e-6) uniroot(y,c(n*pi+eps,(n+1)*pi-eps))$root
    sapply(0:3,f)
    ## [1] 0.8603337 3.4256204 6.4372755 9.5293334
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

There is function in which a new window is opened and shown. I want
Is there any function that does the inverse operation of array_diff() ? I mean,
Is there a function or any other way to calculate in C the logarithm
is there any function in C++ that calculates a fingerprint or hash of a
Is there any function available in PHP to check whether an array is empty
I want to solve an equation for a different value in each cycle of
Is there any way for R to solve for the inverse of a given
I was solving some simple pointer exercises when i came across the following example:
Is there any way to stop an R program without error? For example I
Is there a function that can truncate or round a Double? At one point

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.