Post Reply 
[CAS problem] High-precision operations in numerical solution equations
04-01-2020, 06:14 PM (This post was last modified: 04-01-2020 06:16 PM by Albert Chan.)
Post: #2
RE: [CAS problem] High-precision operations in numerical solution equations
(04-01-2020 01:03 PM)yangyongkang Wrote:  Hi everyone, I recently came across an x = tan (x) equation about x. Find x> 0, the solution over the
interval [k * pi, (k + 1/2) * pi] (k is a positive integer). It is found that when k is taken large, the error occurs.
Code:
subst(tan(x)-x,x=fsolve(tan(x)=x,x=100000.5*pi))
Calculation output:142106699.971
Very large error。

Solver might converge to a root outside your required interval.
It is better to solve for x, then calculate tan(x)-x

XCas> guess := 10000.5*pi
XCas> fsolve(tan(x)=x, x=guess)     → 7.72525183694
XCas> fsolve(tan(x)=x, x=guess)     → 4.49340945791

XCas> guess := 100000.5*pi                 → 314160.836155
XCas> x := fsolve(tan(x)=x,x=guess)     → 314160.836155 (not shown, but slightly less than guess)

XCas> tan(guess) - guess          → 27378944702.1              
XCas> tan(x) - x                       → 4735723246.82
XCas> x := 314160.836152       // Error for x is tiny, only -0.000003
XCas> tan(x) - x                       → -11691.0416004

For large guess (=pi/2 + k*pi), solved x is only slightly smaller.
We can estimate tan(x) = cot(guess-x) ≈ 1/(guess-x), and x ≈ guess

XCas> x := guess - 1/guess   // "solved" tan(x)=x, we have x = 314160.836152123
Find all posts by this user
Quote this message in a reply
Post Reply 


Messages In This Thread
RE: [CAS problem] High-precision operations in numerical solution equations - Albert Chan - 04-01-2020 06:14 PM



User(s) browsing this thread: 1 Guest(s)