How to expand nested function? #2670
-
I have 2 simple functions, for example: And one complex function: Can I using mathjs expand function
or
Can I do this? |
Beta Was this translation helpful? Give feedback.
Replies: 1 comment
-
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 See docs: https://mathjs.org/docs/expressions/expression_trees.html |
Beta Was this translation helpful? Give feedback.
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 off1
with it's implementation2*x
using the method.transform(...)
. When replacing, you should make sure the function variables should be correctly renamed too when needed, such thatf1(y)
will be replaced with2*y
.See docs: https://mathjs.org/docs/expressions/expression_trees.html