-
Notifications
You must be signed in to change notification settings - Fork 0
/
script.js
29 lines (24 loc) · 888 Bytes
/
script.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
function Derviative(f , x , h=1e-5){
return (f(x + h) - f(x)) / h
}
function count_variables(func_str){
let variables = new Set();
for (part in func_str.replace(' ' , '').replace('(' , '').replace(')' , '').split('+')){
for(subpart in part.split('-')){
for (term in subpart.split('*')){
for (factor in term.split('/')){
if (factor.toString().length > 0 && !factor.isInteger()){
variables.add(factor)
}
}
}
}
}
return variables.length
}
function Derivate_example_function(x){
return 3*(Math.sin(x ** 2 )) / Math.cos(x)
}
let x_point = parseInt(prompt("import x : ")) ;
deriv_at_x = Derviative(Derivate_example_function , x_point)
console.log(`The derivative of the function at x=${x_point} is approximately ${deriv_at_x}`)