1
$\begingroup$

I would like to know how to find the value of a function.

For example, consider one the most basic funcions

y[x] = x^2

The ploy is a parabola. So if I want y = 1200, I need to see on the graph approximate values to test for x to find it.

My questions is, in mathematica is there a function or any command where I can write y = 1200 and automatically generate the value of x?

$\endgroup$
1
  • 2
    $\begingroup$ Try Solve` like Solve[1200 == x^2, x] $\endgroup$
    – Jason B.
    Sep 3, 2020 at 22:25

1 Answer 1

1
$\begingroup$

The first option is always Solve (also NSolve). As @Jason showed, using Solve with a specific value will give you all possible solutions

f[x_] = x^2
Solve[f[x] == 1.2, x]

{{x -> -1.09545}, {x -> 1.09545}}

On the other hand as @Mark showed,

Solve[y == f[x], x]

{{x -> -Sqrt[y]}, {x -> Sqrt[y]}}

will give you all possible analytical solutions which you can use to generate values of x for any y. However these methods can be tricky when you have large and complicated functions (specially trigonometric functions where you might have to specify the domain like 0<x<2Pi as well). In that case you can use FindRoot

FindRoot[f[x] == 1.2, {x, 1.0}]
FindRoot[f[x] == 1.2, {x, -1.0}]

{x -> 1.09545} {x -> -1.09545}

FindRoot requires an initial guess and gives only one numerical solution closest to the initial guess.

$\endgroup$
1
  • $\begingroup$ Thanks for help me $\endgroup$
    – Slayz
    Sep 7, 2020 at 22:48

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.