0
$\begingroup$

Sorry if this is a newbie question, but I could not find a solution.

Say I have two functions, like:

A[x_, y_] := x + y^2;
B[a_, b_] := Integrate[A[x, 1], {x, b, 2}];

How would I go about printing the function B?

Actual output:

B

Ideal output:

4 - b - (b ^ 2) / 2

Basically I'd like to print the body of the function in simplified format, expanding my function calls and integration.

$\endgroup$
2
$\begingroup$
?? A

(*

A[x_,y_]:=x+y^2

*)

?? B

B[a_,b_]:=!( *SubsuperscriptBox[([Integral]), (b), (2)](A[x, 1] [DifferentialD]x))

or just A[x,y], which gives:

$x + y^2$

Never use upper-case letters for functions or variables, since they are likely to conflict with Mathematica's internal symbols.

Also, you define B as an integral, so that is the function. If you want to evaluate that first, you must do:

B[a, b]

$-\frac{b^2}{2}-b+4$

$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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