Message Boards Message Boards


NSolve and Solve run forever or give errors with big numbers

Posted 2 months ago
5 Replies
2 Total Likes


I didn't use Mathematica for years and I am VERY rusty regarding the best way to solve this problem :

2*vectk.vectG = G^2,

k = 2*pi/lambda

I have the G vector and I want to find all vector k that can fit into this previous equation. Vect k should use some "primitive" vectors b1, b2 and b3.

la1 =  6.2696*10^-10;
la2 =  40.3246*10^-10;
la3 =  9.8488*10^-10;
alpha = 90;
beta = 99.464;
gamma = 90;
a1 = {la1, 0, 0};
a2 = {0, la2, 0};
a3 = {la3*Cos[beta Degree], 0, la3*Sin[beta Degree]};
omega = 2456.07*(10^-10)^3;
lambda = 1.5*10^-10;
b1 = 2*Pi*(Cross[a2, a3]/omega);
b2 = 2*Pi*(Cross[a3, a1]/omega);
b3 = 2*Pi*(Cross[a1, a2]/omega);
G[h_, k_, l_] := h*b1 + k*b2 + l*b3;
G = G[1, 7, 0]
h = 1;
k = 7;
l = 0;
Solve[2*Dot[k1*b1 + k2*b2 + k3*b3, h*b1 + k*b2 + l*b3] == 
   Norm[h*b1 + k*b2 + l*b3]^2 && 
  Norm[{k1*b1 + k2*b2 + k3*b3}] <= 2*Pi*1.01/lambda, {k1, k2, 
  k3}, Integers, WorkingPrecision -> 100]

When I execute it processes for ever.

I don't know if Solve function can solve such a problem or if there is a problem with my syntax. If Solve cannot find such a solution, would you have some recommandations ? It is for a school project...


5 Replies

There are many problems with your code. The object {k1*b1, k2*b2, k3*b3} is a matrix. What do you mean by its Norm? The maximum singular value? Your first equation seems of the form vector==scalar. How can you hope to find integer solutions to an equation with inexact coefficients?

Posted 2 months ago

Thank you for your answer. I was looking for the Norm[vector]. I corrected the code.

Also, I thought

(k1*b1 + k2*b2 + k3*b3).( h*b1 + k*b2 + l*b3) 

was a vector. I corrected it too with

Dot[k1*b1 + k2*b2 + k3*b3, h*b1 + k*b2 + l*b3]

You say your vector g is given, { g1, g2, g3 } say.

Now chose your vector k = { k1, k2, k3 } and form vectors ks1 and ks2

g = {g1, g2, g3};
k = {k1, k2, k3};
ks1 = k - g.k/g.g g
ks2 = Cross[g, k]

Then for arbitrary u and v

k and (g.k/g.g g + u ks1 + v ks2) have the same sclar product, which means your problems has infinitly many solutions:

g.(g.k/g.g g + u ks1 + v ks2) // FullSimplify
Posted 2 months ago

I don't really understand the reasoning, but from my visualization of the problem, there should be a limited quantity of solutions. We only want the nodes in "the plan normal to vect.G passing throw (1/2)*vect.G" touched by vect.k who has a fixed length starting from the origin...

I used a completely different path. I made a list of the nodes of the lattice using Table, then extracted those included in the plan (an almost flat cylinder) with Select, then extracted again those at distance k from the origin.

I am curious to understand why my first approach didn't work. But this is not vital either : /

What do you mean by "reasoning"? You asked for vectors having the same scalar-product g.k = G^2 / 2, and I gave you a method to construct such vectors. And there are infinitly many. Due to u and v for me it is a two-dimensional manifold. And of course you can normalize them and give them any lengths you want.

But perhaps I don't understand your problem correctly. What do you mean by "nodes"? What do you want to do?

Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
or Discard

Group Abstract Group Abstract