Solving equation using mathematica

  • Context: Mathematica 
  • Thread starter Thread starter 76Ahmad
  • Start date Start date
  • Tags Tags
    Mathematica
Click For Summary

Discussion Overview

The discussion revolves around solving a specific equation involving two variables, x and y, using Mathematica. Participants explore different programming approaches to iterate through specified ranges of x and y values to find solutions to the equation y^4 + 2y^2x^2 - 15x = 0.

Discussion Character

  • Technical explanation, Homework-related, Mathematical reasoning

Main Points Raised

  • One participant requests assistance in writing a Mathematica program to solve the equation for x values from 0 to 10,000 and y values from 0 to 100.
  • Another participant suggests using nested For loops to iterate through the values of y and x, checking for solutions to the equation.
  • A different approach using FindInstance is proposed, although there is uncertainty about whether it respects the desired order of solution attempts.
  • A participant reports the output from the first suggested method and questions whether all values were checked correctly, seeking a way to print diagnostic messages at intervals.
  • Another participant provides a modified version of the For loop that includes diagnostic messages to track the number of solutions found at specific intervals of x and y.

Areas of Agreement / Disagreement

Participants generally agree on the need for a programmatic approach to solve the equation, but there are differing opinions on the best method to implement this in Mathematica. The discussion remains unresolved regarding the effectiveness of the proposed solutions.

Contextual Notes

There are limitations regarding the assumptions made about the behavior of the functions used, as well as the output format and the range of values being checked. The effectiveness of the diagnostic messages and their impact on understanding the solution process is also not fully resolved.

76Ahmad
Messages
46
Reaction score
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
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]
 
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
.
.
.
 
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
 

Similar threads

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