Menu Close

please-help-Write-an-algorithm-that-will-find-the-solution-of-the-equation-f-x-x-when-x-lt-0-x-when-x-0-




Question Number 46738 by Umar last updated on 30/Oct/18
please help    Write an algorithm that will find  the solution of the equation            f(x)= { ((−x, when x<0)),((x,     when x≥0)) :}
$${please}\:{help} \\ $$$$ \\ $$$${Write}\:{an}\:{algorithm}\:{that}\:{will}\:{find} \\ $$$${the}\:{solution}\:{of}\:{the}\:{equation} \\ $$$$\:\:\:\:\:\:\:\:\:\:{f}\left({x}\right)=\begin{cases}{−{x},\:{when}\:{x}<\mathrm{0}}\\{{x},\:\:\:\:\:{when}\:{x}\geqslant\mathrm{0}}\end{cases} \\ $$
Commented by hassentimol last updated on 31/Oct/18
I think it may be this :     ask for x     if x< 0 :         return −x     else :        return x    I also think it would be like that on python :  x = float(input(′′value of x ?′′))  if (x<0) :      print ((−1)∗x)  else :      print(x)
$$\mathrm{I}\:\mathrm{think}\:\mathrm{it}\:\mathrm{may}\:\mathrm{be}\:\mathrm{this}\:: \\ $$$$\:\:\:\mathrm{ask}\:\mathrm{for}\:\mathrm{x} \\ $$$$\:\:\:\mathrm{if}\:\mathrm{x}<\:\mathrm{0}\:: \\ $$$$\:\:\:\:\:\:\:\mathrm{return}\:−\mathrm{x} \\ $$$$\:\:\:\mathrm{else}\:: \\ $$$$\:\:\:\:\:\:\mathrm{return}\:\mathrm{x} \\ $$$$ \\ $$$$\mathrm{I}\:\mathrm{also}\:\mathrm{think}\:\mathrm{it}\:\mathrm{would}\:\mathrm{be}\:\mathrm{like}\:\mathrm{that}\:\mathrm{on}\:\mathrm{python}\:: \\ $$$$\mathrm{x}\:=\:\mathrm{float}\left(\mathrm{input}\left(''\mathrm{value}\:\mathrm{of}\:\mathrm{x}\:?''\right)\right) \\ $$$$\mathrm{if}\:\left(\mathrm{x}<\mathrm{0}\right)\:: \\ $$$$\:\:\:\:\mathrm{print}\:\left(\left(−\mathrm{1}\right)\ast\mathrm{x}\right) \\ $$$$\mathrm{else}\:: \\ $$$$\:\:\:\:\mathrm{print}\left(\mathrm{x}\right) \\ $$
Commented by Umar last updated on 31/Oct/18
thank you sir
$${thank}\:{you}\:{sir} \\ $$

Leave a Reply

Your email address will not be published. Required fields are marked *