Planetary Orbital Evolution due to Tides
Orbital evolution of two objects experiencing tides
LogDerivatives.cpp
Go to the documentation of this file.
1 
9 #include "LogDerivatives.h"
10 
11 namespace StellarEvolution {
12 
13  double LogDerivatives::transform_log_x_deriv(unsigned order) const
14  {
15  switch(order) {
16  case 0:
17  return __underlying_deriv_values[0];
18  case 1:
19  return __underlying_deriv_values[1] / __x;
20  case 2:
21  return (
23  -
25  )/(__x * __x);
26  default:
28  "Transforming log-derivatives of order higher than 2 is"
29  " not implemented."
30  );
31  }
32  }
33 
35  double uncorrected_derivative,
36  unsigned order
37  ) const
38  {
39  if(order == 0)
40  return std::exp(uncorrected_derivative);
41  else if(order == 1)
42  return __deriv_values[0] * uncorrected_derivative;
43  else if(order == 2) {
44  if(__deriv_values[0] == 0) {
45  assert(__deriv_values[1] == 0);
46  return 0.0;
47  } else {
48  return (
49  __deriv_values[0] * uncorrected_derivative
50  +
52  );
53  }
54  } else {
56  "Requesting derivative of roder > 2 not supported!"
57  );
58  }
59  }
60 
61  double LogDerivatives::order(unsigned deriv_order) const
62  {
63  if(__deriv_values.size() <= deriv_order) {
64  for(
65  unsigned order = __deriv_values.size();
66  order <= deriv_order;
67  ++order
68  ) {
70  double corrected_deriv_value = (
71  __log_x
73  : calc_deriv(order)
74  );
75  if(__log_y)
76  corrected_deriv_value = transform_log_y_deriv(
77  corrected_deriv_value,
78  order
79  );
80  __deriv_values.push_back(corrected_deriv_value);
81  }
82  }
83  return __deriv_values[deriv_order];
84  }
85 
86 } //End of StellarEvolution namespace.
double transform_log_y_deriv(double uncorrected_derivative, unsigned order) const
Correct for differentiating of log(quantity) instead of quantity.
Function arguments do not satisfy some requirement.
Definition: Error.h:73
virtual double calc_deriv(unsigned deriv_order) const =0
Should be overwritten to calculate the derivatives with respect to either arg or log(arg) as specifie...
double __x
The value of the argument at which derivatives are calculated.
bool __log_x
Is the underlying derivative w.r.t. log(argument)?
std::vector< double > __underlying_deriv_values
Cache for previously computed underlying derivative values.
double order(unsigned deriv_order=1) const
Returns the deriv_order-th derivative of the quantity.
Declares a class for differentiating functions of log(arg) w.r.t. arg.
bool __log_y
Is the underlying derivative of log(quantity)
std::vector< double > __deriv_values
Cache for previously computed corrected derivative values.
double transform_log_x_deriv(unsigned order) const
Correct for differentiating w.r.t. log(arg) instead of arg.