Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Improve simplification of physical quantities #37

Closed
sharkdp opened this issue Mar 18, 2017 · 5 comments
Closed

Improve simplification of physical quantities #37

sharkdp opened this issue Mar 18, 2017 · 5 comments

Comments

@sharkdp
Copy link
Owner

sharkdp commented Mar 18, 2017

An input like

5Mbit/s * 2h

should be simplified to 36 Gbit, i.e. units of the same dimension should always be unified (here: second and hour). Similarly

5cm * 5m

should be simplified to either 0.25m² or 2500cm²

This is related to sharkdp/purescript-quantities#16

@itdaniher
Copy link

Possibly related:

Welcome to insect. Type '?' if this is your first visit.
> 1 watt -> joules
Cannot unify unit 'W' with unit 'J'
> joules
1J
> watt
1W

compare to gnu units expansion and simplification:

You have: 1 watt
You want: 1 joule
conformability error
        1 kg m^2 / s^3
        1 kg m^2 / s^2
You have: 1 watt
You want:
        Definition: 1 kg m^2 / s^3
You have: 1 joule
You want:
        Definition: 1 kg m^2 / s^2

the latter explains this issue at hand and relates it to physical quantities, allowing a user to debug their expression.

This is by far my favorite feature of gnu units and make-or-break for a CAS-like system that offers dimensional analysis and unit conversion.

Definitely interesting work overall, I would love to see this replace connectbot + gnu units or wolfram for basic engineering math.

Regards!

@sharkdp
Copy link
Owner Author

sharkdp commented Mar 21, 2017

@itdaniher That's a cool feature, indeed! Thank you for the feedback... I think this is something that could be implemented rather easily.

@itdaniher
Copy link

Happy to share! I'll be keeping an eye on this project for sure.

sharkdp added a commit that referenced this issue Mar 24, 2017
@sharkdp
Copy link
Owner Author

sharkdp commented Mar 24, 2017

@itdaniher This feature is now supported:

> 1 watt -> joules
Unification error:
  Cannot unify unit W (base units: m²·g/s³)
          with unit J (base units: m²·g/s²)

> g0 * 40s + 5m
Unification error:
  Cannot unify unit m (base units: m)
          with unit m/s (base units: m/s)

@sharkdp
Copy link
Owner Author

sharkdp commented Mar 30, 2017

Simplification is now supported:

>>> 5Mbit/s * 2h

  (5Mbit / s) × 2h

   = 36000Mbit

>>> 5cm * 5m

  5cm × 5m

   = 2500cm²

>>> 120km/h * 2min

  (120km / h) × 2min

   = 4km

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants