MathGroup Archive 2010

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Numerical simulation

  • To: mathgroup at smc.vnet.net
  • Subject: [mg113703] Re: Numerical simulation
  • From: Peter Pein <petsie at dordos.net>
  • Date: Mon, 8 Nov 2010 03:39:45 -0500 (EST)
  • References: <iaonn6$jm9$1@smc.vnet.net>

Am Tue, 2 Nov 2010 10:04:22 +0000 (UTC)
schrieb Equilib <petterbe at gmail.com>:

> Hi,
> Does anybody have a good idea on how to set up and run simple
> numerical simulations in Mathematica?
> 
> I have an equation that consists of the variables p, g that I want to
> solve for p for different values of g=[0,1] and c=[0,1]. The function
> could be for example 1/2+c+g(1-p)+root(c+p*g-1)=0. (the real equation
> is to complex to solve algebraicly using Solve[XX,p]).
> 
> I guess I need to construct a matrix for different values [0,1] of g
> and c and then use this to numerically solve for p. but how do i set
> this up in a smart way? And how do I use the results to plot p as a
> function of for example g?
> 
> Best,
> Petter
> 
> 

Hi,

when you got (or will get) an equation which can be handled by Reduce,
you can try:

func[c_, g_] = Block[{listlist=
   LogicalExpand[Reduce[1/2 + c + g*(1 - p) + Sqrt[c + p*g - 1] == 0
   && 0 <= c <= 1 >= g >=0 == Im[p], p]] /. Or -> List /.
   HoldPattern[(c1___) && p == (pp_) && (c2___)] :> {pp, c1 && c2}},

  Piecewise[{FullSimplify[#1, #2], FullSimplify[#2]}& @@@ listlist]
]

Peter


  • Prev by Date: Re: Tag List Protected error
  • Next by Date: Re: How to apply Fourier transform to speech signals?
  • Previous by thread: Re: Numerical simulation
  • Next by thread: Re: Numerical simulation