4

I am looking to approximate the solution u of the following equation using discretization method or any other idea. Is there any way on how to find a numerical solution for it:

u[t]-Integrate[Abs[t - s]^(-1/2)*u[s], {s, 0, 1}] == 1/3 (-2 Sqrt[1 - t]+3t-4 Sqrt[1-t]t-4t^(3/2)) where 0<t<1.

The solution is u[x]=x but I am assuming that I dont know the answer and we need to find approximation for it.

Roman
  • 47,322
  • 2
  • 55
  • 121
Mutaz
  • 323
  • 1
  • 6
  • 2
    Either you need to provide the function u[t], or you need to provide an equation that u[t] satisfies. – Carl Woll May 19 '19 at 19:39
  • In fact, I need to find this u numerically. – Mutaz May 19 '19 at 19:43
  • 2
    The above is not valid Mathematica code? In Mathematica a function u(t) is written as u[t] also for u(s) it is u[s] – Nasser May 19 '19 at 19:44
  • 2
    Perhaps you meant you need to solve u[t] - Integrate[Abs[t-s]^(-1/2) u[s], {s, 0, 1}] == 0 numerically. If there is no equation, then there is no way to solve for u[t]. – Carl Woll May 19 '19 at 19:45
  • I have corrected the question accordingly – Mutaz May 19 '19 at 19:48
  • 3
    If an approximation is fine, you could write $u(t)=a_0+a_1t+a_2t^2+\mathcal O(t^3)$ and solve for $a_i$. I get $a_0=0$, $a_1=1$, $a_2=0$, etc, which confirms that $u(t)=t$ is a solution. – AccidentalFourierTransform May 19 '19 at 22:11
  • Some times the solution is not a polynomial – Mutaz May 20 '19 at 04:26
  • Maybe a good start would be to go to math.SE and ask: given a function $u(t)$ for $t\in[0,1]$, how can we best describe the function $w(t)=\int_0^1 ds,u(s)/\sqrt{\lvert s-t\rvert}$ for $t\in[0,1]$? Once you know more properties of this transformed function, your problem may be easier to reflect in Mathematica. – Roman May 20 '19 at 12:21

3 Answers3

3

Not an answer, only an idea to solve the problem.

I tried to solve your integral equation iterativ using NestList:

sol = NestList[
Function[fu,
FunctionInterpolation[
 1/3 (-2 Sqrt[1 - t] + 3 t - 4 t Sqrt[1 - t] - 4 t^(3/2)) + 
  NIntegrate[fu[s]/Sqrt[Sqrt[(t - s)^2]] , {s, 0, 1}, 
   Method -> "LocalAdaptive" ], {t, 0, 1 }]
] , 0 &,  (* initial function *)5];

Unfortunately the Picarditeration doesn't converge in your case:

    Plot[Map[#[t] &, sol], {t, 0, 1}

enter image description here

Perhaps you have additional system knowhow to force a convergent iteration?

Ulrich Neumann
  • 53,729
  • 2
  • 23
  • 55
3

I will add another method that is not as accurate as method @Roman, but faster. It uses expression describing the integral Integrate[1/Sqrt[Abs[t-s]], {s, 0, 1}]

ker[s_, t_] := If[t > s, -2*Sqrt[t - s], 2*Sqrt[s - t]]

Then everything is as usual

np = 51; points = fun = Table[Null, {np}];
Table[points[[i]] = i/np, {i, np}];
sol = Unique[] & /@ points;

Do[fun[[i]] = 
   1/3 (-2 Sqrt[1 - t] + 3 t - 4 Sqrt[1 - t] t - 4 t^(3/2)) /. 
    t -> points[[i]], {i, np}];

sol1 = sol /. 
   First@Solve[
     Table[sol[[j]] - 
        Sum[.5*(sol[[i]] + 
            sol[[i + 1]])*(ker[points[[i + 1]], points[[j]]] - 
            ker[points[[i]], points[[j]]]), {i, 1, np - 1}] == 
       fun[[j]], {j, 1, np}], sol];

u = Transpose[{points, sol1}];

Show[Plot[t, {t, 0, 1}], ListPlot[u]]

Fig1

Alex Trounev
  • 44,369
  • 3
  • 48
  • 106
2

Here's a general solution that works by interpolation. I'll present the method in a very slow way, and we can work on speeding it up later on if desired.

First, we make an ansatz for the function $u(t)$ on the interval $[0,1]$. Here I use a grid of $n+1$ equidistant points and a linear interpolation scheme:

n = 10;
tvalues = Subdivide[n];
uvalues = Unique[] & /@ tvalues;  (* we don't care what these variables are called *)
tupairs = Transpose[{tvalues, uvalues}];
u[t_] = Piecewise@BlockMap[{((t-#[[2,1]])#[[1,2]]-(t-#[[1,1]])#[[2,2]])/(#[[1, 1]]-#[[2, 1]]),
          #[[1,1]]<=t<=#[[2,1]]}&, tupairs, 2, 1]

Check that this interpolation scheme has indeed the values uvalues on the grid points tvalues:

u /@ tvalues == uvalues
(* True *)

Define the integral $\int_0^1 ds\,u(s)/\sqrt{\lvert t-s\rvert}$:

uint[t_] := Integrate[u[s]/Sqrt[Abs[t-s]], {s, 0, 1}]

Evaluate this integral on the same grid of tvalues: here is the slow part of this calculation, and could probably be sped up dramatically,

uintvalues = uint /@ tvalues
(* long output where every element is a linear combination of the uvalues *)

The right-hand side of the integral equation, evaluated on the same grid of tvalues:

f[t_] = 1/3 (-2 Sqrt[1 - t] + 3 t - 4 Sqrt[1 - t] t - 4 t^(3/2));
fvalues = f /@ tvalues
(* long output *)

Solve for the coefficients of $u(t)$: a linear system of equations for the grid values uvalues, found by setting the left and right sides of the integral equation equal at every grid point in tvalues,

solution = tupairs /.
  First@Solve[Thread[uvalues - uintvalues == fvalues] // N, uvalues]

{{0, 5.84947*10^-16}, {1/10, 0.1}, {1/5, 0.2}, {3/10, 0.3}, {2/5, 0.4}, {1/2, 0.5}, {3/5, 0.6}, {7/10, 0.7}, {4/5, 0.8}, {9/10, 0.9}, {1, 1.}}

This confirms your analytic solution $u(t)=t$ but is much more general.

You don't need the // N in the last step if you prefer an analytic solution; however, numerical solution is very much faster.

ListLinePlot[solution, PlotMarkers -> Automatic]

enter image description here

Update: much faster version

To speed up this algorithm, the main point is to speed up the calculation of the uintvalues from the uvalues. Instead of doing piecewise integrals, this calculation can be expressed as a matrix multiplication, uintvalues == X.uvalues, with the matrix X defined as

n = 10;
X = N[4/(3 Sqrt[n])]*
  SparseArray[{{1,1} -> 1.,
               {-1,-1} -> 1.,
               Band[{2,2}, {-2,-2}] -> 2.,
               Band[{2,1}, {-1,1}, {1,0}] ->
                 N@Table[(i-2)^(3/2)-(i-1)^(3/2)+3/2*(i-1)^(1/2), {i,2,n+1}],
               Band[{1,-1}, {-2,-1}, {1,0}] -> N@Reverse@Table[(i-2)^(3/2)-(i-1)^(3/2)+3/2*(i-1)^(1/2), {i,2,n+1}],
               Sequence @@ Table[Band[{1,a}, {1+n-a,n}] -> N[a^(3/2)-2*(a-1)^(3/2)+(a-2)^(3/2)], {a,2,n}],
               Sequence @@ Table[Band[{a+1,2}, {n+1,n+2-a}] -> N[a^(3/2)-2(a-1)^(3/2)+(a-2)^(3/2)], {a,2,n}]},
              {n+1, n+1}] // Normal;

(The coefficients follow from the Piecewise ansatz and analytic integration.)

With this matrix defined, the algorithm becomes simply

tvalues = Subdivide[n];
f[t_] = 1/3 (-2 Sqrt[1 - t] + 3 t - 4 Sqrt[1 - t] t - 4 t^(3/2));
fvalues = f /@ tvalues;
solution = Inverse[IdentityMatrix[n+1] - X].fvalues
ListLinePlot[Transpose[{tvalues, solution}]]

In this way, $n=1000$ grid points can be achieved in a few seconds, most of which is still spent in assembling the X-matrix. The next step would be to write down a faster way of assembling X.

Roman
  • 47,322
  • 2
  • 55
  • 121
  • Dear Roman, I couldn't find any word that deserve saying Thank you for the idea you provided. The solution works perfectly for me. We just need to work to speed it up. Also I have another schemes that I need to discuss it with you. Please send me your email. I need someone to work with me on a paid project if you interested. – Mutaz May 20 '19 at 19:37
  • You're welcome. Email me at Uncompress["1:eJxTTMoPChZnYGAoys9NzNMrTs7IzUxNcSjNy0xKLNZLzgAAnn0Kkg=="] – Roman May 20 '19 at 19:40
  • @Roman How did you find the interpolation u[t]? – Alex Trounev May 21 '19 at 12:06
  • @AlexTrounev every piece of the Piecewise function is a two-point Lagrange polynomial. Concretely, if you set f[x_] = y1*(x - x2)/(x1 - x2) + y2*(x - x1)/(x2 - x1), then f[x1] == y1 and f[x2] == y2. In this way the function f passes through the two points {x1,y1} and {x2,y2}. – Roman May 21 '19 at 12:27
  • @Roman Now I see why the solution of the equation coincides with the exact one. – Alex Trounev May 21 '19 at 16:48
  • @AlexTrounev yes the linear interpolation perfectly represents a linear solution :-) However this method can be used with other kinds of interpolations too (cubic splines, for example). And the linear interpolation will approximate nonlinear solutions pretty well too. I just picked the simplest way to get started. – Roman May 21 '19 at 17:20
  • @ Roman I am just wondering how do you ended up by the form of X from the Integral eqn? – Mutaz May 22 '19 at 01:52
  • @Mutaz by calculating X = D[uintvalues, {uvalues}] for several values of n and then looking for patterns. – Roman May 22 '19 at 07:50
  • @Roman, can i understand the 3rd lines of the 1st code block as follows? 1. With Unique[]&/@tvalues you are applying Unique[]& to {0,1/10,2/10,...,9/10,1}, where Unique[]& is a pure function. If correct, but why the pure function has no formal parameter? I thought that any pure function should have its formal parameter. 2. I just learned that Unique[] is used to generate a new unique symbol named $x. You said "not care what the variables are called". But if it is necessary? – lxy May 23 '19 at 11:27
  • 1
    @jsxs 1. Correct. All I wanted here is a list of symbols that has the right length. Unique[]& is a pure function with zero arguments (which is perfectly legal), and so the supplied argument in Map is discarded. I agree it's a bit opaque; I could have done uvalues = Table[Unique[], {n+1}] instead for more clarity. – Roman May 23 '19 at 11:53
  • @jsxs 2. You can pick any list of uvalues you like, as long as it has the correct length of n+1. You could for example build a list with uvalues = Table[ToExpression["u" <> ToString[i]], {i, 0, n}] so that the variables have more meaningful names. Or you could use subscripting like uvalues = Table[Subscript[u, i], {i, 0, n}] or indexing like uvalues = Array[u, n + 1]. It really doesn't matter, as these variable names aren't used anywhere and the solution appears without them. – Roman May 23 '19 at 11:57
  • @Roman thanks for the clarification. I prefer to uvalues = Table[Unique[], {n+1}], which should be more transparent to beginner, like me :-). Btw, key point to me: for a pure function without argument, the supplied argument in Map will be discarded partially with the number of elements retained to take effect. – lxy May 23 '19 at 14:27
  • @jsxs yes this method is very general. The "much faster version" section is different for different integrals though. You're welcome! – Roman May 24 '19 at 14:01
  • @Roman I have tried to understand and combine your method with Michael's answer to my post: https://mathematica.stackexchange.com/questions/192123/solving-an-integro-differential-equation-with-mathematica/192736?noredirect=1#comment503601_192736. It includes an integral int with a singular point. The code is slow for large integration time tmax. Could you help with speeding it up. Thank you in advance! – user55777 Jun 27 '19 at 08:52
  • @user55777 please contact me at Uncompress["1:eJxTTMoPChZnYGAoys9NzNMrTs7IzUxNcSjNy0xKLNZLzgAAnn0Kkg=="] – Roman Jun 27 '19 at 20:12