Real Part in Mathematica: How to Extract the Real Values from Fractions

  • Mathematica
  • Thread starter member 428835
  • Start date
  • Tags
    Mathematica
In summary, the conversation is about a user seeking help with extracting the real component of a fraction with variables and imaginary numbers. They have tried using the built-in function Re[], but it only echoes their input. Another user suggests using ComplexExpand, which simplifies the fraction and removes any imaginary numbers. The original user realizes their mistake and thanks the helper for their solution.
  • #1
member 428835
Hi PF!

I have some variables that are all real, and I have a few ##i##s, all in a fraction. When I ask Mathematica to give me the real part of the entire fraction, ##Re[]##, it simply echoes my input, not giving me anything useful. Any help is greatly appreciated.
 
Physics news on Phys.org
  • #2
Can you post the code?
 
  • #3
Screen Shot 2018-02-24 at 5.59.52 PM.png
 

Attachments

  • Screen Shot 2018-02-24 at 5.59.52 PM.png
    Screen Shot 2018-02-24 at 5.59.52 PM.png
    14.4 KB · Views: 480
  • #4
Last line is output
 
  • #5
Looks fine to me. Apparently the expression doesn’t simplify much
 
  • #6
You could try using ComplexExpand:
MM.png
 

Attachments

  • MM.png
    MM.png
    2.7 KB · Views: 952
  • #7
phyzguy said:
You could try using ComplexExpand:
View attachment 221008
Yea I've tried this before. I should have been more specific: see what I want is the real component without any imaginary numbers. Like multiplying by the conjugate and simplifying. Do you know if there a built in function that does this?
 
  • #8
joshmccraney said:
Yea I've tried this before. I should have been more specific: see what I want is the real component without any imaginary numbers. Like multiplying by the conjugate and simplifying. Do you know if there a built in function that does this?

Look again at my post. That's what ComplexExpand does. There are no "i's" in the final answer.
 
  • Like
Likes member 428835
  • #9
phyzguy said:
Look again at my post. That's what ComplexExpand does. There are no "i's" in the final answer.
Ohhhhh shooot, sorry! I saw the variable ##\lambda i## and thought there was an ##i## in the solution. Sorry and thanks!
 

1. How do I extract the real values from fractions using Mathematica?

To extract the real values from fractions in Mathematica, you can use the RealPart function. This function takes in an expression and returns the real part of that expression as a new expression. For fractions specifically, you can use the function like this: RealPart[numerator/denominator]. This will return the real part of the fraction as a new expression.

2. Can I use RealPart to extract the real values from a list of fractions?

Yes, you can use RealPart to extract the real values from a list of fractions. However, you will need to apply the function to each individual fraction in the list. For example, if you have a list of fractions called "myFractions", you can use the Map function to apply RealPart to each fraction in the list like this: Map[RealPart, myFractions]. This will return a new list with the real values extracted from each fraction.

3. How does Mathematica handle complex numbers when using RealPart?

When using RealPart in Mathematica, the function will return only the real part of complex numbers. This means that if you have a complex number with both a real and imaginary part, RealPart will only return the real part and discard the imaginary part. If you want to keep the imaginary part, you can use the ComplexExpand function to expand the complex number into its real and imaginary parts, and then use RealPart on the real part.

4. Can I use RealPart to extract the real values from symbolic expressions?

Yes, you can use RealPart to extract the real values from symbolic expressions in Mathematica. However, keep in mind that RealPart will only work on expressions that have a defined real part. If the expression does not have a real part, RealPart will return an error. To avoid this, you can use the Assumptions option in RealPart to specify that the expression is real. For example, RealPart[expression, Assumptions -> x>0] will return the real part of the expression while assuming that x is a positive real number.

5. Is there a way to extract the real values from fractions without using RealPart?

Yes, there are other ways to extract the real values from fractions in Mathematica. One way is to use the Re function, which returns the real part of a complex number or expression. Another way is to use the Chop function, which removes small complex parts from an expression and returns the real part. Finally, you can also use the //N function to convert the fraction into a decimal approximation, which will automatically extract the real values.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
823
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
932
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
2K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
5K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
1K
Replies
2
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
6
Views
7K
  • Calculus and Beyond Homework Help
Replies
4
Views
1K
Back
Top