<!--
This file is generated by a tool. Do not edit directly.
For open-source contributions the docs will be updated automatically.
-->

*Last updated: 2023-03-16.*

<div itemscope itemtype="http://developers.google.com/ReferenceObject">
<meta itemprop="name" content="tf_quant_finance.rates.analytics.forwards.forward_rates" />
<meta itemprop="path" content="Stable" />
</div>

# tf_quant_finance.rates.analytics.forwards.forward_rates

<!-- Insert buttons and diff -->

<table class="tfo-notebook-buttons tfo-api" align="left">
</table>

<a target="_blank" href="https://github.com/paolodelia99/tf-quant-finance/blob/main/tf_quant_finance/rates/analytics/forwards.py">View source</a>



Computes forward rates from daycount fractions and discount factors.

```python
tf_quant_finance.rates.analytics.forwards.forward_rates(
    df_start_dates, df_end_dates, daycount_fractions, dtype=None, name=None
)
```



<!-- Placeholder for "Used in" -->

#### Example
```python
# Discount factors at start dates
df_start_dates = [[0.95, 0.9, 0.75], [0.95, 0.99, 0.85]]
# Discount factors at end dates
df_end_dates = [[0.8, 0.6, 0.5], [0.8, 0.9, 0.5]]
# Daycount fractions between the dates
daycount_fractions = [[0.5, 1.0, 2], [0.6, 0.4, 4.0]]
# Expected:
#  [[0.375 , 0.5   , 0.25  ],
#   [0.3125, 0.25  , 0.175 ]]
forward_rates(df_start_dates, df_end_dates, daycount_fractions,
              dtype=tf.float64)
```

#### Args:


* <b>`df_start_dates`</b>: A real `Tensor` representing discount factors at the start
  dates.
* <b>`df_end_dates`</b>: A real `Tensor` representing discount factors at the end
  dates.
* <b>`daycount_fractions`</b>: A real `Tensor` representing  year fractions for the
  coupon accrual.
* <b>`dtype`</b>: `tf.Dtype`. If supplied the dtype for the input and output `Tensor`s.
  Default value: None which maps to the default dtype inferred from
  `df_start_dates`.
* <b>`name`</b>: Python str. The name to give to the ops created by this function.
  Default value: None which maps to 'forward_rates'.

Returns: