3
$\begingroup$

From solving the PDE example of the general 1 dim heat equation in Nasser Abbasi's site https://www.12000.org/my_notes/pde_in_CAS/maple_2019_and_mma_12/insu157.htm#x182-1810003.1.1 (his problem No 151) I get the described solution containing the integral

Integrate[f[x] Sin[(\[Pi] x n)/L], {x, 0, L}, Assumptions -> k > 0 && L > 0]

Instead of this output form, how can I display this integral with the integral sign, as it is displayed in Nasser's site, not showing the assumptions? Neither StandardForm nor TraditionalForm does this. Is taking out (e.g. manually) the assumptions from Integrate's arguments the only way? How can I have Mathematica output the solution with the integral displayed with the integral sign and without the assumptions? Can the assumptions (any assumptions) be taken out automatically from Integrate's arguments, e.g. by some kind of replacement? I can't find out what this general replacement rule would have to be.

Thanks for help!

$\endgroup$
5
  • 1
    $\begingroup$ "Is taking out (e.g. manually) the assumptions from Integrate's arguments the only way?" - perhaps my definition of "manually" is a little different from yours, but: Integrate[f[x] Sin[(Pi x n)/L], {x, 0, L}, Assumptions -> k > 0 && L > 0] /. HoldPattern[Integrate][fun_, Longest[int : ({__} ..)], rest___] :> Integrate[fun, int]. If you wish, you could also employ Inactive[] somewhere. $\endgroup$ Feb 2, 2020 at 14:23
  • $\begingroup$ @J.M. This answers my question. Thanks a lot. $\endgroup$ Feb 2, 2020 at 17:58
  • $\begingroup$ @J.M. I don't think I understand your more elaborate pattern. Probably I'm overlooking something important. Would you mind explaining why it's needed? $\endgroup$
    – Mr.Wizard
    Feb 2, 2020 at 19:19
  • $\begingroup$ You might also use Interpretation: intForm[int : Verbatim[Integrate][f_, x : Except[_Rule] .., opts___Rule]] := Interpretation[ HoldForm[Integrate[f, x]], int]. Then integral // intForm. $\endgroup$
    – Michael E2
    Feb 2, 2020 at 20:50
  • $\begingroup$ @Mr.Wizard 1. I don't want Integrate[] on the LHS to evaluate. 2. I want the rule to also catch multivariate integrals like Integrate[f[x] g[y + a], {x, 0, 1}, {y, 0, 1}, Assumptions -> (a > 0)]. $\endgroup$ Feb 2, 2020 at 23:51

1 Answer 1

3
$\begingroup$

Depending on your needs consider $PrePrint and MakeBoxes. Something like this:

MakeBoxes[
  Integrate[a__, Assumptions -> _],
  fmt : TraditionalForm
] := MakeBoxes[Integrate[a], fmt]

Now when you view the integral in TraditionalForm:

Integrate[f[x] Sin[(n π x)/L], {x, 0, L}, 
  Assumptions -> k > 0 && L > 0] // TraditionalForm

$$\int_0^L f(x) \sin \left(\frac{\pi n x}{L}\right) \, dx$$

And TeXForm works too because by default is uses TraditionalForm:

Integrate[f[x] Sin[(n π x)/L], {x, 0, L}, 
  Assumptions -> k > 0 && L > 0] // TeXForm
\int_0^L f(x) \sin \left(\frac{\pi  n x}{L}\right)\, dx
$\endgroup$
2
  • $\begingroup$ Thanks a lot for your answer. This kind of global solution is indeed most appropriate for my needs. $\endgroup$ Feb 3, 2020 at 13:31
  • $\begingroup$ @RolandSalz Happy to help. Let me know if you have problem using this and I'll try to fix it. $\endgroup$
    – Mr.Wizard
    Feb 4, 2020 at 4:38

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.