EvaluateToFloat - Maple Help

Statistics

 EvaluateToFloat
 evaluate data using floating-point arithmetic

 Calling Sequence EvaluateToFloat(X)

Parameters

 X -

Description

 • The EvaluateToFloat command evaluates to floating-point all elements in data. Each element of data can be any Maple expression, but this expression must be able to be evaluated to a floating-point number. Failure to evaluate to do so will generate an exception. By default the EvaluateToFloat attempts to represent the result using hardware data type. This can be changed by setting the UseHardwareFloats flag to false.
 • The first parameter X is a data sample - given as e.g. a Vector.

Examples

 > $\mathrm{with}\left(\mathrm{Statistics}\right):$
 > $A≔\mathrm{Array}\left(\left[3,3,1,a,b,a,\mathrm{\pi },\mathrm{sin}\left(1\right),\mathrm{undefined},\mathrm{\infty }\right]\right)$
 ${A}{≔}\left[\begin{array}{cccccccccc}{3}& {3}& {1}& {a}& {b}& {a}& {\mathrm{\pi }}& {\mathrm{sin}}{}\left({1}\right)& {\mathrm{undefined}}& {\mathrm{\infty }}\end{array}\right]$ (1)

This will result in an error since A contains non-numeric data.

 > $\mathrm{EvaluateToFloat}\left(A\right)$
 > $B≔\mathrm{RemoveNonNumeric}\left(A\right)$
 ${B}{≔}\left[\begin{array}{ccccc}{3}& {3}& {1}& {\mathrm{\pi }}& {\mathrm{sin}}{}\left({1}\right)\end{array}\right]$ (2)
 > $\mathrm{EvaluateToFloat}\left(B\right)$
 $\left[\begin{array}{ccccc}{3.}& {3.}& {1.}& {3.14159265358979}& {0.841470984807897}\end{array}\right]$ (3)
 > $C≔\left[\mathrm{sin}\left(1\right),\mathrm{sin}\left(2\right),\mathrm{sin}\left(3\right)\right]$
 ${C}{≔}\left[{\mathrm{sin}}{}\left({1}\right){,}{\mathrm{sin}}{}\left({2}\right){,}{\mathrm{sin}}{}\left({3}\right)\right]$ (4)
 > $\mathrm{EvaluateToFloat}\left(C\right)$
 $\left[{0.841470984807897}{,}{0.909297426825682}{,}{0.141120008059867}\right]$ (5)
 > $U≔\mathrm{Array}\left(C\right)$
 ${U}{≔}\left[\begin{array}{ccc}{\mathrm{sin}}{}\left({1}\right)& {\mathrm{sin}}{}\left({2}\right)& {\mathrm{sin}}{}\left({3}\right)\end{array}\right]$ (6)
 > $S≔\mathrm{EvaluateToFloat}\left(U\right)$
 ${S}{≔}\left[\begin{array}{ccc}{0.841470984807897}& {0.909297426825682}& {0.141120008059867}\end{array}\right]$ (7)
 > $\mathrm{UseHardwareFloats}≔\mathrm{false}$
 ${\mathrm{UseHardwareFloats}}{≔}{\mathrm{false}}$ (8)
 > $T≔\mathrm{EvaluateToFloat}\left(U\right)$
 ${T}{≔}\left[\begin{array}{ccc}{0.8414709848}& {0.9092974268}& {0.1411200081}\end{array}\right]$ (9)
 > $\mathrm{ArrayOptions}\left(S,\mathrm{datatype}\right)$
 ${{\mathrm{float}}}_{{8}}$ (10)
 > $\mathrm{ArrayOptions}\left(T,\mathrm{datatype}\right)$
 ${\mathrm{sfloat}}$ (11)