Mathematica Asked by Slayz on March 11, 2021
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?
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.
Correct answer by Sumit on March 11, 2021
Get help from others!
Recent Questions
Recent Answers
© 2024 TransWikia.com. All rights reserved. Sites we Love: PCI Database, UKBizDB, Menu Kuliner, Sharing RPP