how i convert (0.345346329292023) to 1-sqrt(3/7)
13 次查看(过去 30 天)
显示 更早的评论
how i convert (0.345346329292023) to 1-sqrt(3/7)
3 个评论
Walter Roberson
2018-3-21
The Maple programming language has a function named identify that tries to deal with these situations. If you happen to have Maple then in Maple command
kernelopts(opaquemodules=false);
showstat(identify:-isAlg);
to see the code.
回答(2 个)
James Tursa
2018-3-21
编辑:James Tursa
2018-3-21
I don't think you are going to be able to do this in general. The Symbolic Toolbox can help with some simple forms involving square roots, but recovering a radical form for an arbitrary number is probably too much to ask. Particularly since you aren't starting with an exact value of the radical form to begin with. E.g.,
>> sym(sqrt(3/7))
ans =
(3^(1/2)*7^(1/2))/7
>> sym(1-sqrt(3/7))
ans =
1555301599913323/4503599627370496
>> sym(nthroot(2,3))
ans =
5674179970822795/4503599627370496
It was able to recover the simple sqrt of an integer ratio, but once you throw in some additional arithmetic it "punts" and simply returns the equivalent rational fraction for the floating point value. It doesn't even recover the simple cube root of 2 either.
So, simple square root expressions it can recover, but anything beyond that probably not. There may be ways to manipulate things to get more help if you know something about the resulting radical form you expect, but you will probably never get a generic capability for arbitrary values like you seem to be asking for.
1 个评论
John D'Errico
2018-3-21
编辑:John D'Errico
2018-3-21
As James says, you can never intelligently recover some totally general form in terms of radicals. If you KNEW it was a pure sqrt, well, yes. But even something as simple as a sum of terms will be nearly impossible. Worse, put a cube root in there, and you are in deeper trouble yet.
Good luck, for example, in recovering the radical form that generated this number:
X =
0.27398020095128
Even if I told you that there are 4 terms in the expression that created it, it would take some serious computing time to recover the original expression I used. Worse, I could add that there are infinitely many variations on that expression that MIGHT have been involved, if you would allow me to get tricky.
sadeem alqarni
2018-3-22
编辑:Stephen23
2018-3-22
2 个评论
Walter Roberson
2018-3-22
Are your values always of the form A+/-sqrt(B/C) ? Will both numeric values always be available?
If we have
v1 = 0.345346329292023; v2 = 1.654653670707977;
then
V = sort([v1, v2]);
A = round(mean(V));
[B,C] = rat((V(2)-A).^2);
rBC = sqrt(sym(B)/sym(C));
zz1 = simplify(subs(y22, {r,s}, {sym(A)-rBC, sym(A)+rBC});
另请参阅
类别
在 Help Center 和 File Exchange 中查找有关 Data Type Conversion 的更多信息
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!