Group Abstract Group Abstract

Message Boards Message Boards

0
|
4.4K Views
|
4 Replies
|
2 Total Likes
View groups...
Share
Share this post:

How can I get FindRoot to work with units?

Posted 2 years ago
POSTED BY: James Bowery
4 Replies
Posted 2 years ago

Hm, right. It really seems like it cannot deal with a multivariable problem ... Here is a simpler example that produces the same error message:

FindRoot[{x == Quantity[1, "Seconds"], 
  y == Quantity[2, "Meters"]}, {{x, Quantity[3, "Seconds"]}, {y, 
   Quantity[4, "Meters"]}}]
(* FindRoot::nlu: -- Message text not found -- 
  ({3.s,4.m}) ({x,y}) ({2.s,2.m}) ({2}) (Removed[$$Failure]) *)
POSTED BY: Domen V
Posted 2 years ago

Thanks for finding a minimal example.

POSTED BY: James Bowery
Posted 2 years ago

Then perhaps I've found a bug in Mathematica's handling of Units with FindRoot because here's the opaque error message ("Message text not found") that appears when I don't strip off the Units with QuantityMagnitude:

enter image description here

POSTED BY: James Bowery
Posted 2 years ago

FindRoot does work with Quantity, but you have to provide the appropriate units for the variables. You can read the tutorial on Numerical Calculations with Units, which also provides an example:

FindRoot[1/
  2 (t^2 (Quantity[-9.8, ("Meters")/("Seconds")^2]) + 
    Quantity[200, "Meters"]), {{t, Quantity[1, "Seconds"]}}]

(* {t -> Quantity[4.51754, "Seconds"]} *)
POSTED BY: Domen V
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard