Skip to main content
Possible cure for Solve problems
Source Link
Jens
  • 97.9k
  • 7
  • 215
  • 510

On version 8.0.4 (Mac OS X 10.7.4) I can't reproduce the hanging problem right now. So I'll just post what I get in order to illustrate the point whuber was making in the comment about the switch between branches at $\pi/2$:

f[r_] := 
 ArcCos[(-1 + 4.20278 r (0.008712/r^2 + 0.475876/r - 1/(1 + r)))/
   Sqrt[1 - 10.598 r^2 (0.008712/r^2 + 0.475876/r - 1/(1 + r))]]

inv = InverseFunction[f]

InverseFunction::ifun: Inverse functions are being used. Values may be lost for multivalued inverses.

(*
==> Function[K$560, 
 Root[-9.980709009173207336338507314921*10^32 - 
    5.6513875402447117935217351899052*10^34 #1 + \
(-6.2538998570511812298820407237647*10^35 + 
       6.7574125679790639379694250000000*10^35 Cos[
         K$560]^2) #1^2 + (4.9434185675637107331456209245797*10^36 - 
       2.4031727155691592312030575000000*10^36 Cos[
         K$560]^2) #1^3 + (-7.6367044490503772137949618167113*10^36 + 
       1.0564173268177257812500000000000*10^36 Cos[K$560]^2) #1^4 + 
    4.1353312991847914062500000000000*10^36 Cos[K$560]^2 #1^5 &, 1]]
*)

Plot[f[inv[x]], {x, 0, Pi}, AspectRatio -> Automatic]

plot f of inverse

The plot should be a straight line along the diagonal if inv were the correct inverse. With Solve, you get all the branches and can stitch together the inverse over a larger interval. But with InverseFunction, we were warned and proceeded anyway, so it's no wonder that we get an inverse that's only valid up to $\pi/2$.

Possible things to try if the calculation hangs

Although I don't see any effect here, it sometimes helps to do Rationalize before applying symbolic manipulations: for example, you could try

f[r_] = 
 ArcCos[Rationalize[(-1 + 
       4.20278 r (0.008712/r^2 + 0.475876/r - 1/(1 + r)))/
     Sqrt[1 - 10.598 r^2 (0.008712/r^2 + 0.475876/r - 1/(1 + r))]]] //
   FullSimplify

Here I used = deliberately because I want the Rationalize and FullSimplify to be performed immediately.

On version 8.0.4 (Mac OS X 10.7.4) I can't reproduce the hanging problem right now. So I'll just post what I get in order to illustrate the point whuber was making in the comment about the switch between branches at $\pi/2$:

f[r_] := 
 ArcCos[(-1 + 4.20278 r (0.008712/r^2 + 0.475876/r - 1/(1 + r)))/
   Sqrt[1 - 10.598 r^2 (0.008712/r^2 + 0.475876/r - 1/(1 + r))]]

inv = InverseFunction[f]

InverseFunction::ifun: Inverse functions are being used. Values may be lost for multivalued inverses.

(*
==> Function[K$560, 
 Root[-9.980709009173207336338507314921*10^32 - 
    5.6513875402447117935217351899052*10^34 #1 + \
(-6.2538998570511812298820407237647*10^35 + 
       6.7574125679790639379694250000000*10^35 Cos[
         K$560]^2) #1^2 + (4.9434185675637107331456209245797*10^36 - 
       2.4031727155691592312030575000000*10^36 Cos[
         K$560]^2) #1^3 + (-7.6367044490503772137949618167113*10^36 + 
       1.0564173268177257812500000000000*10^36 Cos[K$560]^2) #1^4 + 
    4.1353312991847914062500000000000*10^36 Cos[K$560]^2 #1^5 &, 1]]
*)

Plot[f[inv[x]], {x, 0, Pi}, AspectRatio -> Automatic]

plot f of inverse

The plot should be a straight line along the diagonal if inv were the correct inverse. With Solve, you get all the branches and can stitch together the inverse over a larger interval. But with InverseFunction, we were warned and proceeded anyway, so it's no wonder that we get an inverse that's only valid up to $\pi/2$.

On version 8.0.4 (Mac OS X 10.7.4) I can't reproduce the hanging problem right now. So I'll just post what I get in order to illustrate the point whuber was making in the comment about the switch between branches at $\pi/2$:

f[r_] := 
 ArcCos[(-1 + 4.20278 r (0.008712/r^2 + 0.475876/r - 1/(1 + r)))/
   Sqrt[1 - 10.598 r^2 (0.008712/r^2 + 0.475876/r - 1/(1 + r))]]

inv = InverseFunction[f]

InverseFunction::ifun: Inverse functions are being used. Values may be lost for multivalued inverses.

(*
==> Function[K$560, 
 Root[-9.980709009173207336338507314921*10^32 - 
    5.6513875402447117935217351899052*10^34 #1 + \
(-6.2538998570511812298820407237647*10^35 + 
       6.7574125679790639379694250000000*10^35 Cos[
         K$560]^2) #1^2 + (4.9434185675637107331456209245797*10^36 - 
       2.4031727155691592312030575000000*10^36 Cos[
         K$560]^2) #1^3 + (-7.6367044490503772137949618167113*10^36 + 
       1.0564173268177257812500000000000*10^36 Cos[K$560]^2) #1^4 + 
    4.1353312991847914062500000000000*10^36 Cos[K$560]^2 #1^5 &, 1]]
*)

Plot[f[inv[x]], {x, 0, Pi}, AspectRatio -> Automatic]

plot f of inverse

The plot should be a straight line along the diagonal if inv were the correct inverse. With Solve, you get all the branches and can stitch together the inverse over a larger interval. But with InverseFunction, we were warned and proceeded anyway, so it's no wonder that we get an inverse that's only valid up to $\pi/2$.

Possible things to try if the calculation hangs

Although I don't see any effect here, it sometimes helps to do Rationalize before applying symbolic manipulations: for example, you could try

f[r_] = 
 ArcCos[Rationalize[(-1 + 
       4.20278 r (0.008712/r^2 + 0.475876/r - 1/(1 + r)))/
     Sqrt[1 - 10.598 r^2 (0.008712/r^2 + 0.475876/r - 1/(1 + r))]]] //
   FullSimplify

Here I used = deliberately because I want the Rationalize and FullSimplify to be performed immediately.

Source Link
Jens
  • 97.9k
  • 7
  • 215
  • 510

On version 8.0.4 (Mac OS X 10.7.4) I can't reproduce the hanging problem right now. So I'll just post what I get in order to illustrate the point whuber was making in the comment about the switch between branches at $\pi/2$:

f[r_] := 
 ArcCos[(-1 + 4.20278 r (0.008712/r^2 + 0.475876/r - 1/(1 + r)))/
   Sqrt[1 - 10.598 r^2 (0.008712/r^2 + 0.475876/r - 1/(1 + r))]]

inv = InverseFunction[f]

InverseFunction::ifun: Inverse functions are being used. Values may be lost for multivalued inverses.

(*
==> Function[K$560, 
 Root[-9.980709009173207336338507314921*10^32 - 
    5.6513875402447117935217351899052*10^34 #1 + \
(-6.2538998570511812298820407237647*10^35 + 
       6.7574125679790639379694250000000*10^35 Cos[
         K$560]^2) #1^2 + (4.9434185675637107331456209245797*10^36 - 
       2.4031727155691592312030575000000*10^36 Cos[
         K$560]^2) #1^3 + (-7.6367044490503772137949618167113*10^36 + 
       1.0564173268177257812500000000000*10^36 Cos[K$560]^2) #1^4 + 
    4.1353312991847914062500000000000*10^36 Cos[K$560]^2 #1^5 &, 1]]
*)

Plot[f[inv[x]], {x, 0, Pi}, AspectRatio -> Automatic]

plot f of inverse

The plot should be a straight line along the diagonal if inv were the correct inverse. With Solve, you get all the branches and can stitch together the inverse over a larger interval. But with InverseFunction, we were warned and proceeded anyway, so it's no wonder that we get an inverse that's only valid up to $\pi/2$.