Message Boards Message Boards

0
|
10095 Views
|
4 Replies
|
0 Total Likes
View groups...
Share
Share this post:

NSolve and Domains / Assumptions

Posted 11 years ago
Hi,

I am not completely new to Mathematica, but haven't used it in years, and was never very deep into it either, so I have some struggles getting back into it.

Say, I have given an expression r(R). The inverse expression R(r) cannot be given explicitly, but the graph appears one-to-one, so it should be possible to get it numerically. Hence I wanted to use NSolve. However NSolve cannot give me the answer either. I then thought, maybe the problem is out of the range where I plotted the function, and thought I could augment NSolve with some assumptions on the allowed domain of both R, and r.

But I don't know how to do that. Can anyone help me out?

Thanks!
POSTED BY: Gernot H
4 Replies
try FindRoot
POSTED BY: Frank Kampas
Posted 11 years ago
Hi Frank,

thanks for you Answer!

I am not sure if FindRoot is able to do what I want to do. Or I am doing something wrong still, since I am getting cryptic error messages -  it doesnt like the starting point term. I will add the code of the concrete function I am given, so it is easier to follow: I have given the relation r = rfunc(R) with
rfunc[R_] := (2 R + M + Sqrt[4 R^2 + 4 M R + 3 M^2])/
   4*(((4 + 3 Sqrt[2])*(2 R - 3 M))/(
    8 R + 6 M + 3*Sqrt[8 R^2 + 8 M R + 6 M^2]))^(1/Sqrt[2]);
M := 1;
Plot[rfunc[R], {R, 0, 6}]
, and where M = 1.
As one can see from the plot, R goes to 3/2 as r goes to 0, and R goes to infinity as r goes to infinity. Inbetween the function is one-to-one, so it should be possible to invert the function numerically on this domain. So I want an expression R = somefunction.

What I tried before is,
NSolve[rfunc[R]==r,R]
but this does not work.

Can FindRoot do this, and if yes, how? Or can NSolve do this, with specifying additional assumptions on the domain and/or range? If so, how would I do this?

The Mathematica Help to the assumption functions is not really helpfull here for me. : /
POSTED BY: Gernot H
Hi, 
FindRoot will work well if you specify the root domain carefully:
M := 1;
r[R_] := (2 R + M + Sqrt[4 R^2 + 4 M R + 3 M^2])/
    4*(((4 + 3 Sqrt[2])*(2 R - 3 M))/(8 R + 6 M +
        3*Sqrt[8 R^2 + 8 M R + 6 M^2]))^(1/Sqrt[2]);

(* inverse function *)
g[(x_)?NumericQ] :=
  Block[{y}, y /. FindRoot[x == r[y], {y, 3/2, 10} (* inverse func. arg. domain *)]];
Example:
r[3/2]
g[%]
Plot[{x, g[r[x]]}, {x, 0, 6}, PlotStyle -> {Dashed, Thick}]

I.M.
POSTED BY: Ivan Morozov
Posted 11 years ago
Thank you very much Ivan Morozov, this would have taken me forever to figure it out myself! But I understand how it works now. Thanks a lot! : )
POSTED BY: Gernot H
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard

Group Abstract Group Abstract