Minor modifications, adding usage to derivative.

This commit is contained in:
Adsooi 2023-10-09 23:28:29 +02:00
parent 4b692894f2
commit 3f1d089a78
Signed by: Ad5001
GPG key ID: EF45F9C6AFE20160
4 changed files with 5 additions and 21 deletions

View file

@ -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 : ""

View file

@ -27,7 +27,7 @@ var ADDITIONAL_VARCHARS = [
"ₜ","¹","²","³","⁴","⁵","⁶",
"⁷","⁸","⁹","⁰","₁","₂","₃",
"₄","₅","₆","₇","₈","₉","₀",
"∞"
"∞","π"
]
function Instruction(type, value) {

View file

@ -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
}

View file

@ -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": "",
}