Maple simplification of ln expressions - maple

I want to have maple simplify 8ln(6) - 5ln(3) + 10ln(2) - 10ln(5) to ln(7077888/9765625). That is, ln(m/n) where m and n are positive integers. And I want the solution to work for similar expressions with many more terms.
I have tried combinations of expand, simplify, simplify(,ln), and combine. Combine almost works, but produces 40 ln(a/b) where a is the product of fractional powers of integers.
I can do this in sagemath, but would appreciate help doing this in maple.
Solution: What I really care about are the integers m,n. I don't understand why the following works (or is necessary):
a := 8ln(6) - 5ln(3) + 10ln(2) - 10ln(5);
a := 8 ln(6) - 5 ln(3) + 10 ln(2) - 10 ln(5)
combine(exp(%));
7077888
-------
9765625

Related

Why does `evalb(((3*x + 1)^5)(3*x - 1)/x^6 = ((3 + 1/x)^5)(3 - 1/x)) assuming (0 < x)` return `false` in Maple?

The question should perhaps be why does (3*x + 1)^5 * (3*x - 1) / x^6 = (3 + 1/x)^5 * (3 - 1/x) evaluate to false in Maple, even with the assumption that x > 0. The same expression evaluates to true in Mathematica and, of course, the statement itself is mathematically true under the previous assumption.
Maple's help pages don't give any clue on why this happens, and I would like someone to explain this behaviour before I think that Maple's evalb() is kind of broken. It is the type of questions I'm asking myself lately, since I'm deciding wether I should learn Maple or rather drop it and focus on learning Mathematica.
Thank you in advance.
If both sides of the equation are of type numeric (or extended complex numeric, etc), then evalb will test the equality. But for your symbolic expressions the evalb command will only test that they are the very same expression (by comparing memory address).
But they are not the very same expression. They are merely two different symbolic expressions for which you wish to do a mathematical test of equivalence.
restart;
expr:=(3*x+1)^5*(3*x-1)/x^6=(3+1/x)^5*(3-1/x):
is(expr);
true
testeq(expr);
true
simplify((rhs-lhs)(expr));
0

Convert polynomial expression to float coeffs

This might seem a dumb question but its been a few hours I search about it without really finding exactly what I'm seeking for.
In Maple, if you have a polynomial like this:
How do I convert this expression to an expression that has floating point coefficients (s^3 + 19s^2 + 89.13s + 71.13) within Maple?
This should just be embedded in the collect() function in my opinion (like a parameter 'float'). Right now I have to calculate myself each polynomial myself (only using Maple to simplify some lengthy calculations in a physics class), which is downright retarded.
Thanks!
There is no need to use (or introduce) any explicitly written float coefficient just to get your desired effect. And indeed you may have good reason to want to have all coefficients be exact, perhaps for some earlier computations.
restart;
S := (s+9-Pi) * (s+9+Pi) * (s+1):
sort( evalf( expand(S) ), s, ascending );
2 3
71.13039560 + 89.13039560 s + 19. s + s
sort( evalf( expand(S) ), s, descending );
3 2
s + 19. s + 89.13039560 s + 71.13039560
The above may be useful to you, if this is not adequate:
evalf( expand(S) );
3 2
s + 19. s + 89.13039560 s + 71.13039560
The easiest way to evaluate your results using floating point approximation is to use the evalf command:
evalf(collect((s+9+Pi)*(s+9+Pi)*(s+1),s));
returns
147.4182721+s^3+25.28318530*s^2+171.7014573*s
If you are really just interested in floating point results, it is worth noting that if one or more of the terms in your original expression is floating point, Maple will evaluate the results in floating point. For example:
collect((s+9.+Pi)*(s+9+Pi)*(s+1),s);
Also note that I changed your use of lower-case pi (the Greek letter) to Pi (the mathematical constant) in the code above.

Get matlab to show square roots (i.e. 2^(1/2) instead of 1.414)

I have a few simple equations that I want to pipe through matlab. But I would like to get exact answers, because these values are expected to be used and simplified later on.
Right now Matlab shows sqrt(2.0) as 1.1414 instead of something like 2^(1/2) as I would like.
I tried turning on format rat but this is dangerous becasue it shows sqrt(2) as 1393/985 without any sort of warning.
There is "symbolic math" but it seems like overkill.
All I want is that 2 + sqrt(50) would return something like 2 + 5 * (2)^(1/2) and even my 5 years old CASIO calculator can do this!
So what can I do to get 2 + sqrt(50) evaluate to 2 + 5 * (2)^(1/2) in matlab?
As per #Oleg's comment use symbolic math.
x=sym('2')+sqrt(sym('50'))
x =
5*2^(1/2) + 2
The average time on ten thousand iterations through this expression is 1.2 milliseconds, whilst the time for the numeric expression (x=2+sqrt(50)) is only 0.4 micro seconds, i.e. a factor of ten thousand faster.
I did pre-run the symbolic expression 50 times, because, as Oleg points out in his second comment the symbolic engine needs some warming up. The first run through your expression took my pc almost 2 seconds.
I would therefore recommend using numeric equations due to the huge difference in calculation time. Only use symbolic expressions when you are forced to (e.g. simplifying expressions for a paper) and then use a symbolic computation engine like Maple or Wolfram Alpha.
Matlab main engine is not symbolic but numeric.
Symbolic toolbox. Create expression in x and subs x = 50
syms x
f = 2+sqrt(x)
subs(f,50)
ans =
50^(1/2) + 2

Modular arithmetic Basic cofusion

I am just learning number theory .When I was reading modular arithmetic I came across this statement :
29 is congruent to 15 (mod 7).
So actually this statement actually shows just
29 is congruent to 15
and we are working under mod 7..mod 7 in brackets is just to show the modulus. It is not 29 is congruent to 15%7.It is 29 is congruent to 15 and we are working under modulus 7.
Your observation is correct. The word mod is actually used in two different senses: one of them is to clarify a relation as you describe
A = B (mod C)
means, e.g., that B-A is divisible by C. Or sometimes (but equivalently in the end), it means that you should be reading A and B as being notation, e.g., for elements of the algebraic structure integers modulo C rather than as notation for integers.
The other usage is as a binary operator: B mod C means the remainder when B is divided by C.
Usually it's straightforward to tell the difference from context... assuming you are actually aware of both possible usages. Also, in the first kind of usage, mod is usually set off from the others; e.g.
A = B mod C
is the first usage as a relation, but
A = B mod C
could go either way.

Understanding colon notation in MATLAB

So I'm completely new to MATLAB and I'm trying to understand colon notation within mathematical operations. So, in this book I found this statement:
w(1:5)=j(1:5) + k(1:5);
I do not understand what it really does. I know that w(1:5) is pretty much iterating through the w array from index 1 through 5, but in the statement above, shouldn't all indexes of w be equal to j(5) + k(5) in the end? Or am I completely wrong on how this works? It'd be awesome if someone posted the equivalent in Java to that up there. Thanks in advance :-)
I am pretty sure this means
"The first 5 elements of w shall be the first 5 elements of j + the first 5 elements of k" (I am not sure if matlab arrays start with 0 or 1 though)
So:
w1 = j1+k1
w2 = j2+k2
w3 = j3+k3
w4 = j4+k4
w5 = j5+k5
Think "Vector addition" here.
w(1:5)=j(1:5) + k(1:5);
is the same that:
for i=1:5
w(i)=j(i)+k(i);
end
MATLAB uses vectors and matrices, and is heavily optimized to handle operations on them efficiently.
The expression w(1:5) means a vector consisting of the first 5 elements of w; the expression you posted adds two 5 element vectors (the first 5 elements of j and k) and assigns the result to the first five elements of w.
I think your problem comes from the way how do you call this statement. It is not an iteration, but rather simple assignment. Now we only need to understand what was assigned to what.
I will assume j,k, w are all vectors 1 by N.
j(1:5) - means elements from 1 to 5 of the vector j
j(1:5) + k(1:5) - will result in elementwise sum of both operands
w(1:5) = ... - will assign the result again elementwise to w
Writing your code using colon notation makes it less verbose and more efficient. So it is highly recommended to do so. Also, colon notation is the basic and very powerful feature of MATLAB. Make sure you understand it well, before you move on. MATLAB is very well documented so you can read on this topic here.