relativity maths

i am making a calculator thing that does math based around particles and need some equations i couldn't find on wikipedia
i have gamma, beta, rest mass energy, and kinetic energy calculations
to complete this calculator i need acceleration and mass calculations
if anybody is interested maybe i could post the code for you
update after a long bit of internet searching i found
force = velocity * acceleration * gamma^3
Last edited on
I think you are looking for invariant mass and acceleration if I'm understanding you correctly?

http://en.wikipedia.org/wiki/Mass_in_special_relativity#Invariant_mass

The two equations are there. I'd be quite interested to see your code to see what you're doing. Presumably working out special relativity equations for a user given particle?
thanks that helped
my code is not even half complete and is 12000+ characters
is it considered spam if i post it between two replys
I don't think that is considered spam. If you are worried, you can upload it to somewhere and just post the link. ;)

closed account (N36fSL3A)
Nope, it's relevant information so I guess the admin wouldn't have a problem with it.

He's pretty chill with most things, as long as you don't post naughty pictures.
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
#include <iostream>
#include <cmath>

using namespace std;


int main ()
{
    int w = 1;
    double gamma;
    double gammaA;
    double gammaB;
    double beta;
    double betaSQ;
    double C = 299792458;
    double CSQ = 89875517873681764;
    double Gc = 6.67384 / 100000000000;
    double Ge = 9.78;
    double G;
    double V;
    double Va;
    double Vb;
    double VSQ;
    double VCU;
    double Vstr;
    double Vend;
    double length;
    double M;
    double Mr;
    double Mn;
    double A;
    double F;
    double T;
    double Ep;
    double Em;
    double Ek;
    double Et;
    double x;
    double y;
    double z;
    double a;
    double b;
    double c;
    while (w == 1){
    cout << "all variables are metric (meters, seconds, newtons, kilograms, joules) \n";
    cout << "relative 1 or newtonian 2 \n";
    cin >> y;
    if (y == 1){
    cout << "solve for gamma 1, beta 2, gravity 3, mass 4, acceleration 5, force 6, time 7, mass energy 8, kinetic energy 9, total energy 10 \n";
    cin >> x;
    if (x == 1) {
            cout << "input beta \n";
            cin >> beta;
            betaSQ = beta * beta;
            gammaA = 1 - betaSQ;
            gammaB = sqrt(gammaA);
            gamma = 1 / gammaB;
            cout << "\ngamma is " << gamma;

    }
    else if (x == 2) {
            cout << "input velocity \n";
            cin >> V;
            beta = V / C;
            cout << "\nbeta is " << beta;
    }
    else if (x == 3) {

    }
    else if (x == 4) {
            cout << "rest mass 1 or moving mass 2 \n";
            cin >> z;
            if (z == 1) {
                cout << "mass energy 1 or total energy 2 \n";
                cin >> a;
                if (a == 1) {
                    cout << "input mass energy \n";
                    cin >> Em;
                    Mn = Em / CSQ;
                    cout << "\nthe rest mass is " << Mn;
                }
                else {
                    cout << "input total energy \n";
                    cin >> Et;
                    cout << "\ninput gamma \n";
                    cin >> gamma;
                    cout << "\ninput velocity \n";
                    cin >> velocity;
                    Em = (Et / gamma) / V;
                    Mn = Em / CSQ;
                    cout << "\nthe rest mass is " << Mn;
                }
            }
            else {

            }
    }
    else if (x == 5) {

    }
    else if (x == 6) {

    }
    else if (x == 7) {

    }
    else if (x == 8) {
            cout << "input rest mass \n";
            cin >> Mn;
            Em = M * CSQ;
            cout << "\nthe mass energy is " << CSQ;
    }
    else if (x == 9) {
            cout << "input gamma \n";
            cin >> gamma;
            cout << "\ninput rest mass \n";
            cin >> Mn;
            cout << "\ninput V \n";
            cin >> V;
            Em = Mn * CSQ;
            Et = Em * gamma * V;
            Ek = Et - Em;
            cout << "\nthe kinetic energy is " << Ek;
    }
    else {
            cout << "input gamma \n";
            cin >> gamma;
            cout << "\ninput rest mass \n";
            cin >> Mn;
            cout << "\ninput velocity \n";
            cin >> V;
            Em = Mn * CSQ;
            Et = Em * gamma * V;
            cout << "\nthe total energy is " << Et;
    }
    }
    else {
        cout << "solve for velocity 1, mass 2, acceleration 3, force 4, time 5, kinetic energy 6, gravity 7 \n";
    cin >> x;
    if (x == 1) {
            cout << "timed acceleration 1 or kinetic energy and mass 2 \n";
            cin >> z;
            if (z == 1) {
                cout << "input time \n";
                cin >> T;
                cout << "\ninput acceleration \n";
                cin >> A;
                V = A * T;
                cout << "\nthe velocity is " << V;
            }
            else {
                cout << "input mass \n";
                cin >> M;
                cout << "\ninput kinetic energy \n";
                cin >> Ek;
                Va = Ek / M;
                Vb = Va * 2;
                V = sqrt (Vb);
                cout << "\nthe velocity is " << V;
            }
    }
    else if (x == 2) {
            cout << "input kinetic energy \n";
            cin >> Ek;
            cout << "\ninput velocity \n";
            cin >> V;
            VSQ = V * V;
            M = Ek * 2 / VSQ;
            cout << "\nthe mass is " << M;
    }
    else if (x == 3) {
            cout << "input force \n";
            cin >> F;
            cout << "\ninput mass \n";
            cin >> M;
            A = F / M;
            cout << "\nthe acceleration is " << A;
    }
    else if (x == 4) {
            cout << "input mass \n";
            cin >> M;
            cout << "\ninput acceleration \n";
            cin >> A;
            F = M * A;
            cout << "\nthe force is " << F;
    }
    else if (x == 5) {
            cout << "input acceleration \n";
            cin >> A;
            cout << "\ninput start velocity \n";
            cin >> Vstr;
            cout << "\ninput velocity end \n";
            cin >> Vend;
            V = Vend - Vstr;
            T = A / V;
            cout << "\nthe time is " << T;
    }
    else if (x == 6) {
        cout << "input velocity \n";
        cin >> V;
        cout << "\ninput mass \n";
        cin >> M;
        VSQ = V * V;
        Ek = VSQ * M / 2;
        cout << "\nthe kinetic energy is " << Ek;
    }
    else {
            cout << "graitational force 1, potential energy 2, or acceleration 3 \n";
            cin >> z;
            if (z == 1) {
                cout << "\ninput mass \n";
                cin >> M;
                cout << "\ninput other mass \n";
                cin >> Mn;
                cout << "\ninput distance \n";
                cin >> length;
                G = M * Mn * Gc / (length * length);
                cout << "\nthe gravitational force is " << G;
            }
            else if (z == 2) {
                    cout << "\ntotal potential energy 1, lengthed/timed fall 2, or lengthed/timed fall on earth 3 \n";
                    cin >> a;
                    if (a == 1) {

                    }
                    else if (a == 2) {
                        cout << "\n potential energy 1, end veloctiy 2, or average veloctiy 3 \n";
                        cin >> b;
                        if (b == 1) {
                            cout << "\ninput gravitation \n";
                            cin >> G;
                            cout << "\ninput fall length \n";
                            cin >> length;
                            cout << "\ninput mass \n";
                            cin >> M;
                            Ep = G * length * M;
                            cout << "\nthe potential energy is " << Ep;
                        }
                        else if (b == 2) {
                            cout << "\ntime 1 or length 2 \n";
                            cin >> c;
                            if (c == 1) {
                                cout << "\ninput fall time \n";
                                cin >> T;
                                cout << "\ninput gravitation \n";
                                cin >> G;
                                length = G * T * T / 2;
                                Ep = G * length;
                                VSQ = Ep * 2;
                                V = sqrt(VSQ);
                                cout << "\nthe end velocity is " << V;
                            }
Last edited on
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
}
                            else {
                                cout << "\ninput fall length \n";
                                cin >> length;
                                cout << "\ninput gravitation \n";
                                cin >> G;
                                Ep = G * length;
                                VSQ = Ep * 2;
                                V = sqrt(VSQ);
                                cout << "\nthe end velocity is " << V;
                            }

                        }
                        else {
                            cout << "\ntime 1 or length 2 \n";
                            cin >> c;
                            if (c == 1) {
                                cout << "\ninput fall time \n";
                                cin >> T;
                                cout << "\ninput gravitation \n";
                                cin >> G;
                                V = T * G / 2;
                                cout << "\nthe average velocity is " << V;
                            }
                            else {
                                cout << "\ninput fall length \n";
                                cin >> length;
                                cout << "\ninput gravitation \n";
                                cin >> G;
                                T = sqrt(length * 2 / G);
                                V = T * G / 2;
                                cout << "\nthe average velocity is " << V;
                            }
                        }
                    }
                    else {
                        cout << "\npotential energy 1, end velocity 2, or average velocity 3 \n";
                        cin >> b;
                        if (b == 1) {
                            cout << "\ntime 1 or length 2 \n";
                            cin >> c;
                            if (c == 1) {
                                cout << "\ninput time \n";
                                cin >> T;
                                cout << "\ninput mass \n";
                                cin >> M;
                                length = Ge * T * T / 2;
                                Ep = length * M * Ge;
                                cout << "\nthe potential energy is " << Ep;
                            }
                            else {
                                cout << "\ninput fsll length \n";
                                cin >> length;
                                cout << "\ninput mass \n";
                                cin >> M;
                                Ep = length * M * Ge;
                                cout << "\nthe potential energy is " << Ep;
                            }
                        }
                        else if (b == 2) {
                            cout << "\ntime or length \n";
                            cin >> c;
                            if (c == 1) {
                                cout << "\ninput fall time \n";
                                cin >> T;
                                length = Ge * T * T / 2;
                                Ep = length * Ge;
                                VSQ = Ep * 2;
                                V = sqrt(VSQ);
                                cout << "\nthe end velocity is " << V;
                            }
                            else {
                                cout << "\ninput fall length \n";
                                cin >> length;
                                Ep = length * Ge;
                                VSQ = Ep * 2;
                                V = sqrt(VSQ);
                                cout << "\nthe end velocity is " << V;
                            }
                        }
                        else {
                            cout << "\ntime or length \n";
                            cin >> c;
                            if (c == 1) {
                                cout << "\ninput time \n";
                                cin >> T;
                                V = T * Ge / 2;
                                cout << "\nthe average velocity is " << V;
                            }
                            else {
                                cout << "\ninput length \n";
                                cin >> length;
                                T = sqrt(length * 2 / Ge);
                                V = T * Ge / 2;
                                cout << "\nthe average velocity is " << V;
                            }
                        }
                        }
                    }
            }
    }
    cout << "\n would you like to do another equation? 1 yes 2 no \n";
    cin >> w;
    }
}

i like if statements
Last edited on
Please put your code in [code][/code] tags:

http://www.cplusplus.com/articles/z13hAqkS/
Topic archived. No new replies allowed.