Question about Mathematica

  1. Hi,
    I have a question about fitting in Mathematica.I have a function like this:
    F=T*Y^(0.5) T is temperature but Y obtained from this coupled equation 1-u*Y=u(1-u/Y^.4)^.5*Y
    I have T and F from experimental I want to obtain u from fitting.
    could you please advise me how can I do it by Mathematica.
    Thank you
  2. jcsd
  3. Re: Question about Mathemtica

    You don't need to fit this. You can solve for u in terms of T and F eliminating Y.

    Try something like:
    Solve[equation1, u] /. Solve[equation2, Y]

    This will solve the second equation for Y and substitute that into the solution for u.
    Last edited: Apr 19, 2011
  4. Re: Question about Mathemtica

    Thanks ,actually you cant do that because as I told you this a coupled equation,I apology because in formula I forgot something the second formula is something like this
    1-u*Y=u(1-u/Y^.4)^.5*Y^.45 and then I should put this in this equation F=T*Y^(0.5).
    now could you please me tell what to do.I appreciate it.
  5. Re: Question about Mathemtica

    personally I prefer matlab or excel for numerical solutions over mathematica; mathematica can do it but I find mathematica better for analytical solutions.

    My advice is just make the fit in excel and get an equation for Y, then plug that into mathematica to get an expression for u.
  6. Re: Question about Mathemtica

    When you do a fit you need to have more unknowns than equations. For example, if you do a simple linear regression you have an equation of the form y=mx+b where x and y are known (your data points) and m and b are unknown. So you have one equation in two unknowns and you do fitting.

    In your case T and F are knowns and u and Y are unknowns. You have two equations in two unknowns, so you cant do fitting, there is nothing to fit, you just solve the equations. The only thing close to a "fit" that you can do in this case is to average the results.
    Last edited: Apr 20, 2011
  7. Re: Question about Mathemtica

    Not solving your question, just typing your equations like i would on paper, to be sure you get your initial equations communicated to us (and for easier viewing), please check if i made an error:

    Your first equation: (1)
    Your second equation: (2)
    [tex]1-\left(u \cdot y\right)=u \cdot y^{0.45} \cdot \sqrt{1-\frac{u}{y^{0.4}}}[/tex]

    Again with your statement from your first post, "i got f and t from experimental data" you should already be able to solve equation (1) for y, right?
  8. Re: Question about Mathemtica

    Yes.I apology again I forget a very Important one let me write the exact equation,just because I wanted to simplify it I made mistake the exact equation is:


    so this one is exact one as you can see the y depeds on T and u.actually I solve my problem
    in just by hand.I am seeking to alternative is important for me
    once again I apologies for my mistake,I really appreciate it
  9. Re: Question about Mathemtica

    OK, here is the process:
    1) solve the first equation for y
    2) substitute into the second equation
    3) solve the second equation for f to get an expression for f in terms of t, a, and u
    4) put your data in the form {{t1,f1},{t2,f2},...}
    5) use FindFit[data,expr,{a,u},{t}]
  10. Re: Question about Mathemtica

    I write this small program in mathematica
    F[p_, k_] :=
    Block[{y}, Solve[k*y - 1 == 0, y];
    but when I write this
    F[.2, .4]
    I get
    0.04 y
    Do somebody know where I made mistake?
  11. Re: Question about Mathemtica

    Yes, you forgot to substitute the expression for y into the output expression.
  12. Re: Question about Mathemtica

    could please you explain more?
    thank you
  13. Re: Question about Mathemtica

    In the first line you solved for y, but then you never did anything with that solution. You didn't set y to anything. So when it came time to evaluate the second line y had not changed and was just left as the symbol y. You can fix that one of two ways:

    F[p_, k_] :=
    Block[{y}, p^2*y /. Solve[k*y - 1 == 0, y]]


    F[p_, k_] :=
    Block[{y}, y=1/k;

    In the first one you set the value of y by substitution (/.), and in the second you set the value of y directly (=).
  14. Re: Question about Mathemtica

    thank you
  15. Re: Question about Mathemtica

    what is meaning of this term in [Block]for example:

    what is meaning of {} here for variable

    thank you
  16. Re: Question about Mathemtica

    The {} simply denotes a list. Mathematica uses very consistent notation, [] always denotes function arguments, () always denotes operator precedence.
  17. Re: Question about Mathemtica

    I have defined this function
    F[p_, k_] :=
    p^2*y /. Solve[k*y - 1 == 0, y]]
    I want to minimize it, so I write:

    Minimize[F, k] and the answer is
    {F, {k -> 0}}
    I know I can write it very simply.
    But I want to know where I made mistake in this way of writing.
    Thank you
  18. Re: Question about Mathemtica

    Remember that F is not defined. What is defined is F[_,_]. Since F is not defined it is not a function of k and all values of k qualify as a minimum.
  19. Re: Question about Mathemtica

    Thank you , but I think I define it before,when I inserted F[p_,k_].

    could you please explain more how can I get correct result by this way?
    Thank you very much
  20. Re: Question about Mathemtica

    To actually minimize the function you need to call

    Minimize[F[p,k], k]

    Defining F and defining F[_,_] are two different things. In this case F is not defined at all, but F[p,k] is defined and evaluates to {p^2/k}. Do you see the difference?
  21. Re: Question about Mathemtica

    Thank you very much.
Know someone interested in this topic? Share this thead via email, Google+, Twitter, or Facebook

Have something to add?