how i convert (0.345346329292023) to 1-sqrt(3/7)

3 visualizaciones (últimos 30 días)
sadeem alqarni
sadeem alqarni el 21 de Mzo. de 2018
Comentada: sadeem alqarni el 5 de Abr. de 2018
how i convert (0.345346329292023) to 1-sqrt(3/7)
  3 comentarios
sadeem alqarni
sadeem alqarni el 21 de Mzo. de 2018
Yes I want the method to take some arbitrary value
Walter Roberson
Walter Roberson el 21 de Mzo. de 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.

Iniciar sesión para comentar.

Respuestas (2)

James Tursa
James Tursa el 21 de Mzo. de 2018
Editada: James Tursa el 21 de Mzo. de 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 comentario
John D'Errico
John D'Errico el 21 de Mzo. de 2018
Editada: John D'Errico el 21 de Mzo. de 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.

Iniciar sesión para comentar.


sadeem alqarni
sadeem alqarni el 22 de Mzo. de 2018
Editada: Stephen23 el 22 de Mzo. de 2018
syms y(x) aj xn h yn yn2 fn fn2 fn1 a0 a1 a2 a3 a4 a(j) t k x q1 r fnr yn1 s fn2 fns rr
m=[1,xn,xn^2,xn^3,xn^4,xn^5,xn^6;
1,xn+h,(xn+h)^2,(xn+h)^3,(xn+h)^4,(xn+h)^5,(xn+h)^6;
0,0,2,6*xn,12*xn^2,20*xn^3,30*xn^4;
0,0,2,6*(xn+r*h),12*(xn+r*h)^2,20*(xn+r*h)^3,30*(xn+r*h)^4;
0,0,2,6*(xn+h),12*(xn+h)^2,20*(xn+h)^3,30*(xn+h)^4;
0,0,2,6*(xn+s*h),12*(xn+s*h)^2,20*(xn+s*h)^3,30*(xn+s*h)^4 ;
0,0,2,6*(xn+2*h),12*(xn+2*h)^2,20*(xn+2*h)^3,30*(xn+2*h)^4]
b=[yn;yn1;fn;fnr;fn1;fns;fn2]
z=[a(0);a(1);a(2);a(3);a(4);a(5);a(6)]
z==m\b
w=[1,x,x^2,x^3,x^4,x^5,x^6]
y=(w*(m\b))
y2=subs(y,x,(xn+t*h))
r1=simplify(collect(y2,[fn,fnr,fn1,fns,fn2]))
[c,q] = coeffs(r1, [ yn,yn1,fns,fnr,fn1,fn,fn2])
c1=simplify(c)
y22=subs(r1,t,2)
[c2,q]=coeffs(y22,[ yn,yn1,fns,fnr,fn1,fn,fn2])
c3=simplify(c2)
f=diff(y2,t)
y33=subs(f,t,2)
[c4,d]=coeffs(y33,[ yn,yn1,fns,fnr,fn1,fn,fn2])
c5=simplify(c4)
y44=subs(r1,t,1)
[c6,q]=coeffs(y44,[ yn,yn1,fns,fnr,fn1,fn,fn2])
c7=simplify(c6)
f=diff(y2,t)
y55=subs(f,t,1)
[c8,d]=coeffs(y55,[ yn,yn1,fns,fnr,fn1,fn,fn2])
c9=simplify(c8)
y66=subs(r1,t,s)
[c10,q]=coeffs(y66,[ yn,yn1,fns,fnr,fn1,fn,fn2])
c11=simplify(c10)
f=diff(y2,t)
y77=subs(f,t,s)
[c12,d]=coeffs(y77,[ yn,yn1,fns,fnr,fn1,fn,fn2])
c13=simplify(c12)
y88=subs(r1,t,r)
[c14,q]=coeffs(y88,[ yn,yn1,fns,fnr,fn1,fn,fn2])
c15=simplify(c14)
f=diff(y2,t)
y99=subs(f,t,r)
[c16,d]=coeffs(y99,[ yn,yn1,fns,fnr,fn1,fn,fn2])
c17=simplify(c16)
y100=subs(r1,t,0)
[c18,q]=coeffs(y100,[ yn,yn1,fns,fnr,fn1,fn,fn2])
c19=simplify(c18)
f=diff(y2,t)
y101=subs(f,t,0)
[c20,d]=coeffs(y101,[ yn,yn1,fns,fnr,fn1,fn,fn2])
c21=simplify(c20)
zz=simplify(subs(y22,{r,s},{sym('1-sqrt(3/7)'),sym('1+sqrt(3/7)')}))
zz1=simplify(subs(y22,{r,s},{0.345346329292023,1.654653670707977})
how i make the output of zz1 equal to zz for any values????
  2 comentarios
Walter Roberson
Walter Roberson el 22 de Mzo. de 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});
sadeem alqarni
sadeem alqarni el 5 de Abr. de 2018
true... thank you so much

Iniciar sesión para comentar.

Categorías

Más información sobre Creating, Deleting, and Querying Graphics Objects en Help Center y File Exchange.

Etiquetas

Community Treasure Hunt

Find the treasures in MATLAB Central and discover how the community can help you!

Start Hunting!

Translated by