# Restrict the domain of a function (and plot) it) when it depends on the value of a parameter

I know similar questions have been asked, but I am very new at Mathematica and other questions/answers are quite complex and do not suit the code I want to write.

I want to restrict the domain of the function f(x) to be between 0 and a, for the variable x. (I do not want to restrict the plot, just the function - just as in this question). f[x_] := x*(1+a*ln(1-x/a)) , where a is a parameter, that I wish to vary from 0 to let's say 20 with increments of 0.05 for instance.

Then, I wish to plot the function with a slider for this a parameter, that is being able to vary it (hence the plot of f(x) - and its domain - adjusting dynamically).

Following the best answer here, I have tried this:

f[a_Real,x_Real]:= x*(1+a*ln(1-x/a))
Manipulate[Plot[f[a,x],{x,0,a}],{a,0,20,0.05}]


which doesn't work...

• Welcome to Mathematica.SE! I hope you will become a regular contributor. To get started, 1) take the introductory tour now, 2) when you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge, 3) remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign, and 4) give help too, by answering questions in your areas of expertise. Jul 19 at 18:10

The problem: ln(...) should be Log[...]. Furthermore, the endpoints in Plot should be different, so you cannot use a = 0.
f[a_Real, x_Real] := x*(1 + a*Log[1 - x/a])

• You can click on the "+" button next to the slider. Or you can use Manipulate[Plot[f[a, x], {x, 0, a}], {a, 0.05, 20, 0.05, Appearance -> "Labeled"}] Jul 20 at 9:51