Printing only integer values for some equation using MATHEMATICA.

In summary, the conversation discusses the need for help with a Mathematica program involving the values of t, r, k, n, and x. The program is designed to find integer values for k, n, and x within a given range of t. The program also involves the use of the formula r=3+2Sqrt[2] and the condition that all values must have high powers of 3+2 Sqrt[2].
  • #1
76Ahmad
48
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
  • #2
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]
 

Related to Printing only integer values for some equation using MATHEMATICA.

1. How can I print only integer values for an equation in Mathematica?

To print only integer values for an equation in Mathematica, you can use the function Round. This function rounds any decimal values to the nearest integer, allowing you to print only whole number results.

2. Can I specify the number of digits to be displayed for the integer values?

Yes, you can use the NumberForm function to specify the number of digits to be displayed for the integer values. This function allows you to control the formatting of numbers in your output.

3. Is there a way to print only positive or negative integer values?

In Mathematica, you can use the functions Floor and Ceiling to round down or up respectively to the nearest integer. This allows you to print only positive or negative integer values, depending on your equation.

4. Can I print a list of integer values for a range of numbers in an equation?

Yes, you can use the function Table to print a list of integer values for a range of numbers in an equation. For example, Table[x^2, {x, 1, 5}] will print a list of the square of integers from 1 to 5.

5. How can I exclude non-integer values from my output?

You can use the function IntegerQ to check if a number is an integer or not. By using this function in conjunction with the If statement, you can exclude non-integer values from your output.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
282
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
9
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
12
Views
4K
Back
Top