Skip to content

How to expand nested function? #2670

Answered by josdejong
MAGNETO903 asked this question in Q&A
Discussion options

You must be logged in to vote

That is an interesting one. There is no functionality built in for this, but I think you could build it quite easily.

After parsing an expression like f1(x), you could transform the parsed expression and replace all occurrences of f1 with it's implementation 2*x using the method .transform(...). When replacing, you should make sure the function variables should be correctly renamed too when needed, such that f1(y) will be replaced with 2*y.

See docs: https://mathjs.org/docs/expressions/expression_trees.html

Replies: 1 comment

Comment options

You must be logged in to vote
0 replies
Answer selected by josdejong
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
None yet
2 participants
Converted from issue

This discussion was converted from issue #2069 on August 17, 2022 12:36.