fix critical issue
This commit is contained in:
parent
450ed827ad
commit
8ab13c79c3
6
TODO.md
6
TODO.md
@ -9,12 +9,12 @@
|
||||
3. Smart display of graph
|
||||
- Display of intersections between functions
|
||||
- Add docs about roots and extrema
|
||||
- Caching of roots and extrema
|
||||
- add configs for toggling display of roots and extrema
|
||||
4. Fix integral line
|
||||
5. re-add euler's number (well it works if you use capital e like `E^x`)
|
||||
6. allow constants in min/max integral input (like pi or euler's number)
|
||||
7. sliding values for functions (like a user-interactable slider that adjusts a variable in the function, like desmos)
|
||||
8. Keybinds
|
||||
9. nth derivative support (again)
|
||||
10. add configs for toggling display of roots and extrema
|
||||
11. reduce jittering of roots and extrema points
|
||||
12. Update function tests
|
||||
10. Update function tests
|
||||
@ -44,6 +44,9 @@ pub struct FunctionEntry {
|
||||
sum: RiemannSum,
|
||||
}
|
||||
|
||||
// How many times should newton's method iterate?
|
||||
const NEWTON_LOOPS: usize = 50;
|
||||
|
||||
impl FunctionEntry {
|
||||
// Creates Empty Function instance
|
||||
pub fn empty() -> Self {
|
||||
@ -290,9 +293,10 @@ impl FunctionEntry {
|
||||
// Do 50 iterations of newton's method, should be more than accurate
|
||||
let x = {
|
||||
let mut x1: f64 = last_ele.unwrap().x;
|
||||
for _ in 0..50 {
|
||||
x1 = last_ele.unwrap().x
|
||||
- (self.function.get(x1) / self.function.derivative(x1))
|
||||
let mut x2: f64;
|
||||
for _ in 0..NEWTON_LOOPS {
|
||||
x2 = x1 - (self.function.get(x1) / self.function.derivative(x1));
|
||||
x1 = x2;
|
||||
}
|
||||
x1
|
||||
};
|
||||
@ -317,9 +321,11 @@ impl FunctionEntry {
|
||||
// Do 50 iterations of newton's method, should be more than accurate
|
||||
let x = {
|
||||
let mut x1: f64 = last_ele.unwrap().x;
|
||||
for _ in 0..50 {
|
||||
x1 = last_ele.unwrap().x
|
||||
- (self.function.derivative(x1) / self.function.get_derivative_2(x1))
|
||||
let mut x2: f64;
|
||||
for _ in 0..NEWTON_LOOPS {
|
||||
x2 = x1
|
||||
- (self.function.derivative(x1) / self.function.get_derivative_2(x1));
|
||||
x1 = x2;
|
||||
}
|
||||
x1
|
||||
};
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user