I have this algebraic expression

    x                       L                                             L 
    ⌠                       ⌠                                             ⌠  s
    ⎮ s*(L - x) f(s) ds   x ⎮ (L - s) f(s) ds                           Y ⎮ ---- ds
    ⌡                       ⌡                     L                       ⌡ f(s)
    0                       x                     ⌠ ⎛    s⎞               0 
1:  ------------------- + ------------------- = X ⎮ ⎜1 - -⎟ * f(s) ds + -----------
             L                     L              ⌡ ⎝    L⎠                  L

and I would like to substitute different expressions, e.g. sin(2 s) or (L -s ) s / 4, for f(s) and finally evaluate the integrals (it's as simple as pressing =) — but I don't know how to apply the requested substitution at once (I know how I could, painstakingly, change all the occurrences of f(s) one by one)

  • Does the menu item Calc -> Algebra -> Manipulation -> Make substitution not work? It just works for me for the algebraic expression int(s*(L-x)*f(s)/L,s,0,x)+int((L-s)*f(s)/L,s,x,L) with sin(s) substituted for f(s).
    – Tobias
    Jun 1, 2022 at 7:16

1 Answer 1


See the Calc manual on calc-substitute.


The ‘a b’ (‘calc-substitute’) [‘subst’] command substitutes all
occurrences of some variable or sub-expression of an expression with a
new sub-expression. For example, substituting ‘sin(x)’ with ‘cos(y)’ in
‘2 sin(x)2 + x sin(x) + sin(2 x)’ produces ‘2 cos(y)2 + x cos(y) +
sin(2 x)’. Note that this is a purely structural substitution; the lone
‘x’ and the ‘sin(2 x)’ stayed the same because they did not look like
‘sin(x)’. *Note Rewrite Rules::, for a more general method for doing

The ‘a b’ command normally prompts for two formulas, the old one and
the new one. If you enter a blank line for the first prompt, all three
arguments are taken from the stack (new, then old, then target
expression). If you type an old formula but then enter a blank line for
the new one, the new formula is taken from top-of-stack and the target
from second-to-top. If you answer both prompts, the target is taken
from top-of-stack as usual.

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.