I am encountering difficulties while trying to numerically solve an equation in Mathematica that involves an unknown function and an integral. Specifically, the equation takes the form of \begin{equation} f(z)=g(z)+\int_{z}^1\mathrm{d}y\,g\left(1-\frac{z}{y}\right)\frac{1}{y}f(y),\quad z\in(0,1), \end{equation} where $g(z)$ is a known function, and $f(z)$ is the unknown function I am attempting to solve for. It requires for any $g(z)$, you should have a corresponding solution for $f(z)$.

I tried a specific $g(z)$:

g[z_] := z
equation[z_] := f[z] == g[z] + Integrate[g[1 - z/y]/y*f[y], {y, z, 1}]
solution = NSolve[{equation[z]}, f, {z, 0, 1}]
result[z_] := f[z] /. solution[[1]] 

But it didn't work.

  • 1
    $\begingroup$ You are looking for a numerical solution for unknown function g[z]? Isn't that a contradiction? $\endgroup$ Nov 13, 2023 at 8:13
  • $\begingroup$ No, I want to solve f[z], and g[z] is a known function, however I don’t know how g[z] looks like. So I just set it as an unknown function. I know it seems wired but this is the problem. $\endgroup$
    – dcmpsr
    Nov 13, 2023 at 8:45
  • 1
    $\begingroup$ g[z] is an undefined function and you're looking for a numerical solution? That's the contradiction! $\endgroup$ Nov 13, 2023 at 8:47
  • $\begingroup$ Yes, you are right. I reread the question and made an edit on my question. $\endgroup$
    – dcmpsr
    Nov 13, 2023 at 9:25
  • $\begingroup$ Ok, but be aware that the function domain of g[y] is -Infinity<y<0! $\endgroup$ Nov 13, 2023 at 9:28

1 Answer 1


Although the general problem in the question probably requires the methods referenced by flinty in 285076, the specific problem contained in the question's code, g[z] = z can be solved as follows. Write the integral equation as

eq = f[z] - z - Integrate[(1 - z/y)/y*f[y], {y, z, 1}]; 

Now twice differentiate eq

deq = D[eq, {z, 2}]
(* -f[z]/z^2 + f''[z] *)

construct boundary conditions

bc0 = eq /. z -> 1
{* -1 + f[1] *}
bc1 = D[eq, z] /. z -> 1
(* -1 + f'[1] *)

and solve with DSolve

DSolve[{deq == 0, bc0 == 0, bc1 == 0}, f, z] // Flatten
(* {f -> Function[{z}, 1/10 z^(1/2 - Sqrt[5]/2) 
   (5 - Sqrt[5] + 5 z^Sqrt[5] + Sqrt[5] z^Sqrt[5])]} *)

This solution can be verified by back-substitution.

Simplify[eq /. %, 0 < z < 1]
(* 0 *)

Added note: The approach here should work for any g[z] that is a polynomial or can be approximated accurately by one. The order of the resulting ODE would be one greater than the order of the polynomial. Of course, obtaining a symbolic solution, as accomplished here, might not be possible. Numerical solutions of the resulting ODE would be possible except near z = 0, where the solutions typically would be singular. Even the symbolic solution obtained for g[z] = z is singular there.

  • $\begingroup$ Thank you sir! It works well! I'm new to mma and I got invaluable experience from your answer. $\endgroup$
    – dcmpsr
    Nov 16, 2023 at 5:54

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.