Skip to content

Commit 574626a

Browse files
committed
Added more examples
1 parent d362618 commit 574626a

File tree

1 file changed

+53
-2
lines changed

1 file changed

+53
-2
lines changed

src/main.rs

Lines changed: 53 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,10 @@ enum DropdownOptions {
3737
Second,
3838
Third,
3939
Fourth,
40+
Fith,
41+
Sixth,
42+
Seventh,
43+
Eigth,
4044
}
4145

4246
impl DropdownOptions {
@@ -73,6 +77,53 @@ impl DropdownOptions {
7377
solution: |x, (x0, y0)| 2.0 * (2.0 * x - 2.0 * x0 + (y0 / 2.0).atan()).tan(),
7478
name: "y² + 4",
7579
},
80+
DropdownOptions::Fith => FunctionDetails {
81+
function: vec![
82+
|x, y| 2.0 * x.exp() + 2.0 * y[0], // f
83+
|x, y| 2.0 * x.exp() + 2.0 * y[1], // f'
84+
],
85+
solution: |x, (x0, y0)| {
86+
x.exp() * ((x - 2.0 * x0).exp() * y0 + 2.0 * (x - x0).exp() - 2.0)
87+
},
88+
name: "2exp(x) + 2y",
89+
},
90+
DropdownOptions::Sixth => FunctionDetails {
91+
function: vec![|x, y| x.exp() + 6.0 * y[0], |x, y| x.exp() + 6.0 * y[1]],
92+
solution: |x, (x0, y0)| {
93+
1.0 / 5.0
94+
* x.exp()
95+
* (5.0 * (5.0 * x - 6.0 * x0).exp() * y0 + (5.0 * x - 5.0 * x0).exp() - 1.0)
96+
},
97+
name: "exp(x) + 6y",
98+
},
99+
DropdownOptions::Seventh => FunctionDetails {
100+
function: vec![
101+
|x, y| x.powi(3) - x + 6.0 * x * y[0], // f
102+
|x, y| 3.0 * x.powi(2) - 1.0 + 6.0 * (1.0 * y[0] + x * y[1]), // f'
103+
],
104+
solution: |x, (x0, y0)| {
105+
1.0 / 18.0
106+
* ((3.0 * x.powi(2) - 3.0 * x0.powi(2)).exp()
107+
* (3.0 * x.powi(2) + 18.0 * y0 - 2.0)
108+
- 3.0 * x.powi(2)
109+
+ 2.0)
110+
},
111+
name: "x³ - x +6xy",
112+
},
113+
DropdownOptions::Eigth => FunctionDetails {
114+
function: vec![
115+
|x, y| 4.0 * x.sin() - 2.0 * y[0] / x, // f
116+
|x, y| 2.0 * (x * (2.0 * x * x.cos() - y[1]) + y[0]) / x.powi(2), // |x, y| 3.0 * x.powi(2) - 1.0 + 6.0 * (1.0 * y[0] + x * y[1]), // f'
117+
],
118+
solution: |x, (x0, y0)| {
119+
(x0.powi(2) * y0 - 4.0 * (-2.0 + x.powi(2)) * x.cos()
120+
+ 4.0 * (-2.0 + x0.powi(2)) * x0.cos()
121+
+ 8.0 * x * x.sin()
122+
- 8.0 * x0 * x0.sin())
123+
/ x.powi(2)
124+
},
125+
name: "4sin(x) - 2y/x",
126+
},
76127
}
77128
}
78129
fn get_description(self: &Self) -> &'static str {
@@ -109,7 +160,7 @@ impl Default for TaylorApp {
109160
points_exact: Default::default(),
110161
target_epsilon: 0.1,
111162
current_epsilon: f64::INFINITY,
112-
n_divisions: 10,
163+
n_divisions: 3,
113164
calculations_duration: Duration::new(0, 0),
114165
last_args: (0.0, 0.0, DropdownOptions::default(), 0.0),
115166
}
@@ -216,7 +267,7 @@ impl eframe::App for TaylorApp {
216267
ui.add(
217268
DragValue::new(&mut self.target_epsilon)
218269
.speed(0.01)
219-
.clamp_range(0.01..=10.0)
270+
.clamp_range(0.001..=10.0)
220271
.prefix("ε:"),
221272
);
222273
});

0 commit comments

Comments
 (0)