1
$\begingroup$

I have a function u[y] and I want to find the limit of integration that integration is equal zero.

Λ = -30;
u[η_] := (2*η - 2*η^3 + η^4) + Λ/6*(η - 3*η^2 + 3*η^3 - η^4);
θ = Integrate[u[η]*(1 - u[η]), {, 0, 1}] // N;
δ = 1/θ;
u[y_] := Piecewise[{{1,y > δ}}, (2*y/δ - 2*(y/δ)^3 + (y/δ)^4) + Λ/6*
((y/δ) - 3*(y/δ)^2 + 3*(y/δ)^3 - (y/δ)^4)];

FindRoot[Integrate[u[y], {y, 0, yd}] , {yd, 5}]

I have the following error: "Unable to prove that integration limits {0,yd} are real. Adding assumptions may help."

$\endgroup$
1
  • $\begingroup$ you have a syntax error in the limits for the first integral. I took that to be a typo in the post, but could actually be the source of your error. $\endgroup$
    – george2079
    Commented Mar 1, 2018 at 18:34

2 Answers 2

1
$\begingroup$

the integral can be done for symbolic yd , so you should do that once before using FindRoot.

\[CapitalLambda] = -30;
u[\[Eta]_] := (2*\[Eta] - 2*\[Eta]^3 + \[Eta]^4) + \[CapitalLambda]/
     6*(\[Eta] - 3*\[Eta]^2 + 3*\[Eta]^3 - \[Eta]^4);
\[Theta] = Integrate[u[\[Eta]]*(1 - u[\[Eta]]), {\[Eta], 0, 1}]
\[Delta] = 1/\[Theta];
u[y_] := Piecewise[{{1, 
     y > \[Delta]}}, (2*y/\[Delta] - 
      2*(y/\[Delta])^3 + (y/\[Delta])^4) + \[CapitalLambda]/
      6*((y/\[Delta]) - 3*(y/\[Delta])^2 + 
       3*(y/\[Delta])^3 - (y/\[Delta])^4)];
f[yd_] = Integrate[u[y], {y, 0, yd}, Assumptions -> yd > 0]
FindRoot[f[x], {x, 10}]

( note not-delayed = for f )

x -> 9.01341

NSolve[f[x], x] works too:

{{x -> 0}, {x -> 9.01341}}

$\endgroup$
1
$\begingroup$
ClearAll["Global`*"]
 Λ = -30;
u[η_] := (2*η - 2*η^3 + η^4) + Λ/
     6*(η - 3*η^2 + 3*η^3 - η^4);
θ = Integrate[u[η]*(1 - u[η]), {η, 0, 1}] // N;
δ = 1/θ;
u[y_] := Piecewise[{{1, 
    y > δ}, {(2*y/δ - 
       2*(y/δ)^3 + (y/δ)^4) + Λ/
       6*((y/δ) - 3*(y/δ)^2 + 
        3*(y/δ)^3 - (y/δ)^4), True}}]
Assuming[yd ∈ Reals, 
 FindRoot[Integrate[u[y], {y, 0, yd}], {yd, 1}]]

{yd -> 6.20224*10^-9}

OR

Λ = -30;
u[η_] := (2*η - 2*η^3 + η^4) + Λ/
     6*(η - 3*η^2 + 3*η^3 - η^4);
θ = Integrate[u[η]*(1 - u[η]), {η, 0, 1}] // N;
δ = 1/θ;
u[y_] := Piecewise[{{1, 
    y > δ}, {(2*y/δ - 
       2*(y/δ)^3 + (y/δ)^4) + Λ/
       6*((y/δ) - 3*(y/δ)^2 + 
        3*(y/δ)^3 - (y/δ)^4), True}}]
Assuming[yd ∈ Reals, NSolve[Integrate[u[y], {y, 0, yd}], yd]]

{{yd -> 0}, {yd -> 9.01341}}

$\endgroup$
2
  • $\begingroup$ Do you want to convert the code to make it look better? Try:steampiano.net/msc $\endgroup$ Commented Mar 1, 2018 at 18:17
  • $\begingroup$ I always wonder how people do it, thanks for the tip. $\endgroup$ Commented Mar 1, 2018 at 18:20

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.