0
$\begingroup$

I have defined the following function in Mathematica

al[z_] := (a/((1 + a*(b/(2 Pi))*Log[z/Mz])))

(a and b are defined constants) Now I want to put in a variable x that I will integrate over from 0 to 100, but for low values of x (up to 3) I want the function al to be fixed, i.e., z should be 3 for x < 3 and x for x > 3.

However, I only want this constraint on al when I fill in x. Any ideas on how to do this?

$\endgroup$
2
  • 4
    $\begingroup$ Why not use Piecewise[], then? $\endgroup$ Jul 1, 2016 at 12:11
  • $\begingroup$ Well, I use the function multiple times and if I wanted to fill in a value, say $y$, I did not want that constraint, and trying to be as compact as possible I was wondering whether there was another option. Anyway, thanks. In the end for my specific case the option Min[al[x],al[3]] worked fine as well. $\endgroup$
    – user40834
    Jul 1, 2016 at 16:46

1 Answer 1

2
$\begingroup$

You could use Clip:

al[ Clip[x, {3, Infinity}] ]
$\endgroup$
2
  • $\begingroup$ Note that this is equivalent to suggestion by @J.M. to use Piecewise. Evaluate Clip[x, {xmin, xmax}] // PiecewiseExpand and Clip[x, {3, Infinity}] // PiecewiseExpand $\endgroup$
    – Bob Hanlon
    Jul 1, 2016 at 15:46
  • $\begingroup$ Cheers, turns out Min[al[x],al[3]] works as well in my particular case $\endgroup$
    – user40834
    Jul 1, 2016 at 16:48

Your Answer

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

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