从表达式中提取完整的参数和函数名称(仅限标准数学函数) [英] Extract complete argument and function name(s) from the Expression, (standard mathematical functions only) MAPLE

查看:94
本文介绍了从表达式中提取完整的参数和函数名称(仅限标准数学函数)的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

对于类似

a1 := sin(1+a/b);
a2 := log(1+ a*b);
a3 := abs(a^2+b);

如何获取各个函数的表达式.例如

how can I get expressions of respective functions. For example

someCommand(a1)  # should get an output 1+a/b
someCommand(a2)  # should get an output 1+a*b
someCommand(a3)  # should get an output a^2+b

我试图从maple文档中获取相关主题,但不幸的是,我无法完全了解它.

I have tried to get related topics from maple documentation but unfortunately am not able to get exactly.

以及如何按顺序获取所用功能的列表

edited: Also how is it possible to get list (in sequence)of functions used

a :=sin(log(abs(a+b)));# functions can be of more than two
someCommand(a) # have to return [{sin, log, abs}, a+b]

推荐答案

在对另一个答案的后续评论中,您给出了sin(log(abs(a+b)))的另一个示例.我怀疑您想对更多复杂的示例进行切片和切块.

In your followup comment to another Answer you gave the further example of sin(log(abs(a+b))). I suspect that you want to be able to slice and dice even more complicated examples.

您并没有真正告诉您最终的目标是什么.也许您正在尝试构建表达式树.或者,也许您正在计划通过此分析做其他事情.如果您告诉我们最终目标,真的会有所帮助.

You haven't really told use what your final goal is. Perhaps you're trying to build an expression tree. Or perhaps you're evenutally planning on doing something else with this analysis. It'd really help if you told us the final goal.

话虽如此,以下内容可能对您有用.

Having said that, the following might be of some use to you.

restart;

ee := "sin(log(abs(a+b))) + sin(s+t) + abs(log(v+w))":

P:=InertForm:-Parse(ee):

lprint(P);


 `%+`(%sin(%log(%abs(`%+`(a,b)))),%sin(`%+`(s,t)),
      %abs(%log(`%+`(v,w))))

不管您的目标是什么,上面的惰性形式都可能是您可以使用的形式.

It may be that the above inert form is something you can work with, for whatever your goal might be.

indets(P, specfunc(name,`%+`));

            {a %+ b, s %+ t, v %+ w}

indets(P, specfunc(anything,%abs));

       {%abs(a %+ b), %abs(%log(v %+ w))}

indets(P, specfunc(specfunc(name,`%+`),%abs));

                {%abs(a %+ b)}

indets(P, specfunc(specfunc(name,`%+`),%log));

                {%log(v %+ w)}

使用我先前的答案中的常规限制,

Using a routine limke from my earlier Answer,

W := (ee,nm) -> [op(map(`[]`@op,indets(ee,':-specfunc'(nm))))]:

W( indets(P, specfunc(specfunc(name,`%+`),%log)), `%+` );

                   [[v, w]]

W( indets(P, specfunc(specfunc(name,`%+`),%sin)), `%+` );

                   [[s, t]]

W( indets(P, specfunc(specfunc(name,`%+`),%abs)), `%+` );

                   [[a, b]]

还有其他获得最后结果的方法(例如在实际表达式上使用类似W的东西,而不是其惰性形式).我只是想向您展示如何用这一切做更多的事情.

There are other ways to get those last results (using something like W on an actual expression and not its inert form, say). I'm just trying to show you how you can do a bit more with it all.

这篇关于从表达式中提取完整的参数和函数名称(仅限标准数学函数)的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆