Message Boards Message Boards

0
|
5787 Views
|
9 Replies
|
0 Total Likes
View groups...
Share
Share this post:

Find a list of combinations of x, y and z that would produce 1.30000 in eq?

Posted 8 years ago

Hello Everyone,

I'm helping a professor in his research by doing tedious number crunching in Excel, and one time consuming aspect is approximating 3 variables (essentially guessing) within a range to produce approximately 1.30000. I thought that maybe I could use Mathematica to produce a list of combinations of x,y, and z that would produce 1.30000 in the equation below, but I've never really used the program before so I wouldn't know how to do this. Would any of you be kind enough to help me?

[1.30000==[sqrt[[6.64730-x]^(2)]+[[10.17180-y]^(2)]+[[5.66580-z]^(2)]],{x,6,7},{y,9,11},{z,5,8}]
POSTED BY: Albert Shim
9 Replies

Mathematica gives an explicit formula for the solution to your equation, if I do not misunderstand your third equation:

eq1 = 1.30000 == 
   Sqrt[(6.64730 - x)^2 + (10.17180 - y)^2 + (5.66580 - z)^2];
eq2 = w == Sqrt[(5.9169 - x)^2 + (11.4014 - y)^2 + (4.4454 - z)^2];
eq3 = 118.0000 == 
   ArcCos[((1.8800)^2 + (1.30000)^2 - (w)^2)/(2*1.8800*(1.30000))]*(180/Pi);
sol = Solve[{eq1, eq2, eq3}] // Simplify 

The solution triples x,y,z lie in a 3D circle:

ParametricPlot3D[Evaluate[{x, y, z} /. sol], {x, 0, 20}, 
 AxesLabel -> {x, y, z}]
POSTED BY: Gianluca Gorni
Posted 8 years ago

Okay this what I'm trying to automate. If you look at the screenshot below you can see red, yellow, and blue cells in excel. The red cells represent the x,y, and z variables that I have to just guess within a range so that the yellow cells are ~1.30000 and ~118.0000.

(Equation 1)The 1.3000 yellow cell has the following formula: 1.30000==SQRT[(6.64730-x)^2+(10.17180-y)^2+(5.66580-z)^2]

(Equation 2) The blue cell is a variable (lets say w) used in equation 3 and produced by the following equation: w==SQRT[(5.9169-x)^2+(11.4014-y)^2+(4.4454-z)^2]

(Equation 3)The 118.0000 yellow cell has the following formula: 118.0000=ACOS[((1.8800)^2 + (Equation 1)^2 - (Equation 2)^2) / (2 * 1.8800 * (equation 1) ) ] * (180/3.1415926)

What Nasser wrote is exactly what I need but I forgot to mention the other two equations.

enter image description here

POSTED BY: Albert Shim

Your second equation is strange, but it looks like another sphere. Perhaps you are looking for points in the intersection of two spheres:

sphere1 = Sphere[{6.64730, 10.17180, 5.66580}, 1.3];
sphere2 = 
  Sphere[{5.9169, 11.4014, 4.4454}, 
   Sqrt[-(Cos[118 Pi/180] - (1.88^2 + 1.3^2))]];
Graphics3D[{sphere1, sphere2}]
RandomPoint[DiscretizeRegion[RegionIntersection[sphere1, sphere2]]]
POSTED BY: Gianluca Gorni

Your equation looked like the equation of the sphere with center in {6.64730, 10.17180, 5.66580} and radius 1.3. We can use the built-in command RandomPoint (introduced in Mathematica 10.2) that extracts random points from a geometric region. If your version is older than 10.2 you can still use Nasser's method.

POSTED BY: Gianluca Gorni
Posted 8 years ago

HI Gianluca,

Well the variables are orthogonal coordinates which get converted to crystallographic coordinates and plugged into a program called teXsan which tells us the rotational movement of a dummy oxygen atom from 0-360 degrees on a molecule. Its really convoluted, but do you know how I would incorporate the second equation into the code that Nasser wrote?

I really just need something that will take the guesswork out of finding different combinations of those 3 orthogonal coordinates that produce a distance of 1.3 angstroms and 118 degrees using the aforementioned equations.

POSTED BY: Albert Shim

I am not sure I am parsing your syntax correctly, but here is an attempt:

RandomPoint[Sphere[{6.64730, 10.17180, 5.66580}, 1.3]]
Graphics3D[
 Point[RandomPoint[Sphere[{6.64730, 10.17180, 5.66580}, 1.3], 20]]]
POSTED BY: Gianluca Gorni
Posted 8 years ago

Hi Gianluca,

Can you explain what you did? I just started using mathematica an hour ago so I'm sorry if I sound vapid.

Also thanks for replying!

POSTED BY: Albert Shim
howManyToFind = 10;
Clear[x, y, z];
conditions = 6 <= x <= 7 && 9 <= y <= 11 && 5 <= z <= 8;
equation = 1.3 == Sqrt[ (6.64730 - x)^2 + (10.17180 - y)^2 + (5.66580 - z)^2];
r = FindInstance[equation && conditions, {x, y, z}, howManyToFind]

gives

{{x -> 6.05293, y -> 9.01563, z -> 5.6658}, {x -> 6.05184, y -> 9.22727, 
  z -> 5.}, {x -> 6.07746, y -> 9.10928, z -> 6.15194}, {x -> 6.05875, 
  y -> 10.7719, z -> 6.65749}, {x -> 6.26417, y -> 11., 
  z -> 6.5917}, {x -> 6.08437, y -> 9.35088, z -> 6.50198}, {x -> 6.04922, 
  y -> 9.22892, z -> 6.3316}, {x -> 6.66179, y -> 9.05533, 
  z -> 5.}, {x -> 6.05934, y -> 9.22258, z -> 6.3316}, {x -> 6., y -> 9.38983,
   z -> 6.47791}}
POSTED BY: Nasser M. Abbasi
Posted 8 years ago

Hi Nasser,

Yes that was exactly what I was looking for thank you!! There is another layer to this problem though. So the three variables must =1.30000 but they must also equal 118.0000 using the following equation:

118.0000=ACOS[[[1.8800]^2 + [the value given by first equation]^2 - [=SQRT[[5.9169-x]^2+[11.4014-y]^2+[4.4454-z]^2]]^2] / [2 * 1.8800 * the value given by first equation ] ] * 180/3.1415926

If something doesn't make sense then my bad. He emailed me a copy of his excel spreadsheet and I'm trying to decipher how he set the formulas up. If you want to take a look at the excel spreadsheet I can PM it to you and tell you exactly what we are trying to do with this number crunching.

POSTED BY: Albert Shim
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract