cube root in bc
As in bc manual, I got
Quote:
|
Strangely enough, I don't think it's possible, because it has to have an integer exponent, and even more strangely, it works fine in awk:
Code:
bash-3.1$ echo 64 | awk '{ print $1^(1/3) }' |
|
Quote:
|
Its not real messy... Basically..
x^y=e^(y * ln(x)) or echo "e(y*l(x))" | bc -l |
ah, thank you guys!
I tried michaelk's method but ran into some error and conclude, its not possible. thank you all. |
Quote:
Maybe if you explained your error someone might help? I have run the code and whilst there is a small rounding issue on my machine it does return an answer, all be it a very close approximation. |
Quote:
What i meant is i tried michaelk's method(and conclude the impossiblity) before posting in this forum. After getting his reply I retried and succeed. I am sorry if I hurt some one (michaelk or other who helped). Thank you |
After googling for bc third root the first suggestion was this thread .
I stumbled about two and a half problems : 1) Since I never had to use the -l --mathlib option to bc, I did not use it . 2) I wrongly read the letter ' small "L" ' at http://phodd.net/gnu-bc/bcfaq.html#bccbrt as it states Code:
echo 'e(l({number})/3)' | bc -l 3) I also used {number} or {27} instead of just 27 . Code:
bash-3.2# bc |
All times are GMT -5. The time now is 03:30 AM. |