Saturday, November 17, 2018

TI-84+ and Casio (fx-CG 50) Micropython: Simplifying Nested Radicals

TI-84+ and Casio (fx-CG 50) Micropython: Simplifying Nested Radicals

Introduction 

The following program will simplifying the following expression:

√(x + y) = √a + √b

The input is x and y, with output a and b.  The following conditions are implied:  x > y and x > 0.

To see the derivation of simplification and examples, please check out this blog entry:

https://edspi31415.blogspot.com/2018/11/simplifying-nested-radicals.html

TI 84 Plus Program:  DENEST

"EWS 2018-11-12"
Disp "√(X+Y)=√(A)+√(B)","X>Y","X>0"
Prompt X,Y
X/2+1/2*√(X^2-Y^2)→A
X/2-1/2*√(X^2-Y^2) →B
√(A)→Z
round(Z,9)→Z
Disp " "

If Y<0 font="">

Then
If fPart(Z)=0
Then 
Disp √(A),"- √(",B,")"
Else 
Disp "√(",A,")- √(",B,")"
End

Else
If fPart(Z)=0
Then 
Disp √(A),"+ √(",B,")"
Else 
Disp "√(",A,")+ √(",B,")"
End

End

Casio Micropython (fx-CG 50) Script denest.py

Input is the form of:

√(x1 * √x2 + y1 * √y2) = √a + √b

import math
print("sqrt(x+y)=")
print("sqrt(a)+sqrt(b)")
print("x>y","x>0")

print(" ")
print("x1*sqrt(x2)")
x1=float(input("x1:"))
x2=float(input("x2:"))
x=x1*math.sqrt(x2)

print(" ")
print("y1*sqrt(y2)")
y1=float(input("y1:"))
y2=float(input("y2:"))
y=y1*math.sqrt(y2)

a=x/2+math.sqrt(x**2-y**2)
b=x/2-math.sqrt(x**2-y**2)
z=math.sqrt(a)
z=round(z,10)
a=round(a,10)
b=round(b,10)

if y<0: font="">
  if z-int(z)==0:
    print(z,"-sqrt(")
    print(b,"?")
  else:
    print("sqrt(",a)
    print("-sqrt(")
    print(b,")")
else:
  if z-int(z)==0:
    print(z,"+sqrt(")
    print(b,")")
  else:
    print("sqrt(",a)
    print("+sqrt(")
    print(b,")")


Source:

Michael J. Wester, Editor.  Computer Algebra Systems: A Practical Guide John Wiley & Sons: Chichester 1999.  ISBN 978-0-471-983538

Eddie

All original content copyright, © 2011-2018.  Edward Shore.   Unauthorized use and/or unauthorized distribution for commercial purposes without express and written permission from the author is strictly prohibited.  This blog entry may be distributed for noncommercial purposes, provided that full credit is given to the author.  Please contact the author if you have questions.

  Casio fx-7000G vs Casio fx-CG 50: A Comparison of Generating Statistical Graphs Today’s blog entry is a comparison of how a hist...