Minor modifications, adding usage to derivative.
This commit is contained in:
parent
4b692894f2
commit
3f1d089a78
4 changed files with 5 additions and 21 deletions
|
@ -433,7 +433,7 @@ Item {
|
|||
itemSelected: parent.itemSelected
|
||||
categoryItems: Parsing.CONSTANTS_LIST
|
||||
autocompleteGenerator: (item) => {return {
|
||||
'text': item, 'annotation': '',
|
||||
'text': item, 'annotation': Parsing.CONSTANTS[item],
|
||||
'autocomplete': item + " ", 'cursorFinalOffset': 0
|
||||
}}
|
||||
baseText: parent.visible ? parent.currentToken.value : ""
|
||||
|
|
|
@ -27,7 +27,7 @@ var ADDITIONAL_VARCHARS = [
|
|||
"ₜ","¹","²","³","⁴","⁵","⁶",
|
||||
"⁷","⁸","⁹","⁰","₁","₂","₃",
|
||||
"₄","₅","₆","₇","₈","₉","₀",
|
||||
"∞"
|
||||
"∞","π"
|
||||
]
|
||||
|
||||
function Instruction(type, value) {
|
||||
|
|
|
@ -55,6 +55,8 @@ parser.functions.integral = function(a, b, f, variable) {
|
|||
}
|
||||
|
||||
parser.functions.derivative = function(f, variable, x) {
|
||||
if(f == null || variable == null || x == null)
|
||||
throw EvalError("Usage: derivative(<function: string>, <variable: string>, <x: number>)")
|
||||
f = parser.parse(f).toJSFunction(variable, currentVars)
|
||||
return (f(x+DERIVATION_PRECISION/2)-f(x-DERIVATION_PRECISION/2))/DERIVATION_PRECISION
|
||||
}
|
||||
|
|
|
@ -95,23 +95,5 @@ const FUNCTIONS = {
|
|||
'derivative': () => 0,
|
||||
}
|
||||
const FUNCTIONS_LIST = Object.keys(FUNCTIONS);
|
||||
// TODO: Complete
|
||||
const DERIVATIVES = {
|
||||
"abs": "abs(<1>)/<1>",
|
||||
"acos": "-derivate(<1>)/sqrt(1-(<1>)^2)",
|
||||
"acosh": "derivate(<1>)/sqrt((<1>)^2-1)",
|
||||
"asin": "derivate(<1>)/sqrt(1-(<1>)^2)",
|
||||
"asinh": "derivate(<1>)/sqrt((<1>)^2+1)",
|
||||
"atan": "derivate(<1>)/(1+(<1>)^2)",
|
||||
"atan2": "",
|
||||
}
|
||||
const INTEGRALS = {
|
||||
"abs": "integrate(<1>)*sign(<1>)",
|
||||
"acos": "",
|
||||
"acosh": "",
|
||||
"asin": "",
|
||||
"asinh": "",
|
||||
"atan": "",
|
||||
"atan2": "",
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue