fb:porticula NoPaste
t_logexp.bas
Uploader: | Volta |
Datum/Zeit: | 30.09.2010 20:41:33 |
'PROGRAM test_longlog_longexp
' Tests:
' 1. log(x^2) = 2.*log(x)
' 2. e^(2x) = (e^x)^2
#Include "quad_1x.bi"
Using quad_precision
Dim As quad x, lhs, rhs, diff
Dim As Integer i
Screen 0
Width 104,32
Color 15,1
Cls
Randomize 4711
For i = 1 To 15
x.hi=Rnd
x.hi = (x.hi - 0.5) / x.hi
x.lo = x.hi * 1.0e-16
' log(x^2) = 2.*log(x)
lhs = Log(x * x)
If (x.hi > 0.0) Then
rhs = Log(x)
Else
rhs = Log(-x)
End If
rhs = 2.0 * rhs
diff = lhs - rhs
Print "log(x^2) lhs ="; lhs, " Diff. ="; diff
' e^(2x) = (e^x)**2
lhs = 2.0 * x
lhs = Exp(lhs)
rhs = Exp(x)
rhs = rhs * rhs
diff = lhs - rhs
Print "e^(2x) lhs ="; lhs, " Diff. ="; diff
Next
Sleep