Qalculate / libqalculate

Qalculate! library and CLI
https://qalculate.github.io/
GNU General Public License v2.0
1.9k stars 151 forks source link

Strange behavior of Norm and Magnitude when applied to column vectors #528

Closed smm9509 closed 1 year ago

smm9509 commented 1 year ago

In Qalculate! QT: (ver 4.6.0)

magnitude([1um,1um,1um])
--
#7 | ≈ 1.7321 μm
magnitude([1um;1um;1um])
#6 | ≈ 1.7321 × √([(1 μm)]2)
norm([1um;1um;1um])
--
#15 | ≈ 1.7321 × √([(1 μm)]2)
norm([1um,1um,1um])
#14 | ≈ 1.7321 μm

In GNU Octave:

>> norm([1,1,1])
ans = 1.7321
>> norm([1;1;1])
ans = 1.7321

I'm not sure which answer is correct, but I would prefer for norm to operate on column vectors and row vectors as if they were identical.

smm9509 commented 1 year ago

While trying to test this on Ubuntu, I wanted to try putting the queries from above into libqalculate's qalc, but I noticed that my version of qalc is horribly outdated. It seems like the qalc in my $PATH (/usr/bin/qalc ) is provided by an old apt package, while Qalculate! Qt is provided by an up-to-date Flatpak. Is there a way to access the newest qalc that is probably contained somewhere inside the Flatpak? based on this discussion, it might not be possible

hanna-kn commented 1 year ago

Fixed.

Is there a way to access the newest qalc that is probably contained somewhere inside the Flatpak?

flatpak run --command=qalc io.github.Qalculate.qalculate-qt

smm9509 commented 1 year ago

I just noticed that a similar problem occurs with the dot product, but I hope that the fix applies to both operations so you don't have more work to do.

> AFuv := [(−0.747 41)  (0.664 36)  0.0000]

  save([−0.74741  0.66436  0],
  AFuv) =
  [−0.74741  0.66436  0]

> dot([0,−2.7,0]m,AFuv)

  dot([0  −2.7  0] meters, AFuv)
  =
  −1.793772 m

> dot([0;−2.7;0]m,AFuv)

  dot([0; −2.7; 0] meters, AFuv)
  =
  [(−1.793772 m)]
smm9509 commented 1 year ago

This is fixed in the latest version, thanks!