Mathetica function (help fix my equation please)

  • Context: Mathematica 
  • Thread starter Thread starter Shawj02
  • Start date Start date
  • Tags Tags
    Function
Click For Summary

Discussion Overview

The discussion revolves around troubleshooting a Mathematica function related to summation equations. Participants are addressing errors encountered when attempting to define a recursive sequence and are exploring formatting issues with LaTeX for better presentation of mathematical expressions.

Discussion Character

  • Technical explanation
  • Mathematical reasoning
  • Debate/contested

Main Points Raised

  • One participant describes an issue with Mathematica where the expected outputs for a recursive sequence are not being produced, leading to specific error messages.
  • Another participant suggests using TexForm to convert Mathematica expressions to LaTeX as a potential solution.
  • A participant shares their experience with converting equations to LaTeX and mentions issues with "Reals" and "Absolutes" in LaTeX formatting.
  • Some participants identify problems with the summation syntax used in the original equation, suggesting that it should use a different variable for iteration.
  • One participant expresses satisfaction after correcting their summation input but seeks further assistance on how to write absolute values and real numbers in LaTeX.
  • A participant indicates a preference for using plain code over formatted LaTeX for troubleshooting purposes, highlighting the difficulty in finding errors with fancy formatting.

Areas of Agreement / Disagreement

There is no consensus on the best approach to formatting in LaTeX, as preferences vary among participants. Additionally, while some participants agree on the need to correct the summation syntax, the discussion remains open regarding the best practices for LaTeX formatting.

Contextual Notes

Limitations include unresolved issues with specific LaTeX commands for "Reals" and "Absolutes," as well as the initial errors in the Mathematica summation syntax that have not been fully clarified.

Shawj02
Messages
19
Reaction score
0
Hi guys,

I have a problem with Mathematica. The equation (see attachment) is SUPPOSE TO give:
n[0]=n0
n[1]=x0-n0
n[2]=x1-x0+n0
n[3]=x2-x1+x0-n0
n[4]=x3-x2+x1-x0+n0
n[5]=x4-x3+x2-x1+x0-n0
n[6]=x5-x4+x3-x2+x1-x0+n0-1
...

But when I put in n[1] I get the following errors and output:

Sum::itraw: Raw object 1 cannot be used as an iterator. >>
Sum::vloc: The variable 1 cannot be localized so that it can be assigned to numerical values. >>
Sum::itraw: Raw object 1 cannot be used as an iterator. >>
Sum::vloc: The variable 1 cannot be localized so that it can be assigned to numerical values. >>
\sum _{1=1}^1 (-1)^{1-1} x_{1-1}-n_0

What do I need to change to give me an output of x_ 0 + n_ 0n[2] gives:
\sum _{2=1}^2 (-1)^2 x_{2-1}+n_0
when I want it to give me: x_1-x_0-n_0
 

Attachments

  • 1.jpg
    1.jpg
    7.6 KB · Views: 670
Last edited:
Physics news on Phys.org
jedishrfu said:
You might try TexForm to do a conversion to Latex:

http://reference.wolfram.com/language/ref/TeXForm.html

I been playing around with the LATEX thing.. using Mathematica's right click and "copy as Latex" function.
I have attached a copy of my original equation, below is an attempt to convert it into Latex.

\sum _{z=1}^z (-1)^z x_{z-1}-\sum _{z=6}^z 1+n_0 (-1)^z

There seems to be a problem with "Reals" and "Absolutes" How do I do these in Latex?
 

Attachments

  • 1.jpg
    1.jpg
    7.6 KB · Views: 683
Last edited:
The problem is your summation.
Shawj02 said:
\sum _{z=1}^z (-1)^z x_{z-1}-\sum _{z=6}^z 1+n_0 (-1)^z
\sum _{z=1}^z f(z) is bad input. It should be something like
\sum _{i=1}^z f(i)
 
Dale said:
The problem is your summation.
\sum _{z=1}^z f(z) is bad input. It should be something like
\sum _{i=1}^z f(i)

Yep, you're right! I've got it working perfectly now!

My other question is: How do I write the ABS and REALS in LATEX? (so I can post things on physics forms better)

so far I've got:

\sum _{j=1}^z (-1)^j x_{j-1}-\sum _{j=6}^z 1+n_0 (-1)^z
 

Attachments

  • 2.jpg
    2.jpg
    7.3 KB · Views: 655
Shawj02 said:
My other question is: How do I write the ABS and REALS in LATEX? (so I can post things on physics forms better)
When I am trying to troubleshoot I would rather just have the straight code. The fancy formatting is nice, but makes finding code errors more difficult. I know that isn't everyone's preference, but it is my preference. I would just use the "code" tag and copy and paste the Mathematica input.
 

Similar threads

  • · Replies 2 ·
Replies
2
Views
3K
  • · Replies 3 ·
Replies
3
Views
3K
  • · Replies 2 ·
Replies
2
Views
1K
  • · Replies 3 ·
Replies
3
Views
4K
  • · Replies 1 ·
Replies
1
Views
1K
  • · Replies 1 ·
Replies
1
Views
2K
  • · Replies 4 ·
Replies
4
Views
5K
  • · Replies 8 ·
Replies
8
Views
2K
  • · Replies 2 ·
Replies
2
Views
3K
Replies
1
Views
1K