Skip to content

Conversation

@Safari77
Copy link
Contributor

$ time ./target/debug/fend "tan(atan(1e320))"
approx. 100000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000000

real 0m0,004s
user 0m0,002s
sys 0m0,004s

@Safari77
Copy link
Contributor Author

Safari77 commented Jan 1, 2026

iter_root_n precision fix to use INTERNAL_PRECISION.
Each iteration adds 1 bit of precision.
Since log2(10) ≈ 3.32, we need ~3.32 iterations per decimal digit. Use 3.35 as safety factor.

	fn iter_root_n<I: Interrupt>(
		mut low_bound: Self,
		val: &Self,
		n: &Self,
		int: &I,
	) -> FResult<Self> {
		let mut high_bound = low_bound.clone().add(1.into(), int)?;
		let iterations = ((Self::INTERNAL_PRECISION as f64) * 3.35) as usize;
		for _ in 0..iterations {
			let guess = low_bound
				.clone()
				.add(high_bound.clone(), int)?
				.div(&2.into(), int)?;
			if &guess.clone().pow(n.clone(), int)?.value < val {
				low_bound = guess;
			} else {
				high_bound = guess;
			}
		}
		low_bound.add(high_bound, int)?.div(&2.into(), int)
	}

(it would be preferred if 'dp' parameter was available here)

@Safari77 Safari77 marked this pull request as draft January 1, 2026 08:54
@Safari77 Safari77 force-pushed the hi_pi branch 3 times, most recently from 629d828 to 92b3d22 Compare January 1, 2026 10:25
@codecov
Copy link

codecov bot commented Jan 1, 2026

Codecov Report

❌ Patch coverage is 96.67969% with 17 lines in your changes missing coverage. Please review.
✅ Project coverage is 82.15%. Comparing base (9636b16) to head (a619f73).
⚠️ Report is 6 commits behind head on main.

Files with missing lines Patch % Lines
core/src/num/bigrat.rs 96.60% 17 Missing ⚠️
Additional details and impacted files
@@            Coverage Diff             @@
##             main     #374      +/-   ##
==========================================
+ Coverage   81.47%   82.15%   +0.68%     
==========================================
  Files          52       52              
  Lines       14717    15484     +767     
==========================================
+ Hits        11990    12721     +731     
- Misses       2727     2763      +36     

☔ View full report in Codecov by Sentry.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

Also add tests for atan
Fix tests for sqrt_minus_two_i sqrt_minus_two log_10000 log10_10000
@Safari77 Safari77 changed the title High precision atan, sin, cos High precision atan, sin, cos, and other related functions Jan 1, 2026
@Safari77
Copy link
Contributor Author

Safari77 commented Jan 1, 2026

added num-traits = "0.2.19" because clippy was being pedantic.
Changed that iter_root_n to use configurable precision.

@Safari77 Safari77 marked this pull request as ready for review January 1, 2026 14:04
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant