Skip to main content
Post Closed as "Duplicate" by Wjx, gwr, István Zachar, Mr.Wizard
added 33 characters in body; edited title
Source Link
mmal
  • 3.6k
  • 2
  • 20
  • 38

setting Setting a variable equal to the output of FindRoot

So I setdefine a function f[x]$f(x)$ as

f[x_] := x*E^(x*Exp[-x)x] - 0.1606416064; 

Then I set a variable 'actualroot'actualroot to the function FindRootFindRoot, starting at 3$x=3$

actualroot = FindRoot[ f[x]FindRoot[f[x], {x, 3} ] 

and get the output

{x -> 2.88976} 

Later, I want to compare this output with a different estimate (-2.88673$x\approx -2.88673$) of the root, and calculate error, so I have

Abs[ (actualroot - estimateroot)/actualroot ]actualroot] 

and iI get this output:

Abs[ (-2.88673 + (x -> 2.88976))/(x -> 2.88976) ] 

How do I get mathematicaMathematica to evaluate this expression? I also tried using N[]N[] function to give me a decimal evaluation, but it didn't work.

setting a variable equal to the output of FindRoot

So I set a function f[x]

f[x_] := x*E^(-x) - 0.16064 

Then I set a variable 'actualroot' to the function FindRoot, starting at 3

actualroot = FindRoot[ f[x], {x, 3} ] 

and get the output

{x -> 2.88976} 

Later I want to compare this output with a different estimate (-2.88673) of the root, and calculate error, so I have

Abs[ (actualroot - estimateroot)/actualroot ] 

and i get this output:

Abs[ (-2.88673 + (x -> 2.88976))/(x -> 2.88976) ] 

How do I get mathematica to evaluate this expression? I also tried using N[] to give me a decimal evaluation but it didn't work.

Setting a variable equal to the output of FindRoot

I define a function $f(x)$ as

f[x_] := x*Exp[-x] - 0.16064; 

Then I set a variable actualroot to the function FindRoot, starting at $x=3$

actualroot = FindRoot[f[x], {x, 3}] 

and get the output

{x -> 2.88976} 

Later, I want to compare this output with a different estimate ($x\approx -2.88673$) of the root, and calculate error, so I have

Abs[(actualroot - estimateroot)/actualroot] 

and I get this output:

Abs[(-2.88673 + (x -> 2.88976))/(x -> 2.88976)] 

How do I get Mathematica to evaluate this expression? I also tried using N[] function to give me a decimal evaluation, but it didn't work.

Source Link
DWC
  • 103
  • 1
  • 1
  • 4

setting a variable equal to the output of FindRoot

So I set a function f[x]

f[x_] := x*E^(-x) - 0.16064 

Then I set a variable 'actualroot' to the function FindRoot, starting at 3

actualroot = FindRoot[ f[x], {x, 3} ] 

and get the output

{x -> 2.88976} 

Later I want to compare this output with a different estimate (-2.88673) of the root, and calculate error, so I have

Abs[ (actualroot - estimateroot)/actualroot ] 

and i get this output:

Abs[ (-2.88673 + (x -> 2.88976))/(x -> 2.88976) ] 

How do I get mathematica to evaluate this expression? I also tried using N[] to give me a decimal evaluation but it didn't work.