Mathematica text keyword - mathematica-8

I have a file.txt looklike this
key.txt
date: Nov_17_12
begin
k 6.822379e+001 1.298165e+002 0.000000e+000
k 0.000000e+000 1.298165e+002 0.000000e+000
k 6.822379e+001 7.357968e+001 0.000000e+000
end
begin
k 6.822379e+001 7.357968e+001 0.000000e+000
k 0.000000e+000 1.298165e+002 0.000000e+000
k 0.000000e+000 0.000000e+000 0.000000e+000
end
begin
k 6.822379e+001 7.357968e+001 0.000000e+000
k 0.000000e+000 0.000000e+000 0.000000e+000
k 1.456291e+002 7.357968e+001 0.000000e+000
end
begin
k 1.456291e+002 7.357968e+001 0.000000e+000
k 0.000000e+000 0.000000e+000 0.000000e+000
k1.456291e+002 0.000000e+000 0.000000e+000
end
So how can I convert it to MatrixForm as:
A1 = {{6.822379e+001 1.298165e+002 0.000000e+000}
{0.000000e+000 1.298165e+002 0.000000e+000}
{6.822379e+001 7.357968e+001 0.000000e+000}}
A2 = bla bla

Related

For an algorithm with a time complexity of O(N+M), if M is always less than N, can we say the time complexity will be O(N)?

Give an algorithm with time complexity of O(N+M) and M<N.
Can we conclude O(N+M) => O(N+N) => O(2N) => O(N)
Will that be correct?
f(N, M) = O(N + M) is by definition
E c, N0, M0: A N ≥ N0, M ≥ M0: f(N, M) ≤ c (N + M)
But by your hypothesis, M < N so that
E c, N0, M0: A N ≥ N0, M ≥ M0: f(N, M) ≤ c (N + M) < c 2N
and
E c', N0, M0: A N ≥ N0, M ≥ M0: f(N, M) ≤ c' N.

Finding constant C in Big-Oh notation

I'm having trouble finding a constant C that works for the following problems:
18 n2 + 122 n = O( n2) find a C ≤ 50
11 n2 + 132 n + 390 = O( n2) find a C ≤ 20
"Using the definition of O, prove each part. Choose an explicit positive integer constant C within theindicated range and solve for a positive integer K which is as small as possible."
I understand that 18 n2 + 122 n <= c n2 , n >= k
Might as well just increment the coefficient on the dominant power, and use 19 and 12. Then:
18k² + 122k <= 19k²
⇔ 122k <= k²
⇔ k >= 122 or k <= 0
11k² + 132k + 390 <= 12k²
⇔ k² - 132k - 390 >= 0
You could use the quadratic formula for that one, but I would just start at k=133 and count upwards

How to find a prime q such that it divides prime p-1?

I would like to find a prime q such that it divides a prime p-1
E.g. p=23 (prime)
q|p-1 = 11|22
Are there any formula for doing so if prime p is not always a safe prime?

Counting numbers co-prime to n which are less than m

Counting numbers co-prime to n which are less than m, m
I thought of doing this by (phi(n)/n)*m, but it always have some small error.
One way can be using inclusion-exclusion principle, but i am looking for a better algorithm than that.
eg
n = 20 m = 10
{1, 3, 7, 9}
Ans = 4
First you can find all x < m that x is prime and x is divisor of n. It is calculate in O(m * (x.count))
i = 1;
while x[i] not empty do
{
j = 1;
while x[i] * j < m
{
s[(x[i] * j)] = false;
j++;
}
i++;
}
Now you can find all s[k] that s[k] = true.
It is calculate in O(m)
So you can do all steps in O(m * (x.count))

Big Omega Notation Proving

To show that 3n^2 - 25n = Ω(n^2)
For n ≥ n / 2 for n ≥ 0
n – 25/3 ≥ 3n / (2 x 25) for n ≥ 9
3n^2 - 25n ≥ 9n^2 / 50 for n ≥ 9
3n2 - 25n ≥ c·n2 for n ≥ n0 where c=9 / 50 and n0 = 9
Therefore, by definition
3n2 - 25n = Ω(n2).
Above is the proof that 3n^2 - 25n = Ω(n^2).
Why use n ≥ n / 2?
How is n – 25/3 ≥ 3n / (2 x 25) derived?
I am not sure why do we need n>=n/2. What we do need is that n >= 0 => n*3 >= 0 and so we can multiply the first inequality by 3*n on both sides.
(1) n – 25/3 ≥ 3n / (2 x 25) is a simple linear inequality. By doing some transformation we get:
(1) <=> (47/50)*n - 25/3 >= 0 <=> (47/50)n >= 25/3 <=> n >= (25/3)(50/47) <=> n >= 1250/141 <=> n >= 8 + 122/141
And from the above we get that this inequality holds true for all n >= 9 > 8 + 122/141. This is just one of the inequalities you can use to prove this big omega notation. Hope my answer helps.

Resources