寻找正方形的正方形形式

发布于 2025-02-09 16:26:09 字数 376 浏览 1 评论 0原文

我正在尝试构建一个程序,让您乘以两个正方形的根,并以Surd形式显示答案,如果答案不是整数。

我已经看过答案在这里 a href =“ https://stackoverflow.com/questions/10492855/10492855/simplify-square-roots-algebraily'>在这里,尽管我不了解C ++和C#,所以我对该怎么办。我完成的第一件事是将正方形根部内的两个数字乘以在一起,然后如果是整数,我可以显示答案,但是如果不是,它就完全混乱了。

I'm trying to build a program that let's you multiply two square roots and display the answer in surd form if the answer isn't an integer.

I've seen answers here and here, although I don't understand C++ and C#, so I don't have a clue on what to do. The first thing I've done is multiply the two numbers inside the square roots together, then I can display the answer if it is an integer, but if it isn't it completely messes up.

如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

游魂 2025-02-16 16:26:09

我看不到考虑给定数字,总结主要因素的多重性,提取偶数的多个部分并形成产品的平方根。

例如

√(84.375)=√(2²3.7.3.5³)=√(2²3²5³7)=2.3.5√(5.7)=30√35

I don't see a better way than by factoring the given numbers, summing the multiplicities of the prime factors, extracting the even parts of the multiplicities and forming the square root of the products.

E.g.

√(84.375)=√(2²3.7.3.5³)=√(2²3²5³7)=2.3.5√(5.7)=30√35
心的位置 2025-02-16 16:26:09

尝试使用 sympy

>>>import sympy
>>>sympy.sqrt(8)
2*sqrt(2)

Try using SymPy:

>>>import sympy
>>>sympy.sqrt(8)
2*sqrt(2)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文