25 Reputation

2 Badges

3 years, 163 days

MaplePrimes Activity

These are replies submitted by schapplm

@tomleslie Thanks for your answer. I did not think about sqrt(x)=x^(1/2) before. Since I want to use the function count in a scientific publication, I will verify them manually in the Matlab code. From what I read, sqrt is implemented with a dedicated algorithm in hardware in the CPU, so I will create a weighted sum of the different function calls (sqrt,sin,cos,atan) and count them separately.

Writing the code myself is not an option here, since it describes the dynamics of multibody systems (robots) and some special expressions are only available via symbolic computing and are way too complicated for manual derivation.


Using the inert form makes this a lot faster and helps a lot with this kind of geometric problem.

Normally, I only need cos(alpha) and sin(alpha) from alpha which I can get directly from exp_x, exp_y of my example above (for rotation matrizes in kinematics). The angle alpha itself is only needed as a time derivative.

The time derivative of the inert form is calculated as fast as the time derivative of the full expression, so I guess the inert arctan expression does not have to be evaluated any more for time differentiation:

> alpha1:=%arctan(exp_y, exp_x): # fast
> alphaD:=diff(alpha1, t): # fast
> alpha2:=arctan(exp_y, exp_x): # slow
> alphaD:=diff(alpha2, t): # fast





do you mean by inert variant to use a temporary variable which is substituted after the arctan expression is assigned?

> alpha := arctan(tmp1, tmp2):
> alpha := subs({tmp1=exp_y, tmp2=exp_x}, alpha):

my problem is, that I need the full expression with arctan for later calculations, for example time derivative of the whole expression for energy calculations.


@Preben Alsholm 

This is a good point.

Unfortunately, the read function of ".mpl" files takes a long time for complicated nested expressions so the "end user" is forced to use the ".m" format.

@Preben Alsholm 

The last part with string conversion did the trick for converting all variables. Thank you.

@Preben Alsholm 

From my understanding, Maple has two different file formats to save expressions: .m and plain text.

Saving as .mpl or with any other ending than .m just saves the expression in text form. The "~"-characters are gone in this expression, which is good, but the expression has to be re-evaluated when reading the file in maple.

I have a complex non-simplified expression taking 2MB when saving as text. Reading this expression again just freezes Maple...

Page 1 of 1