0
$\begingroup$

I'm rather new to Mathematica so there might be an easy solution but I couldn't find it in another forum. I have an integral that will probably require numerical approximation as Mathematica can't solve it directly.

My Code is

xFunction[x_] = (.01 + .3x)/(2*(2 + 3.2*x - 2.39*(x^2)))
$Assumptions = x <= 0.7
$Assumptions = x >= 0.3
MyIntegral = Integrate[(Tanh[Y]^2)*(xFunction[x] - Y)^(1/6), {Y, .3, x}]

Do I need to define x as a real number? The end goal is to take the values of x on 0.3<x<.7 and graph it which x as the independent variable on the x-axis and MyIntegral as the dependent variable on the y-axis. Y is just a dummy variable so it shouldn't matter. I'm sure it's just a few lines of code but I can't seem to figure it out. Any help would be appreciated!

$\endgroup$
4
  • 1
    $\begingroup$ Please include the full definition of Cfunction and C. $\endgroup$
    – MarcoB
    Commented Jan 28, 2022 at 3:09
  • 1
    $\begingroup$ It is good practice to avoid using single capital letters as variable names in Mathematica (in particular, avoid C, since it has special meaning in Wolfram Language). Changing C to c and defining a test polynomial CFunction[x_] := 3 x^2 - 5 x^3, I do get a numerical result: With[{c = 0.6}, NIntegrate[(Tanh[Y]^2)*(CFunction[Y] - Y)^(1/6), {Y, .3, c}]] $\endgroup$ Commented Jan 28, 2022 at 4:25
  • 1
    $\begingroup$ Do you mean (xFunction[x] - Y) in the integrand and not (xFunction - Y)? $\endgroup$
    – Michael E2
    Commented Jan 28, 2022 at 6:19
  • 1
    $\begingroup$ It has nothing to do with x. The integral Integrate[(Tanh[Y]^2)*(Y)^(1/6), Y] does not evaluate analytically. Need to use Numerical integration as shown above. $\endgroup$
    – Nasser
    Commented Jan 28, 2022 at 8:09

1 Answer 1

0
$\begingroup$

By this point, you have done most of the work already. Use NIntegrate instead of Integrate for numerical integration. I also changed = to := in the definition of xFunction, and lastly, defined MyIntegral to be another function:

xFunction[x_] := (.01 + .3 x)/(2*(2 + 3.2*x - 2.39*(x^2)))
MyIntegral[x_] := NIntegrate[(Tanh[Y]^2)*(xFunction[x] - Y)^(1/6), {Y, .3, x}]

Now, this produces complex numbers for $x\in [0.3,0.7]$. So, instead of Plot, I use ReImPlot:

ReImPlot[MyIntegral[x], {x, 0.3, 0.7}]

and obtainenter image description here

$\endgroup$

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.