| New Reply |
Definiing two functions (mathematica) |
Share Thread | Thread Tools |
| Feb25-12, 10:57 AM | #1 |
|
|
Definiing two functions (mathematica)
I need to define two functions for a molecule with speed s.
a)it has a horizontal velocity between -s and s b) v , the vertical velocity between +Sqrt[s^2-u^2] and -Sqrt[s^2-u^2] This is what I have done for a) Code:
f[s_]:=RandomReal[{-s,s}]
Code:
g[s_,u_]:=RandomReal[{-Sqrt[s^2-u^2],+Sqrt[s^2-u^2]}]
Thanks a bunch |
| Feb25-12, 12:07 PM | #2 |
|
|
You mean just
g[s,f[s]] ? |
| Feb25-12, 12:20 PM | #3 |
|
|
If just insert what you have written I get RandomReal::unifr: "The endpoints specified the uniform distribution range are not real valued I also Tried, Code:
g[s_] := RandomReal[{-Sqrt[s^2 - f[s]^2], +Sqrt[s^2 - f[s]^2]}]
Any ideas? |
| Feb25-12, 01:41 PM | #4 |
|
|
Definiing two functions (mathematica)
I believe that's because the arguments to RandomReal have to be real. But for example if I entered:
g[2,f[3]] the argument passed to Sqrt results in a complex number. Either need to make sure s^2-u^2 is real or either use RandomComplex. |
| New Reply |
| Thread Tools | |
Similar Threads for: Definiing two functions (mathematica)
|
||||
| Thread | Forum | Replies | ||
| Using Collect in functions, Mathematica | Math & Science Software | 0 | ||
| adding many functions in mathematica | Math & Science Software | 2 | ||
| Mathematica: array of functions | Math & Science Software | 4 | ||
| Mathematica functions | Math & Science Software | 1 | ||
| Composition Functions Mathematica | Math & Science Software | 4 | ||