Math Function
Perform mathematical function
Libraries:
Simulink /
Math Operations
HDL Coder /
Math Operations
Description
The Math Function block performs many common mathematical functions.
You can select one of these functions from the Function parameter list in Math Function block.
Function  Description  Mathematical Expression  MATLAB^{®} Equivalent 

exp

Exponential 

exp

log

Natural logarithm 

log

2^u
 Power of base 2 


10^u

Power of base 10 


log10

Common (base 10) logarithm 

log10

magnitude^2

Complex modulus 
 
square

Power 2 


pow
 Power 

power

conj

Complex conjugate 

conj

reciprocal with Exact method 
Reciprocal 


reciprocal with NewtonRaphson method  Reciprocal  See NewtonRaphson Reciprocal Algorithm Method  None 
hypot

Square root of sum squares 

hypot

rem

Remainder after division 
— 
rem

mod

Modulus after division 
— 
mod

transpose

Transpose 


hermitian

Complex conjugate transpose 


Tip
To perform square root calculations, use the Sqrt block.
The block output is the result of the operation of the function on the input or inputs. The functions support these types of operations.
Function  Scalar Operations  ElementWise Vector and Matrix Operations  Vector and Matrix Operations 

exp

Yes 
Yes  Not applicable 
log

Yes 
Yes  Not applicable 
2^u
 Yes  Yes  Not applicable 
10^u

Yes 
Yes  Not applicable 
log10

Yes 
Yes  Not applicable 
magnitude^2

Yes 
Yes  Not applicable 
square

Yes 
Yes  Not applicable 
pow

Yes 
Yes  Not applicable 
conj

Yes 
Yes  Not applicable 
reciprocal with Exact method 
Yes 
Yes  Not applicable 
reciprocal with NewtonRaphson method  Yes  Yes  Not applicable 
hypot

Yes, on two inputs 
Yes, on two inputs (two vectors or two matrices of the same size, a scalar and a vector, or a scalar and a matrix) 
— 
rem

Yes, on two inputs 
Yes, on two inputs (two vectors or two matrices of the same size, a scalar and a vector, or a scalar and a matrix)  Not applicable 
mod

Yes, on two inputs 
Yes, on two inputs (two vectors or two matrices of the same size, a scalar and a vector, or a scalar and a matrix)  Not applicable 
transpose

Yes 
— 
Yes 
hermitian

Yes 
— 
Yes 
The name of the function and the appropriate number of input ports appear on the block.
Tip
Use the Math Function block when you want vector or matrix output.
NewtonRaphson Reciprocal Algorithm Method
The reciprocal
function that has the NewtonRaphson algorithm method
calculates the reciprocal by using the NewtonRaphson approximation method. The
function uses recursive approximation to find better approximations to the roots of
a realvalue function.
The reciprocal of a real number $$a$$ is defined as a zero of the function:
$$f\left(x\right)=\frac{1}{x}a.$$
Simulink^{®} chooses an initial estimate in the range $$0<{x}_{0}<\frac{2}{a}$$, because this is the domain of convergence for the function.
To successively calculate the roots of the function, specify the Number of iterations parameter. The process is repeated as follows:
$${x}_{i+1}={x}_{i}\frac{f\left({x}_{i}\right)}{f\text{'}\left({x}_{i}\right)}={x}_{i}+({x}_{i}a{x}_{i}{}^{2})={x}_{i}.(2a{x}_{i})$$
$$f\text{'}(x)$$ is the derivative of the function $$f(x)$$.
Data Type Support
This table lists the input data types that each function of the block can support.
Function  Single  Double  Half*  Boolean  BuiltIn Integer  Fixed Point 

 Yes  Yes  Yes  —  —  — 
 Yes  Yes  Yes  —  —  — 
 Yes  Yes  Yes  —  —  — 
 Yes  Yes  Yes  —  —  — 
 Yes  Yes  Yes  —  —  — 
 Yes  Yes  Yes  —  Yes  Yes 
 Yes  Yes  Yes  —  Yes  Yes 
 Yes  Yes  Yes  —  —  — 
 Yes  Yes  Yes  —  Yes  Yes 
 Yes  Yes  Yes  —  Yes  Yes 
 Yes  Yes  —  —  Yes  Yes 
 Yes  Yes  Yes  —  —  — 
 Yes  Yes  Yes  —  Yes  — 
 Yes  Yes  Yes  —  Yes  — 
 Yes  Yes  Yes  Yes  Yes  Yes 
 Yes  Yes  Yes  —  Yes  Yes 
For more information on halfprecision arithmetic operations, see The HalfPrecision Data Type in Simulink (FixedPoint Designer).
Ports
Input
Output
Parameters
Block Characteristics
Data Types 

Direct Feedthrough 

Multidimensional Signals 

VariableSize Signals 

ZeroCrossing Detection 
