Services & Resources / Wolfram Forums
MathGroup Archive
*Archive Index
*Ask about this page
*Print this page
*Give us feedback
*Sign up for the Wolfram Insider

MathGroup Archive 2004

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

Search the Archive

Re: Simple, syntactical question

  • To: mathgroup at
  • Subject: [mg48171] Re: [mg48152] Simple, syntactical question
  • From: Andrzej Kozlowski <akoz at>
  • Date: Sat, 15 May 2004 03:56:30 -0400 (EDT)
  • References: <>
  • Sender: owner-wri-mathgroup at

On 15 May 2004, at 09:59, Olaf Skjaraasen wrote:

> Hi all,
> my problem is a simple one, but please bear with me: Assume a function
> f(x) whose x-dependence is different for different parts of the x-axis;
> e.g.,
> f[x_] := If[x<0,x^2, x^2 + Cos[x]];
> I would like Mathematica to do the following: Given values y0,
> x0, find x such that f[x]=y0, subject to the condition x>x0.
> What is the syntax to be used to tell Mathematica to restrict itself to
> x>x0 when solving the equation, whether with Solve, NSolve, FindRoot or
> DSolve?
> Cheers,
> Olaf
Probably the best way is to use  NMinimize. Since you do not provide 
any numerical data I have to make up my own. Suppose x0=-1 and y0 = 0.1

So we define:


Now we minimise and use Chop to get rid of tiny numerical quantities:



We check the answer:



So we have a solution.

Andrzej Kozlowski
Chiba, Japan

  • Prev by Date: Re: Mean
  • Next by Date: Re: Mean
  • Previous by thread: Simple, syntactical question
  • Next by thread: setdirectory doesn't work.anymore