Does anyone have a routine that takes, for example √7.4 and outputs (√185)/5

so basically: √X -> (A√B)/C

Simplifiying radicals

Forum
» Programming & Design / TI-83/84 Programming
» Simplifiying radicals

Simplifiying radicals

12Me21 08 May 2015 14:04

```
Input "√(",X
{1,abs(X
Repeat E‾9>Ans(2
abs(Ans(2){1,fPart(Ans(1)/Ans(2
End
round({X,1}/Ans(1),0→L1
prod(Ans→B
1→A:2→I
While I²≤B
While not(fPart(B/I²
B/I²→B
AI→A
End
I+1+(I>2→I
End
Disp A,"√(",B,"/",L1(2
```

Awesome!

It would be better if the output was like:

A√B

C

While 1

*code*

If A≠1

Output(2,1,A

If B≠1

Then

Output(2,2+iPart(log(A))-(A=1),"√(

Output(2,3+iPart(log(A))-(A=1),B

End

If L_{1}(2)≠1

Output(3,round(log(A)+log(B)+3)/2,0),L_{1}(2

Pause

End

Here is the complete program:

```
Input "√(",X
{1,abs(X
Repeat E‾9>Ans(2
abs(Ans(2){1,fPart(Ans(1)/Ans(2
End
round({X,1}/Ans(1),0→L1
prod(Ans→B
1→A:2→I
While I²≤B
While not(fPart(B/I²
B/I²→B
AI→A
End
I+1+(I>2→I
End
ClrHome
If A≠1
Output(2,1,A
If B≠1
Then
iPart(log(A))-(A=1
Output(2,2+Ans,"√(
Output(2,3+Ans,B
End
If 1≠L1(2
Then
3+iPart(log(A))+iPart(log(B
Output(3,round(Ans/2,0),L1(2
End
Pause
```

Does it simplify the fraction at the end?

like if it was

20√23

200

it would convert to

√23

10

This will simplify the fraction:

```
ClrHome
A→L1(1
L1/gcd(L1(1),L1(2→L1
Ans(1
If Ans≠1
Output(2,1,Ans
If B≠1
Then
iPart(log(A))-(A=1
Output(2,2+Ans,"√(
Output(2,3+Ans,B
End
If 1≠L1(2
Then
3+iPart(log(A))+iPart(log(B
Output(3,round(Ans/2,0),L1(2
End
Pause
```

I think this decimal to fraction code is better than the current one that were using:

```
:ClrHome
:Input "√(",X:1→B
:While fPart(A
:10A→A:10B→B
:End
:{A,B}/gcd(abs(A),B→L₁
:prod(Ans→B
:1→A:2→I
:While I²≤B
:While not(fPart(B/I²
:B/I²→B
:AI→A
:End
:I+1+(I>2→I
:End
:A→L1(1
:L1/gcd(L1(1),L1(2→L1
:Ans(1
:If Ans≠1
:Output(2,1,Ans
:If B≠1
:Then
:iPart(log(A))-(A=1
:Output(2,2+Ans,"√(
:Output(2,3+Ans,B
:End
:If 1≠L1(2
:Then
:3+iPart(log(A))+iPart(log(B
:Output(3,round(Ans/2,0),L1(2
:End
:Pause
```

/forum/t-1190671/simplifiying-radicals#post-