In a Wolfram Notebook,

I declare a function F1[x]=1/x where x is in "Meters"

F1[X_] = With[{x=Quantity[X,"Meters"]},1/x]

I integrate F1. Everything is Ok.


But with the function F2[x]=1/(1-x)

F2[X_] = With[{x=Quantity[X,"Meters"]},1/(1-x)]

Integrating F2 gives an error.


"NIntegrate :NIntegrate was unable to determine the units of quantities that appear in the input."

How can I set units for a function of the type 1/(1-x) and integrate it?

  • 1
    $\begingroup$ What the message is telling you is that the expression $1-2\mathrm{m}$ doesn't make any sense: you cannot subtract meters from a number. You'll have to add the appropriate unit to the $1$ in the denominator as well $\endgroup$
    – Lukas Lang
    Commented Apr 13 at 11:17
  • $\begingroup$ Thta's right! Thanks a lot for your help! $\endgroup$ Commented Apr 13 at 13:04

1 Answer 1


Based on @Lukas's comment, I've modified my function to F3 like this:


Then, the integration gives a result value with the unit.



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.