Date: Feb 13, 2013 4:11 AM
Author: Christopher Creutzig
Subject: Re: how to solve tan(x)=3x/(3+x^2)

On 13.02.13 00:54, Jingxin wrote:
> So I tried to use Solve function to solve this equation, tried root, findroot. By using FindRoot, I was able to get one solution which is closest to x0, but, what if I want all the answers from 0,10 or the first 10 term?

Just a disclaimer up front: Numerically (and without interval numerics),
you can never know how many zeroes a transcendental (i.e.,
non-polynomial) equation has, so there is no way to guarantee finding
all of them.

Your input is sufficiently tame that finding (approximations) to all
zeroes in some range is a reasonable expectation, though. I don't think
there is a nice calling syntax in the symbolic toolbox yet, but you can
call MuPAD commands directly using feval, so you can for example use
numeric::realroots, which returns ranges such that any zero of your
function is in one of those:

>> eq = tan(x)==3*x/(3+x^2)

eq =

tan(x) == (3*x)/(x^2 + 3)

>> s = feval(symengine, 'numeric::realroots', ...
eq, 'x=0..10', 1e-4)

s =

[ [0.0, 0.0485992431640625], [3.726348876953125, 3.7264251708984375],
[6.681365966796875, 6.6814422607421875], [9.7154998779296875,
9.715576171875]]

>> vpasolve(eq, x, s(1))

ans =

0

>> vpasolve(eq, x, s(2))

ans =

3.7263846964537519995745420194228

>> vpasolve(eq, x, s(3))

ans =

6.6814348529499497169811754681414

>> vpasolve(eq, x, s(4))

ans =

9.7155660951117226365449206516755


HTH,
Christopher