# Way to write the integral with ModelingToolkit

Is there a way to write the following integral with ModelingToolkit.jl, is binomial expansion the only option here?

\int_{0}^{t} (t - x)^{\lambda} u(x) d x \quad \text{, } \lambda < 0 \quad \text{, for } t> 0

I want to include this integral in a PINN.

https://neuralpde.sciml.ai/dev/pinn/integro_diff/

Hi @ChrisRackauckas, I have read that tutorial, but I am not sure how to write the code for the power term inside the integral with ModelingToolkit.

Ix = Integral(x in DomainSets.ClosedInterval(0, t))
Ix((t-x)^lambda * u(x))


Hi @ChrisRackauckas I tried what you suggested but I am unable to discretize the equation, below is the code and the error. I am not sure where to pass the parameter x.

using NeuralPDE, Flux, ModelingToolkit, DiffEqFlux, DomainSets
import ModelingToolkit: Interval

@parameters t, x
@variables u(..)
lambda = -1.5
Di = Differential(t)
Ii = Integral(x in DomainSets.ClosedInterval(0, t))
eq = Di(u(t)) + Ii((t-x)^lambda*u(x)) ~ 1.0
bcs = [u(0.0) ~ 0.0]
domains = [t ∈ Interval(0.0,2.0)]
chain = Chain(Dense(1,15,Flux.σ),Dense(15,1))
initθ = Float64.(DiffEqFlux.initial_params(chain))

strategy_ = GridTraining(0.05)
discretization = PhysicsInformedNN(chain,
strategy_;
init_params = nothing,
phi = nothing,
derivative = nothing)
@named pde_system = PDESystem(eq,bcs,domains,[t],[u(t)])
prob = NeuralPDE.discretize(pde_system,discretization)

ERROR: KeyError: key :x not found


Hi @kaido975 The integral Ii should be defined in this way,

Ii = Integral(t in DomainSets.ClosedInterval(0, t))


Hi @Ashutosh_Bharambe, I want the equation to be of the form,

Integral(x, 0..t)(((t - x)^lambda)*u(x)) + Differential(t)(u(t)) ~ 0.0


What you suggested would give me,

Integral(t, 0..t)(((t - x)^lambda)*u(x)) + Differential(t)(u(t)) ~ 0.0


Hey @kaido975 there’s an issue with dealing integrands of this sort. We’re working on it.