I am trying to take natural log (edittext1.text) using complexe library with following syntax
dim ln as complexe
ln=ln.log(edittext1.text)
or
variable=ln.log(edittext1.text)
or
variable=edittext1.text.log()
nothing works
it gives an error
anyone had tried this library or function then plz guide me
Dim ln As complexe
Dim real, imag As Double
' parse your real and imaginary parts into doubles
real = 1.1
imag = 2.2
ln.setComplexe(real, imag)
ln = ln.log
Dim res As String = ln.Re & "+i" & ln.Im
Dim ln As complexe
Dim real, imag As Double
' parse your real and imaginary parts into doubles
real = 1.1
imag = 2.2
ln.setComplexe(real, imag)
ln = ln.log
Dim res As String = ln.Re & "+i" & ln.Im
B4A has a native built in Log function. So, you can use this code:
B4X:
Sub Button1_Click
Dim const e As Double = 2.718281828459
EditText2.Text = Logarithm(EditText1.Text,10)
EditText3.Text = Logarithm(EditText1.Text,e)
The results on the screen should thus look like:
I don't know if the "e" constant is built in some place, but the above shows a log base 10 (used that in high school), and then we do a natural log based on the e constant.
So, above should work just fine. I did not even have to do a type conversion from the "text" value in the edit text boxes, but one should consider setting the format of the text box to number.
Regards,
Albert D. Kallal
Edmonton, Alberta Canada
I am not sure if the/your problem was using only one text box for both numbers, or using that libary?
So, this would work:
B4X:
Dim cX As complexe
Dim cXLog As complexe
Dim strArray() As String = Regex.Split(",",EditText1.text)
cX.setComplexe(strArray(0),strArray(1))
cXLog = cX.log
EditText2.Text = cXLog.Re ' show real part (log(e))
EditText3.Text = cXLog.Im ' show imaginary part (log(e))
So, the complex parts (real, imaginary) parts can be feed from one text box, we assume a "," between the two values.
If screen real estate is not at a preimum? I would go with two EditText boxes on the screen - not one text box.