how i convert (0.345346329292023) to 1-sqrt(3/7)
6 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
how i convert (0.345346329292023) to 1-sqrt(3/7)
3 commentaires
Walter Roberson
le 21 Mar 2018
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.
Réponses (2)
James Tursa
le 21 Mar 2018
Modifié(e) : James Tursa
le 21 Mar 2018
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 commentaire
John D'Errico
le 21 Mar 2018
Modifié(e) : John D'Errico
le 21 Mar 2018
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
le 22 Mar 2018
Modifié(e) : Stephen23
le 22 Mar 2018
2 commentaires
Walter Roberson
le 22 Mar 2018
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});
Voir également
Catégories
En savoir plus sur Creating, Deleting, and Querying Graphics Objects dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!