Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- RealInverse[a_. x_^q_Integer?Positive + b_., x_] /; FreeQ[{a, b}, x] :=
- Surd[(x-b)/a, q]
- RealInverse[expr_, x_] :=
- Module[{y, red},
- red = Reduce[x == (expr /. x -> y), y, Reals];
- ToPW[PWTerm[#, y]& /@ OrList[BooleanConvert[red, "DNF"]], x]
- ]
- OrList[HoldPattern[Or][args__]] := {args}
- OrList[e_] := {e}
- PWTerm[And[cond1___, y_ == root_, cond2___], y_] /; FreeQ[{root, And[cond1, cond2]}, y] := {root, And[cond1, cond2]}
- PWTerm[y_ == root_, y_] /; FreeQ[root, y] := {root, True}
- PWTerm[___] = $Failed;
- ToPW[lis_?MatrixQ, x_] /; Length[First[lis]] == 2 :=
- With[{condlist = Last[Transpose[lis]]},
- Piecewise[lis, Undefined] /; DisjointConditionsQ[condlist, x]
- ]
- ToPW[___] = $Failed;
- DisjointConditionsQ[{_}, _] = True;
- DisjointConditionsQ[cond_List, x_]:=
- Reduce[And @@ Table[DisjointCondition[cond, i], {i, Length[cond]}], x]
- DisjointCondition[cond_, i_] :=
- If[TrueQ[cond[[i]]],
- True,
- Implies[cond[[i]], Not[And @@ Delete[cond, i]]]
- ]
- RealInverse[x^3, x]
- Surd[x, 3]
- RealInverse[x^7 + x^4 + 3 x - 1, x]
- Root[-1 - x + 3 #1 + #1^4 + #1^7 &, 1]
- (* Not invertible over the real line *)
- RealInverse[x^3 - 3 x + 1, x]
- $Failed
- RealInverse[x^(2/3) + Sqrt[x], x]
- ConditionalExpression[
- Root[x^6 - 3 x^4 #1 + (3 x^2 - 2 x^3) #1^2 + (-1 - 6 x) #1^3 + #1^4 &, 1],
- x >= 0
- ]
- RealInverse[Sign[x] (Abs[x]^(2/3) + Sqrt[Abs[x]]), x]
- inverseFunc[x_] = x /. Solve[x^3 == y, x, Reals][[1]] /. y -> x;
- N@inverseFunc[3]
- N@inverseFunc[-1]
- (*1.44225*)
- (*-1.*)
- x /. Solve[x^3 == y, x, Reals]
- (* {Root[-y + #1^3 &, 1]} *)
- Plot[%, {y, -10, 10}, AxesLabel -> {y, x}]
- invfun[g_] := N[x /. First@Solve[g[x] == #, x, Reals]] &
- f[x_] := x^3
- invfun[f][y]
- Plot[invfun[f][y], {y, -10, 10}, AxesLabel -> {y, x}]
Add Comment
Please, Sign In to add comment