Mathetica function (help fix my equation please)

  • Mathematica
  • Thread starter Shawj02
  • Start date
  • Tags
    Function
In summary, the conversation is about a problem with Mathematica where the equation is supposed to give a specific output but is resulting in errors and incorrect output. The solution is suggested to be using the TexForm function to convert the equation into Latex. There is also a discussion about writing ABS and REALS in Latex for posting on physics forums. The expert advises to use the "code" tag and copy and paste the Mathematica input for easier troubleshooting.
  • #1
Shawj02
20
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. >>
[tex]\sum _{1=1}^1 (-1)^{1-1} x_{1-1}-n_0[/tex]

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

Attachments

  • 1.jpg
    1.jpg
    7.6 KB · Views: 603
Last edited:
Physics news on Phys.org
  • #3
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.

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

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: 630
Last edited:
  • #4
The problem is your summation.
Shawj02 said:
[tex] \sum _{z=1}^z (-1)^z x_{z-1}-\sum _{z=6}^z 1+n_0 (-1)^z [/tex]
[tex] \sum _{z=1}^z f(z) [/tex] is bad input. It should be something like
[tex] \sum _{i=1}^z f(i) [/tex]
 
  • #5
Dale said:
The problem is your summation.
[tex] \sum _{z=1}^z f(z) [/tex] is bad input. It should be something like
[tex] \sum _{i=1}^z f(i) [/tex]

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:

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

Attachments

  • 2.jpg
    2.jpg
    7.3 KB · Views: 602
  • #6
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.
 

FAQ: Mathetica function (help fix my equation please)

How can I use Mathematica to fix my equation?

Mathematica is a powerful computational software program that can help you solve and fix equations. You can enter your equation into the program and use various functions and tools to manipulate and solve it.

What is the syntax for using Mathematica functions?

The basic syntax for using Mathematica functions is function[arguments]. You can also use optional arguments and multiple arguments, depending on the specific function you are using.

Can Mathematica solve any type of equation?

Mathematica can solve a wide range of equations, including algebraic, trigonometric, and differential equations. However, it may not be able to solve every equation, especially if it is highly complex or involves unknown variables.

How do I fix errors in my Mathematica equation?

If you encounter errors while using Mathematica to fix your equation, you can check the syntax and make sure all parentheses and brackets are properly closed. You can also use the built-in error checking functions in Mathematica to identify and fix any errors.

Can I use Mathematica to graph my equation?

Yes, Mathematica has powerful graphing capabilities that allow you to visualize your equation and its solutions. You can use various plotting and graphing functions to create 2D and 3D graphs of your equation.

Similar threads

Replies
2
Views
2K
Replies
3
Views
2K
Replies
3
Views
3K
Replies
1
Views
1K
Replies
4
Views
5K
Replies
8
Views
1K
Replies
2
Views
3K
Replies
1
Views
4K
Replies
9
Views
9K
Back
Top