With this code

x = 2*Cos[t]; 
y = 3*Sin[t];
4*Integrate[y, {x, 0, 2}]

Mathematica complains that Integrate::ilim: Invalid integration variable or limit(s) in {2\Cos[t],0,2} .

and the output is

4*Integrate[3*Sin[t], {2*Cos[t], 0, 2}]

How can I make Mathematica calculate as the following?

$$d(2\cos t)=-2\sin t~dt$$

  • $\begingroup$ Invalid integration variable this is because your integration variable is 2*Cos[t]. This not a variable. The integration variable needs to be a symbol. How can I make Mathematica calculate as the following? $$d(2\cos t)=-2\sin t~dt$$ You can not really write this in any CAS I know about. ie. not as a single differential like this. Why do you need to write this in first place as a Mathematica expression? If you show what you are trying to do may be there is a workaround. $\endgroup$
    – Nasser
    Commented Jun 10, 2023 at 21:54
  • $\begingroup$ @Nasser The example code in the beginning is the kind of thing that would be nice if Mathematica could handle it. $\endgroup$
    – xiver77
    Commented Jun 10, 2023 at 21:57
  • $\begingroup$ The example code in the beginning is the kind of thing No, I meant what is the actual problem you are trying to solve in the first place which lead to this code. I assume you have some math problem you are trying to solve, before all this started. Right? If you could show that problem may be there is a way to do this without having to do what you are doing. i.e. alternative method which works. Not the one you showed since that does not work. $\endgroup$
    – Nasser
    Commented Jun 10, 2023 at 22:03
  • $\begingroup$ @Nasser I was actually checking my answer of calculating the area of an ellipse with Mathematica, comparing two different approaches and this was one of them. $\endgroup$
    – xiver77
    Commented Jun 10, 2023 at 22:22
  • $\begingroup$ Since both x and y are functions of t, the simplest thing to do is to express your problem in terms of t. You already know dx = -2 Sin[t] dt, and you know y, so all that's left is to convert your limits which are in terms of x, into the corresponding limits in t. As has already been pointed out, Mathematica currently doesn't do what you appear to want it to do, so this is probably your simplest option. $\endgroup$
    – user87932
    Commented Jun 11, 2023 at 2:03

2 Answers 2


It seems you wish to integrate $\int 3 \sin t \; dx = \int 3 \sin t \cdot (-2 \sin t) \, dt$ and not $\int 3 \sin t\, dt$ (from $x=0$ to $x=2$, of course). In that case, as others have noted, IntegrateChangeVariables[] is not set up to handle the transformation in the form you have; nor is any other function. However, it can be done in a couple of steps. The range of $t$ is ambiguous, so I picked $[0,\pi]$; adjust if needed.

sub = x == 2*Cos[t];
y = 3*Sin[t];
df = SolveValues[
  Eliminate[{int == y*Dt[x], sub, Dt[sub]}, {x, Dt[x]}], int]

(*  {-6 Dt[t] Sin[t]^2}  *)

df /. integrand_*HoldPattern@Dt[u_] :> 
   Flatten@{u, SolveValues[{sub, x == 0, 0 <= t <= Pi}, {t}, {x}], 
     SolveValues[{sub, x == 2, 0 <= t <= Pi}, {t}, {x}]}]

(* {(3 \[Pi])/2}  *)

Best advice: Stick to Leibniz/Euler/Lagrange differential calculus, keep the differentials and forget the Integrate.

$$\left\{\frac{\text{d$\phi $}}{\sqrt{1-k^2 \sin ^2(\phi )}},\{\phi ,a,b\}\right\}\text{/.}\, \left\{\sin (\phi ):\to x,\text{d$\phi $}:\to \text{dx} \,\left(\text{Sin}^{(-1)}\right)'\text{@@}\{x\},\{\phi \_,\text{a$\_$},\text{b$\_$}\}:\to \left\{x,\text{Sin}^{(-1)}\text{@@}\{a\},\text{Sin}^{(-1)}\text{@@}\{b\}\right\}\right\}$$

$$\left\{\frac{\text{dx}}{\sqrt{1-x^2} \sqrt{1-k^2 x^2}},\left\{x,\sin ^{-1}(a),\sin ^{-1}(b)\right\}\right\}$$

{d\[Phi]/Sqrt[1 - k^2 Sin[\[Phi]]^2] , {\[Phi], a, b}} /. 
 {Sin[\[Phi]] :> x, d\[Phi] :>  dx InverseFunction[Sin]' @@ {x}, 
 {\[Phi]_, a_, b_} :> 
      {x, InverseFunction[Sin] @@ {a}, InverseFunction[Sin] @@ {b} }}

Finally you can Apply


Never do replacements with targets inside complex procedures. Mostly they return the result and the replacemant rules don't work as expected.

Very late now Wolfram introduced Inactive, eg Inactive[Integrate], in order to keep notation and do algebra without interfering with integration procedures.


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.