Group Abstract Group Abstract

Message Boards Message Boards

Define and solve formula syntax problem

Posted 4 years ago
POSTED BY: Karl S
7 Replies

I am getting no errors:

Kramer[Z_, \[Lambda]_, T_, x_] := 
  108*10^-4*Z*
   Log[Konst[\[Lambda]]]/((T/100)^(3/
         2)*\[Lambda]^2)*((electrondensity[x, Z, 
        Avog])/(electrondensitycrit[\[Lambda]]))^2;
Integrate[Kramer[Z, \[Lambda], T, x], x]
POSTED BY: Gianluca Gorni
Posted 4 years ago
Kramer[Z_, \[Lambda]_, T_, x_] := 
      108*10^-4*Z*
       Log[Konst[\[Lambda]]]/((T/100)^(3/
             2)*\[Lambda]^2)*((electrondensity[x, Z, 
            Avog])/(electrondensitycrit[\[Lambda]]))^2;
    Plot[Integrate[Kramer[12, 10.6, 30, x], x], {x, 0, 40}]

I get

SetDelayed::write: Tag Times in (5.20617*10^-6 [Lambda]^2 Log[6.57374*10^25 [Lambda]] Z)[Z,[Lambda],T,x_] is Protected.

and the plot is empty

POSTED BY: Karl S

You must give a numerical value Avog and decide what function is Konst. Also, you must wrap Integrate in Evaluate, to avoid the trap of the order of evaluation:

electrondensity[x_, Z_, Avog_] := (7*Avog*Z)/(118)*(1/x)^3;
electrondensitycrit[\[Lambda]_] := 1.1 10^21/\[Lambda]^2;
Kramer[Z_, \[Lambda]_, T_, x_] := 
  108*10^-4*Z*
   Log[Konst[\[Lambda]]]/((T/100)^(3/
         2)*\[Lambda]^2)*((electrondensity[x, Z, 
        Avog])/(electrondensitycrit[\[Lambda]]))^2;
Block[{Konst = Identity, 
  Avog = Quantity[1, "AvogadroConstant"] // QuantityMagnitude}, 
 Plot[Evaluate[Integrate[Kramer[12, 10.6, 30, x], x]], {x, 0, 40}]]
POSTED BY: Gianluca Gorni
Posted 4 years ago

Probably because of preexisting conflicting definitions. Quit the kernel and start over.

Integrate[Kramer[12, 10.6, 30, x], x]
(* -((7.42291*10^-42 Avog^2 (50.0099 + Log[T]))/x^5) *)

Avog and T do not have numeric values so a Plot cannot be generated.

POSTED BY: Rohit Namjoshi

Also, beware of the expression 4*T/100 *\[Lambda]*2 \[Pi].

Mathematica reads it as 4*(T/100) *\[Lambda]*2 \[Pi], which may not be what you have in mind.

POSTED BY: Gianluca Gorni

This works well enough for me:

electrondensity[x_, Z_, Avog_] := (7*Avog*Z)/(118)*(1/x)^3
electrondensitycrit[\[Lambda]_] := 1.1 10^21/\[Lambda]^2;
Solve[electrondensity[x, 12, Avog] == 
  electrondensitycrit[10.6], x, Reals]

It is somewhat tricky, because Mathematica may interpret the cubic root in the complex sense, while you may expect real values only. As for indicating the variables, it depends on what you want to do with the formula. Do you need only to display it, or for actual calculation?

POSTED BY: Gianluca Gorni
Posted 4 years ago

Ok this works for me also now.

electrondensity[x_, Z_, Avog_] := (7*Avog*Z)/(118) * (1/x)^3
electrondensitycrit[\[Lambda]_] := 1.1 10^21/\[Lambda]^2
Konst[\[Lambda]_] := 
 4*T/(100 *\[Lambda]*2 \[Pi])/(0.577*6.626*10^-34 *3*10^8)

I want to integrate the following formula for x:

Kramer[Z_, \[Lambda]_, T_, x_] := 
 108*10^-4 *Z * 
  Log[Konst[\[Lambda]]]/((T/100)^(3/
        2)*\[Lambda]^2 ) *((electrondensity[
       x])/(electrondensitycrit[\[Lambda]]))^2

However, with defining this equation, the error:

SetDelayed::write: Tag Times in (5.20617*10^-6 [Lambda]^2 Log[6.57374*10^25 [Lambda]] Z)[Z,[Lambda],T,x_] is Protected.

occurs with the output: $Failed

POSTED BY: Karl S
Reply to this discussion
Community posts can be styled and formatted using the Markdown syntax.
Reply Preview
Attachments
Remove
or Discard