Register to reply

Definiing two functions (mathematica)

by rbnphlp
Tags: definiing, functions, mathematica
Share this thread:
Feb25-12, 10:57 AM
P: 54
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)
for b)
now , If I enter f[2] I get u, so I have s and u from first code. How do I use these values in the second code (without manually inputting them)?

Thanks a bunch
Phys.Org News Partner Science news on
Experts defend operational earthquake forecasting, counter critiques
EU urged to convert TV frequencies to mobile broadband
Sierra Nevada freshwater runoff could drop 26 percent by 2100
Feb25-12, 12:07 PM
P: 1,666
You mean just

g[s,f[s]] ?
Feb25-12, 12:20 PM
P: 54
Quote Quote by jackmell View Post
You mean just

g[s,f[s]] ?
Yes ,thats what I want ..But how do I put into mathematica ?

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,

g[s_] := RandomReal[{-Sqrt[s^2 - f[s]^2], +Sqrt[s^2 - f[s]^2]}]
However , what it does in this case is , finds f[s] for -Sqrt[s^2 - f[s]^2] and +Sqrt[s^2 - f[s]^2] seperately , so I get different f[s] in that case..

Any ideas?

Feb25-12, 01:41 PM
P: 1,666
Definiing two functions (mathematica)

I believe that's because the arguments to RandomReal have to be real. But for example if I entered:


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.

Register to reply

Related Discussions
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