Group Abstract Group Abstract

Message Boards Message Boards

NSolve and Domains / Assumptions

GROUPS:
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
Answer
6 months ago
try FindRoot
POSTED BY: Frank Kampas
Answer
6 months 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
Answer
6 months ago
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
Answer
6 months 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
Answer
5 months ago