0
$\begingroup$

I have this code:

\[Alpha]=0.86;
\[Beta]=0.6;
g=0.0005;
p[x_,y_,t_,ta_,f_,fa_,u_]:=(((\[Alpha]^\[Alpha])((1-\[Alpha])^(1-\[Alpha])) (y-(t+ta)*x-(f+fa)))/u)^(1/(1-\[Alpha]));
r[x_,y_,t_,ta_,f_,fa_,u_]:=(p[x,y,t,ta,f,fa,u](g))((1/(p[x,y,t,ta,f,fa,u](\[Beta])(g)))^(\[Beta]/(\[Beta]-1)))-1((1/(p[x,y,t,ta,f,fa,u](\[Beta])(g)))^(1/(\[Beta]-1)));

Table[
 
 y = 70000;
 t = 600;
 f = 0;
 ta = 0;
 fa = 0;
 ra = 45000;
 
 Lu[u_] := (solution = 
    FindRoot[{r[x, y, t, ta, f, fa, u] - ra == 0}, {xbar, 10}, 
     AccuracyGoal -> 1]; xbar /. solution);]

There is more code after this inside the table function, but the FindRoot part gives me this error:

"ReplaceAll::reps: {FindRoot[{r[x,y,t,ta,f,fa,3000]-ra==0},{xbar,10},AccuracyGoal->1]} is neither a list of replacement rules nor a valid dispatch table, and so cannot be used for replacing."

Any help on solving this would be greatly appreciated.

$\endgroup$
5
  • $\begingroup$ [Alpha] is not defined. $\endgroup$ Nov 4, 2021 at 20:12
  • $\begingroup$ Instead of Lu[u_]... try just FindRoot[{r[x,y,t,ta,f,fa,u]-ra==0},{xbar,10},AccuracyGoal->1] with a value for u that makes this fail substituted in there. Exactly what does the result of that look like? Is that something in exactly the correct form that will make sense when you try to use that with /. ? The more usual form is Lu[u_]:=xbar/.FindRoot[...] Is there a good reason you are not doing that? $\endgroup$
    – Bill
    Nov 4, 2021 at 20:13
  • $\begingroup$ If I just write that, it treats it as text $\endgroup$ Nov 4, 2021 at 20:31
  • $\begingroup$ @Bill There is a good reason, becayse Lu[u_] is being used in another function later on $\endgroup$ Nov 5, 2021 at 12:30
  • $\begingroup$ I am trying to tell you how to find and fix the error you are getting so you can later get the solution you want. You reposted the same question and people told you to do the same thing that I did. $\endgroup$
    – Bill
    Nov 5, 2021 at 14:49

0

Your Answer

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