Solving equation using mathematica

  • Mathematica
  • Thread starter 76Ahmad
  • Start date
  • Tags
    Mathematica
In summary: From In[1]:= y=100 x=50 1 solutionsFrom In[1]:= y=100 x=100 1 solutionsIn summary, we can use For loops and Mod to solve an equation of x and y that is equal to 0 and try all the values of x and y within a certain range. By using If statements, we can print diagnostic messages to check the progress of the program.
  • #1
76Ahmad
48
0
Hello every one, I need help please...

How to write in mathematica to solve an equation of x and y that is equal to 0,
(i.e. y^4+2y^2x^2-15x=0)
and let the program try all the value of x=0,1,2,3,...,10000.
and all the value of y=0,1,2,3,...,100.

The program should start with x=0 and try all the 100 value of y,
and then go to the next x.

Please help..thanks
 
Physics news on Phys.org
  • #2
How about just some For loops:

Code:
For[y = 0, y <= 10000, y++,
 For[x = 0, x <= 100, x++,
  If[y^4 + 2 y^2 x^2 - 15 x == 0,
    Print["My x: ", x, " my y: ", y];
    ];
  ]
 ]

or FindInstance does this but I'm not sure if we can assume the function is attempting the solutions in the order you wish.

Code:
FindInstance[
 y^4 + 2 y^2 x^2 - 15 x == 0 && 0 <= x <= 10000 && 0 <= y <= 100, {x, 
  y}, Integers]
 
  • #3
I tried the the first one and the out put was:

My x: 0 my y: 0

I do not know if its checked all the values correctly?
how to make it print for example on each 50x

x=50 no solutions
x=100 no solutions
x=150 no solutions
.
.
.
 
  • #4
Perhaps you can learn how to use If and Mod to print diagnostic messages.

In[1]:= numsolutions=0;
For[y=0,y<=10000,y++,
For[x=0,x<=100,x++,
If[y^4+2 y^2 x^2-15 x==0,numsolutions++;Print["My x: ",x," my y: ",y];];
If[Mod[y,50]==0&&Mod[x,50]==0, Print["y=",y," x=",x, " ", numsolutions," solutions"]];
]
]

From In[1]:= My x: 0 my y: 0
From In[1]:= y=0 x=0 1 solutions
From In[1]:= y=0 x=50 1 solutions
From In[1]:= y=0 x=100 1 solutions
From In[1]:= y=50 x=0 1 solutions
From In[1]:= y=50 x=50 1 solutions
From In[1]:= y=50 x=100 1 solutions
From In[1]:= y=100 x=0 1 solutions
 
  • #5
.Hello,

Thank you for reaching out for help with solving your equation using Mathematica. Mathematica is a powerful tool for solving mathematical equations and can handle a wide range of complex equations.

To solve your equation, you can use the built-in function "NSolve" in Mathematica. This function allows you to specify the variables and the range of values you want to test for each variable.

In your case, you can write the following code:

NSolve[y^4 + 2 y^2 x^2 - 15 x == 0 && 0 <= x <= 10000 && 0 <= y <= 100, {x, y}]

This code will solve your equation for all values of x between 0 and 10000 and all values of y between 0 and 100. The output will give you a list of solutions in the form of {x -> value, y -> value}.

If you want to see the solutions in a table format, you can use the "Table" function in Mathematica. For example:

Table[NSolve[y^4 + 2 y^2 x^2 - 15 x == 0 && 0 <= x <= 10000 && 0 <= y <= 100, {x, y}], {x, 0, 10000}]

This code will give you a table of solutions for each value of x between 0 and 10000.

I hope this helps you solve your equation using Mathematica. If you need further assistance, please do not hesitate to reach out. Good luck with your research!
 

1. How do I enter an equation into Mathematica?

To enter an equation into Mathematica, you can use the "Input" field at the top of the notebook interface. Alternatively, you can use the keyboard shortcut "Ctrl + =" to create a new input cell. You can then type your equation using standard mathematical notation, or use the provided buttons and menus for more advanced formatting options.

2. How can I solve an equation for a specific variable?

To solve an equation for a specific variable, you can use the "Solve" function in Mathematica. This function takes two arguments: the equation you want to solve and the variable you want to solve for. For example, if you have the equation "2x + 4 = 10" and you want to solve for x, you would use the command "Solve[2x + 4 == 10, x]".

3. Can Mathematica solve complex equations?

Yes, Mathematica is capable of solving complex equations. You can enter complex numbers using the "i" symbol, and use the "Solve" function as normal. Mathematica will give you the solutions in terms of complex numbers, if they exist.

4. How do I plot the solutions to an equation in Mathematica?

You can use the "Plot" function in Mathematica to plot the solutions to an equation. This function takes two arguments: the equation you want to plot and the range of values for the variable. For example, if you want to plot the solutions to the equation "x^2 + y^2 = 1" for values of x between -2 and 2, you would use the command "Plot[Sqrt[1-x^2], {-2, 2}]".

5. Can I use Mathematica to solve differential equations?

Yes, Mathematica has built-in functions for solving differential equations. You can use the "DSolve" function to find the general solution to a differential equation, or the "NDSolve" function to find a numerical solution. You can also use the "Manipulate" function to visually explore the behavior of a differential equation by changing its parameters.

Similar threads

  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
109
  • MATLAB, Maple, Mathematica, LaTeX
Replies
4
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
2
Views
238
  • MATLAB, Maple, Mathematica, LaTeX
Replies
8
Views
3K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
1
Views
810
  • MATLAB, Maple, Mathematica, LaTeX
Replies
3
Views
1K
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
1K
  • Precalculus Mathematics Homework Help
Replies
6
Views
596
  • MATLAB, Maple, Mathematica, LaTeX
Replies
5
Views
978
Back
Top