billpage

Bill Page

38 Reputation

4 Badges

19 years, 236 days
private contractor
Technical professional in industry or government
Athens, Ontario, Canada

MaplePrimes Activity


These are questions asked by billpage

The map[inplace] operation can apply a function to the elements of an rtable, replacing these elements with the result.  Using map[inplace,evalhf] can be numerically quite efficient but I would like something more general.  For example

x += x +~ v*~dt

where += in some other languages denotes an inplace addition operation and x and v are Vectors (rtable). Is there a way to do this in Maple?

Maple provides efficient vectorization and automatic parallelization for many common operators. For example

x -> 2*~x*~cos~(x*~x)

But in my application it is common to want to create rather long vectorized operators starting from some complicated symbolic computations. Doing conversions by hand from symbolic expressions to element-wise operations is laborious and error prone.

As a very simple example consider that it is possible to obtain (almost) the same result as above by writing the following as a vectorized operation

D(x->sin(x^2))~

But there are at least two problems with this. First of all it is not nearly as efficient as the first operator and second, perhaps not unrelated, is that the datatype returned when applying this operator to a Vector/rtable of hardware floats (e.g. datatype=float[8]) becomes something  more general.

My question is how can I convert a complicated symbolic expression into an efficient numeric element-wise vector operation?

I have tried several different approaches but so far without success. In the case above for example it seemed natural to expect that the following derivative

D(x->sin~(x^~2))

would produce a vectorized result, but this is not the case. In another attempt I was unable to see how to perform substitions into an expression, e.g. like this

unapply(subs(`*`=`*`~, cos=cos~, diff(sin(x),x)), x)

I would be glad to receive suggestions and/or references to relevant documentation. 

 

I am trying to learn to love Maple's document mode... I would like to be able to display a matrix formula or equation without evaluating it. One way to do this is with the following commands:

  with(LinearAlgebra): `print/&.` := proc (l, r) l.r end proc
  pq := <<-P^2, -P*Q+c>|< P*Q+c, Q^2>>
  2*<g.P, g.Q> = pq &. <alpha, beta>

(Paste them into a worksheet in document mode and press Enter to execute one at a time.)

Page 1 of 1