# Difference equation with neural network

**URL:** https://discourse.julialang.org/t/difference-equation-with-neural-network/97403
**Category:** Machine Learning
**Tags:** neural-network, difference-equations
**Created:** [April 12, 2023, 7:07pm UTC](https://discourse.julialang.org/t/difference-equation-with-neural-network/97403 "2023-04-12T19:07:29Z")
**Posts on this page:** 1
**Page:** 1

<div class="post-metadata">

### Author: ![quantiota](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/quantiota/32/46039_2.png) [@quantiota](https://discourse.julialang.org/u/quantiota)
#### Post date: [April 12, 2023, 7:07pm UTC](https://discourse.julialang.org/t/difference-equation-with-neural-network/97403/1 "2023-04-12T19:07:30Z")

</div>

Someone can give me a research direction to find the time series w[i] so that the loss function sum(F.^2) is minimized for a known time series q.

```julia
# define a function to calculate the values of F for a given time series q, time series of 𝜭, and value of ζ
# 𝜭[i] is defined as 𝜭[i] = cumsum (w[i] * Δt[i]) where Δt[i] is the time period.

ζ = 1/(4*pi)
function calculate_F(q, ζ, 𝜭)
    F = Float64[]
    for i in 1 : length(q) - 2
        value = q[i+2] - 2*exp(-ζ*𝜭[i]) * cos(𝜭[i] ) * q[i+1] + exp(-2*ζ*𝜭[i]) * q[i]
        push!(F, value)
    end
    return F
end

```
