Printing only integer values for some equation using MATHEMATICA.

Click For Summary
SUMMARY

The discussion focuses on using Mathematica to find integer values for the variables k, n, and x based on a specific equation involving the parameter t, which ranges from 2 to 1000. The equation utilizes the expression r = 3 + 2Sqrt[2] and iterates through values of t to compute k, n, and x. The user encounters an issue where no integer values are printed due to the high powers of r affecting the results. The solution involves ensuring that the conditions for integer outputs are correctly implemented in the Mathematica code.

PREREQUISITES
  • Familiarity with Mathematica programming language
  • Understanding of mathematical functions and integer conditions
  • Knowledge of the Sqrt function and its implications in equations
  • Basic experience with loops and conditional statements in programming
NEXT STEPS
  • Explore Mathematica's IntegerQ function for validating integer outputs
  • Learn about the implications of high powers in mathematical expressions
  • Investigate optimization techniques for Mathematica code to improve performance
  • Study the use of Print statements for debugging in Mathematica
USEFUL FOR

Mathematica users, mathematicians, and programmers interested in solving equations and validating integer results in computational mathematics.

76Ahmad
Messages
46
Reaction score
0
Hello every one, I need help on some mathematica run program.

Suppose the following:

1) 2=<t=<1000
2) r=3+2Sqrt[2]
3) k=(r^t+r^(-t)-20)/4
4) n=2k+4
5) x=n/2-(r^t-r^(-t))/2Sqrt[2]

I need to run the program For[t=2,t=<1000,t++
and only print if it found any integer values of (k,n,x)

please help, thanks
 
Physics news on Phys.org
r = 3 + 2Sqrt[2];
For[t = 2, t <= 1000, t++,
k = (r^t + r^(-t) - 20)/4;
If[IntegerQ[k], Print["k=", k]];
n = 2k + 4;
If[IntegerQ[n], Print["n=", n]];
x = n/2 - (r^t - r^(-t))/2Sqrt[2];
If[IntegerQ[x], Print["x=", x]];
]

And this prints nothing because every value has high powers of 3+2 Sqrt[2]
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 1 ·
Replies
1
Views
3K
Replies
10
Views
3K
  • · Replies 11 ·
Replies
11
Views
3K
  • · Replies 9 ·
Replies
9
Views
4K
  • · Replies 5 ·
Replies
5
Views
2K
  • · Replies 12 ·
Replies
12
Views
5K
  • · Replies 4 ·
Replies
4
Views
3K
  • · Replies 7 ·
Replies
7
Views
2K
  • · Replies 3 ·
Replies
3
Views
2K