|
Prev | Next |
# include "exp_2.hpp"
y = exp_2(x)
\[
\exp (x) = 1 + x^1 / 1 ! + x^2 / 2 ! + \cdots
\]
The second order approximation for the exponential function is
\[
{\rm exp\_2} (x) = 1 + x + x^2 / 2
\]
cppad-yyyymmdd/introduction/exp_apx
where
cppad-yyyymmdd
is the distribution directory
created during the beginning steps of the
installation
of CppAD.
x
has prototype
const Type &x
(see
Type
below).
It specifies the point at which to evaluate the
approximation for the second order exponential approximation.
y
has prototype
Type y
It is the value of the exponential function
approximation defined above.
u
and v are Type objects and i
is an int:
| Operation | Result Type | Description |
Type(i)
|
Type
|
construct object with value equal to
i
|
Type u = v
|
Type
|
construct
u
with value equal to
v
|
u * v
|
Type
|
result is value of
u * v
|
u / v
|
Type
|
result is value of
u / v
|
u + v
|
Type
|
result is value of
u + v
|
| exp_2.hpp | exp_2: Implementation |
| exp_2.cpp | exp_2: Test |
| exp_2_for0 | exp_2: Operation Sequence and Zero Order Forward Mode |
| exp_2_for1 | exp_2: First Order Forward Mode |
| exp_2_rev1 | exp_2: First Order Reverse Mode |
| exp_2_for2 | exp_2: Second Order Forward Mode |
| exp_2_rev2 | exp_2: Second Order Reverse Mode |
| exp_2_cppad | exp_2: CppAD Forward and Reverse Sweeps |
double x = .1;
double y = exp_2(x);
What is the value assigned to
v1, v2, ... ,v5 in exp_2.hpp
?
exp_2.hpp to
a routine exp_3.hpp that computes
\[
1 + x^2 / 2 ! + x^3 / 3 !
\]
Do this in a way that only assigns one value to each variable
(as exp_2 does).
double x = .5;
double y = exp_3(x);
using exp_3 created in the previous problem.
What is the value assigned to the new variables in exp_3
(variables that are in exp_3 and not in exp_2) ?