2
$\begingroup$

I need a help to find k here:

$f(x)=-k^x + x^2$

It is not too simple. I have interest to find the single value of "k" where, inside interval {x,2,3}, the function have only one value to x when f(x) = 0.

In fact, using try and error I have already found the value:

ratio = -2.0870652286345332^x + x^2

Plot[ratio, {x, 2.715, 2.720}] 

FindMaximum[ratio, {x, 2.715, 2.720}]

NSolve[ratio == 0 && x >= 2, x]

XK Graph

I need to know, a better way to reach the value -2.0870652286345332 to k. Optimization? Solving? I was unable to got it.

Any insight are welcome.

Best regards

$\endgroup$
1
  • $\begingroup$ Welcome to Mathematica.SE! I suggest that: 1) You take the introductory Tour now! 2) When you see good questions and answers, vote them up by clicking the gray triangles, because the credibility of the system is based on the reputation gained by users sharing their knowledge. Also, please remember to accept the answer, if any, that solves your problem, by clicking the checkmark sign! 3) As you receive help, try to give it too, by answering questions in your area of expertise. $\endgroup$
    – bbgodfrey
    Commented Mar 23, 2015 at 23:52

3 Answers 3

4
$\begingroup$

Having just one root requires

eq1 = -k^x + x^2 == 0;
eq2 = D[-k^x + x^2, x] == 0
(* 2*x - k^x*Log[k] *)

FindRoot can solve for x and k simultaneously.

FindRoot[{eq1, eq2}, {{x, 2.5}, {k, 2}}]
(* {x -> 2.71828, k -> 2.08707} *)

Plot[(-k^x + x^2) /. %[[2]], {x, 2, 3}]

Mathematica graphics

$\endgroup$
4
$\begingroup$

For an exact solution:

f[k_, x_] = -k^x + x^2;

soln = Reduce[{f[k, x] == 0, D[f[k, x], x] == 0, x > 0}, {k, x}, 
   Reals] // ToRules

{k -> E^(2/E), x -> E}

f[k, x] /. soln

0

k /. soln // N[#, 17] &

2.0870652286345330

Plot[f[k /. soln, x], {x, 2, 3}]

enter image description here

$\endgroup$
0
$\begingroup$

There is not only one single value of k, where f[x,k]==0 in the range [2,3] at only one x-value, but the range of from k=2 to k=3^(2/3) matches to that condition. Get an impression with

    Manipulate[Plot[f[x, k], {x, 2, 3}, PlotRange -> 1], {k, 2, 2.1}]

enter image description here

Solve for k

    sol = 
    First[Solve[Reduce[f[x, k] == 0, k, Reals]]] // PowerExpand

     (*   {k -> x^(2/x)}    *)

    Plot[Evaluate[{k /. sol, k /. sol /. x -> 3}], {x, 2, 3}, 
         PlotRange -> {2, 2.1}]

enter image description here

For k in the range k=2 to k=3^(2/3)=2.08008 there f[x,k]==0 is fulfilled at only one x-value.

     {k /. sol /. x -> 2, k /. sol /. x -> 3, k /. sol /. x -> 3.}

     (*   {2, 3^(2/3), 2.08008}    *)

Here is the corresponding x value

    {sol2 = Solve[f[x, 3^(2/3)] == 0, x], N[sol2]} // Quiet

     (*   {{{x -> 
          3}, {x -> -((3 ProductLog[-(Log[3]/3)])/Log[3])}, {x -> -((
          3 ProductLog[Log[3]/3])/Log[3])}}, {{x -> 3.}, {x -> 
          2.47805}, {x -> -0.757697}}}    * 
$\endgroup$

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.