在任何编程语言中的非数字表示? [英] Irrational number representation in any programming language?

查看:329
本文介绍了在任何编程语言中的非数字表示?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

有人知道在任何编程语言中有无理数字表示类型/对象/类/任何东西吗?



欢迎所有建议。 / p>

简单地说,如果我有两个非理性对象,都代表五的平方根,我将这些对象相乘,我想得到整数五,而不是float 4



具体来说,我需要表示法能够收集条款,而不仅仅是每次都解析为整数/浮点数。例如,如果我想添加五的平方根到一,我不想它返回一些近似integer / float,我想它返回一个对象,我可以添加/乘以另一个无理的对象,如我可以告诉对象在最近的时间解决,以最小化浮点近似误差。



非常感谢!

解决方案

您正在寻找的是称为符号数学。你可能想尝试一些计算机代数系统,如Maxima,Maple或Mathematica。还有用于此目的的库,例如用于Python的 SymPy 库。


Does anyone know of an irrational number representation type/object/class/whatever in any programming language?

All suggestions welcome.

Simply put, if I have two irrational objects, both representing the square root of five, and I multiply those objects, I want to get back the integer five, not float 4 point lots o' 9s.

Specifically, I need the representation to be able to collect terms, not just resolve every time to an integer/float. For instance, if I want to add the square root of five to one, I don't want it to return some approximation integer/float, I want it to return an object that I can add/multiply with another irrational object, such that I can tell the object to resolve at the latest time possible to minimize the float approximation error.

Thanks much!

解决方案

What you are looking for is called symbolic mathematics. You might want to try some computer algebra system like Maxima, Maple or Mathematica. There are also libraries for this purpose, for example the SymPy library for Python.

这篇关于在任何编程语言中的非数字表示?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆