# Truncation and round off functions MathCad Help

These functions all have in common the fact that they extract something from theirarguments.

The functions Re, 1m, and arg extract the corresponding part of a complex number. For more information on these functions, see Chapter 8, “Variables and Constants.”

The functions cell and floor will return the next integer above and below their arguments respectively. You can use these functions to create a function that returns just the mantissa of a number:

mantissa(x) := x – floor(x)

Creating a round-off function.

Creating a round-off function.

Discrete transform functions

Mathcad contains a variety of functions for performing discrete transforms. All these functions require vectors as arguments. When you define a vector v for use with Fourier or wavelet transforms, be sure to start with “o If you do not define va’ Mathcad automatically sets it to zero. This can distort the results of the transform functions

Introduction to Discrete Fourier transforms

Mathcad comes with two types of Fourier transform pairs: fftl ifft and cfftl icfft . These functions are dicrete: they apply to and return vectors and matrices only. You cannot use them with other functions

Use the ift and ifft functions if

•The data values in the time domain are real, and
• the data vector has 2m elements.

The first condition is required because theift/ifft pair takes advantage of the fact that, for real data, the second half of the transform is just the conjugate of the first. Mathcad discards the second half of the result vector. This saves both time and memory. The cift/icift pair does not assume symmetry in the transform. For this reason, you must use this pair for complex valued data. Since the real numbers are just a subset ofthe complex numbers, you can use the cfft/icift pair for rea] numbers as well.

The second condition is required because thefft/ifft Fourier transform pair uses a highly efficient fast Fourier transform algorithm. In order to do so, the vector you use withift must have 2m elements. The cift/icift Fourier transform pair uses an algorithm that
permits vectors as well as matrices of arbitrary size. When you use this transform pair with a matrix, you get back a two-dimensional Fourier transform.

Note that if you used ift to get to the frequency domain, you must use ifft to get back to the time domain. Similarly, if you used cift to get to the frequency domain, you must use icift to get back to the time domain.

Different sources use different conventions concerning the initial factor of the Fourier transform and whether to conjugate the results of either the transform or the inverse transform. The functions fft, ifft, cift, and icfft use I I IN as a normalizing factor and a positive exponent in going from the time to the frequency domain. The functions FFT, IFFT, CFFT, and TCFFT use 1IN as a normalizing factor and a negative exponent in going from the time to the frequency domain. Be sure to use these functions in pairs. For example, if you used CFFT to go from the time domain to the frequency domain, you must use ICFFT to transform back to the time domain.

Fourier transforms on real data

With 2m real-valued data points, you can use thefft/ifft Fourier transform pair. These functions take advantage of symmetry conditions present only when the data is real. This saves both time and memory

Fourier transforms on complex data

There are two reasons why you may not be able to use thefft/iffttransform pair discussed in the previous section:

• The data may be complex valued. This means that Mathcad can no longer exploit the symmetry present in the real valued case.

• The data vector might not have 2m data points in it. This means Mathcad cannot take advantage of the highly efficient FFT algorithm used by the fft/ifft Fourier.” transform pair.

Complex Fourier transforms require the following functions:

Although the cfft/icfft Fourier transform pair will work on arrays of any size, they work significantly faster when the number of rows and columns contains many smaller factors. Vectors with length 2m fall into this category. So do vectors having lengths like 100 or 120. On the other hand, a vector whose length is a large prime number will slow down the Fourier transform algorithm.

When you use the cift with a matrix, the result is the two-dimensional Fourier transform of the input matrix

Use offast Fourier transforms in Mathcad

.

Posted on November 20, 2015 in Built-in Functions