nerdamer
nerdamer copied to clipboard
Exponentiation and common logarithms
For 1.0, I suggest a few breaking changes: log(x) => ln(x) log10(x) => log(x) log(x,base) => log(base,x) //Maybe? This will hopefully avoid future confusions like #231.
much of the library is committed to log.
The core is going to get a rewrite anyways so why not do this at the same time? (Maybe I will send a PR myself for this)
Now for the big thing. I don't have a lot of time to clean this up so sorry for this unorganised table.
| Given | Expected | Do | ne? |
|---|---|---|---|
| solve(10^x=40,x) | [log(40)] | ||
| solve(10^x=0.5,x) | [log(0.5)] | ||
| solve(log(x)=0.78,x) | [10^0.78] | ||
| solve(log(x)=-1.55,x) | [1/10^1.55] | ||
| solve(ln(x)=1,x) | [e] | ||
| solve(ln(x)=-1,x) | [1/e] | ||
| log(25)+log(400) | 4 | ||
| log(20)-log(1/5) | 2 | ||
| log(81)/log(243) | 4/5 | ||
| log(27)/log(sqrt(3)) | 6 | ||
| log(8)+log(625)-log(5) | 3 | ||
| log(3)-log(4)-log(75) | -2 | ||
| log(300) | 2+log(3) | ||
| log(1/sqrt(3)) | -log(3)/2 | ||
| log(1/4) | -2log(2) | ||
| log(sqrt(8)) | 3/2log(2) | ||
| log(54) | 2log(3)+1-log(2) | ||
| log(240) | 3log(2)+log(3)+1 | ||
| log(108) | 2log(2)+3log(3) | ||
| log(sqrt(48)) | 2log(2)+log(3)/2 | ||
| log(x^3)/log(x^(1/3));x>0,x<>1 | 9 | ||
| 2log(x^8)-4log(x^4);x>0 | 0 | ||
| (log(x^2)-log(sqrt(x)))/log(1/x);x>0,x<>1 | -3/2 | ||
| solve(log(3x-2)=2,x) | [34] | ||
| solve(log((7-3x)/3)=0,x) | [4/3] | ||
| solve(log((2-x)/(3+4x))=-1,x) | [17/14] | ||
| solve(sqrt(10)^x=9.2,x) | [2log(9.2)] | ||
| solve(3^(x+1)=8,x) | [3log(2)/log(3)-1] |
More coming tomorrow...
Switching from log to ln is not just a breaking change for the library but for outside of the library as well. Currently the library, for the most part, is compatible with other libraries. This would change that. One solution I can think of is to give the option of setting a default for the log and log10 functions through the set function using a flag. The library would then be referencing these values internally.
I don't understand why most libraries out there use log as the natural log instead of the common log. Why define the log in a new way that does not match Mathematics?
Anyways, the setting you suggested is still a viable solution.
| Given | Expected | Do | ne? |
|---|---|---|---|
| solve(4(7^(2x))=15,x) | [~~(1+log(3)-3log(2))/(2log(7))~~ (-2 log(2) + log(3) + log(5))/(2 log(7))] | ||
| solve(5^(x-2)=3^x,x) | [~~(2-2log(2))/(1-log(2)-log(3))~~ (2 log(5))/(-log(3) + log(5))] | ||
| solve(5^(3x)=4^(2x-1),x) | [(2log(2))/(7log(2)-3)] | ||
| solve(log(x*y)=2,y) | [100/x] | ||
| solve(log(y)/log(x)=1/3,y) | [x^(1/3)] |
Note: log(5) =log(10/2) =log(10)-log(2) =1-log(2)
Always convert log(5) to 1-log(2) for better simplification.
@Happypig375, I'm not sure where the solutions in the table above come from but they appear to be incorrect. Additionally I'd like to point out that univariate equations do have numerical solutions but I'm guessing you're looking for algebraic solutions.
I don't remember if I used Wolfram Alpha or did the math myself. I might have done the math incorrectly. Just maybe.
No biggie. I'll verify them with Wolfram Alpha also.