-
Notifications
You must be signed in to change notification settings - Fork 52
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
Probabilities can be truncated to 0.00000% in stateAsString(true) #86
Comments
@DanBlackwell thank you for reporting. Late answer, I know... Internal state is correct, it is truncated only when printed. qc.stateAsSimpleArray(); Returns: [
{ re: 1, im: 0 },
{ re: 0, im: -5e-11 }
] And: qc.stateAsArray(true); Returns: [
{
index: 0,
indexBinStr: '0',
amplitude: { re: 1, im: 0 },
amplitudeStr: ' 1.00000000+0.00000000i',
magnitude: 1,
chance: 100,
chanceStr: '100.00000',
phase: 0,
phaseStr: '0.00000'
},
{
index: 1,
indexBinStr: '1',
amplitude: { re: 0, im: -5e-11 },
amplitudeStr: ' 0.00000000+0.00000000i',
magnitude: 2.5000000000000002e-21,
chance: 2.5e-19,
chanceStr: '0.00000',
phase: -1.5707963267948966,
phaseStr: '-1.57080'
}
] Goal of However, it could be more informative if it prints something like:
OR:
Or do you have better idea? |
These look like good solutions to me; if the print formatting is to a fixed number of decimals places, I think the following may be more informative:
to me |
Oh yes, that's better solution for probability. Thanks. But, amplitude... We have real and imaginary part and adding any mark there will make it more confusing (especially for imaginary part). Maybe simply to keep amplitude unchanged and mark only probability:
|
Hmm, besides going to e-notation I'm not sure there really is a nice solution to this. If it were me, I'd be tempted to add a I think that as long as the documentation notes that this is possible, that's probably good enough imo. Looking at the documentation here, I initially thought that the |
Not necessarily an issue - perhaps an enhancement though. Due to the truncation (or maybe rounding - haven't looked behind the scenes) some probabilities (as well as vector values) for viable states end up being output as 0.
Example program:
Output:
The text was updated successfully, but these errors were encountered: