AD Binary Arithmetic Operators
Keywords: ad binary arithmetic operators + add plus - subtract minus * multiply times / divide syntax purpose op base x y z operation sequence example derivative addition subtraction multiplication division

| Prev | Next |  |  |  |  |  |  |

AD Binary Arithmetic Operators
Syntax
`z = x Op y`
Purpose
Performs arithmetic operations where either `x` or `y` has type `AD<Base>` or VecAD<Base>::reference .
Op
The operator `Op` is one of the following

Op | Meaning
`+` | `z` is `x` plus `y`
`-` | `z` is `x` minus `y`
`*` | `z` is `x` times `y`
`/` | `z` is `x` divided by `y`

Base
The type `Base` is determined by the operand that has type `AD<Base>` or `VecAD<Base>::reference` .
x
The operand `x` has the following prototype `
const Type &x
` where `Type` is `VecAD<Base>::reference` , `AD<Base>` , `Base` , or `double`.
y
The operand `y` has the following prototype `
const Type &y
` where `Type` is `VecAD<Base>::reference` , `AD<Base>` , `Base` , or `double`.
z
The result `z` has the following prototype `
Type z
` where `Type` is `AD<Base>` .
Operation Sequence
This is an atomic AD of Base operation and hence it is part of the current AD of `Base` operation sequence .
Example
The following files contain examples and tests of these functions. Each test returns true if it succeeds and false otherwise.

add.cpp | AD Binary Addition: Example and Test
sub.cpp | AD Binary Subtraction: Example and Test
mul.cpp | AD Binary Multiplication: Example and Test
div.cpp | AD Binary Division: Example and Test

Derivative
If f and g are Base functions
Addition ∂ [ f ( x ) + g ( x ) ] ∂ x = ∂ f ( x ) ∂ x + ∂ g ( x ) ∂ x
Subtraction ∂ [ f ( x ) - g ( x ) ] ∂ x = ∂ f ( x ) ∂ x - ∂ g ( x ) ∂ x
Multiplication ∂ [ f ( x ) * g ( x ) ] ∂ x = g ( x ) * ∂ f ( x ) ∂ x + f ( x ) * ∂ g ( x ) ∂ x
Division ∂ [ f ( x ) / g ( x ) ] ∂ x = [ 1 / g ( x ) ] * ∂ f ( x ) ∂ x - [ f ( x ) / g ( x ) 2 ] * ∂ g ( x ) ∂ x

Input File: cppad/local/ad_binary.hpp