## Issues with Equations that have "No Solution"

9 posts
• Page

**1**of**1**- matthewmwps
- Junior Member
**Posts:**5**Joined:**Thu Oct 11, 2018 2:48 am**Calculators:**Casio Classpad fx-cp400

### Issues with Equations that have "No Solution"

Hi everyone,

I'm trying to create a User Defined Function to assist me in finding the number of solutions to 2 simultaneous Equations.

My plan is to have the function take three inputs: Equation 1, Equation 2, and the variable to solve for. After doing various calculations, it would then output the values that would give both Equations 1: the same gradient, and 2: the same constant.

To be more specific, i plan on having the function give its output in this format:

{"M=",{Solutions},"C=",{Solutions}}

I've been testing my work against these two equations:

mx+7y=12

7x+my=m

For which the gradient should give "m=-7,m=7", and the constant should give "No Solution".

So far, the calculations themselves are working as intended. However, when either solve function gives "No Solution", like the equations i'm testing with, the entire output would become "No Solution".

Is it possible to change this output from being just "No Solution" to instead being {"M=",{m=-7,m=7},"C=",{No Solution}}?

I'm trying to create a User Defined Function to assist me in finding the number of solutions to 2 simultaneous Equations.

My plan is to have the function take three inputs: Equation 1, Equation 2, and the variable to solve for. After doing various calculations, it would then output the values that would give both Equations 1: the same gradient, and 2: the same constant.

To be more specific, i plan on having the function give its output in this format:

{"M=",{Solutions},"C=",{Solutions}}

I've been testing my work against these two equations:

mx+7y=12

7x+my=m

For which the gradient should give "m=-7,m=7", and the constant should give "No Solution".

So far, the calculations themselves are working as intended. However, when either solve function gives "No Solution", like the equations i'm testing with, the entire output would become "No Solution".

Is it possible to change this output from being just "No Solution" to instead being {"M=",{m=-7,m=7},"C=",{No Solution}}?

- lephe
- Member
**Posts:**40**Joined:**Fri Aug 21, 2015 11:54 am**Location:**France**Calculators:**Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860 GII, Casio fx-CG 50

### Re: Issues with Equations that have "No Solution"

Hi

Could you post your code please? Also, are you working on an fx-CP 400?

Could you post your code please? Also, are you working on an fx-CP 400?

- lentulion
- Junior Member
**Posts:**3**Joined:**Fri Sep 20, 2013 1:38 am**Calculators:**Casio fx-9860 GII

### Re: Issues with Equations that have "No Solution"

Those equation are lineal.

If there is not solution, maybe they are the some equation: one is a product of the another.

If there is not solution, maybe they are the some equation: one is a product of the another.

- matthewmwps
- Junior Member
**Posts:**5**Joined:**Thu Oct 11, 2018 2:48 am**Calculators:**Casio Classpad fx-cp400

### Re: Issues with Equations that have "No Solution"

lentulion wrote:Those equation are lineal.

If there is not solution, maybe they are some equation: one is a product of the another.

That might be true, at least for the constant, but that's not what i'm having issues about.

Regardless of whether or not they're linear to each over, (which would vary of the value of 'm' in those equations.) i'm only trying to find a way outputting information with "no solution" without the no solution taking over everything.

Last edited by matthewmwps on Fri Oct 12, 2018 11:57 pm, edited 1 time in total.

- matthewmwps
- Junior Member
**Posts:**5**Joined:**Thu Oct 11, 2018 2:48 am**Calculators:**Casio Classpad fx-cp400

### Re: Issues with Equations that have "No Solution"

lephe wrote:Hi

Could you post your code please? Also, are you working on an fx-CP 400?

Sure, i can try and show you my code. It's very linear, however, as it's again, a user-defined functioned. So instead of typing the entire 'code' itself, i'll write the steps and what output is expected. Apologies in advance if its hard to follow.

Last edited by matthewmwps on Fri Oct 12, 2018 11:52 pm, edited 1 time in total.

- matthewmwps
- Junior Member
**Posts:**5**Joined:**Thu Oct 11, 2018 2:48 am**Calculators:**Casio Classpad fx-cp400

### Re: Issues with Equations that have "No Solution"

Using these equations:

(a): mx+7y=12

(b): 7x+my=m

1: Solves both functions in terms of y to get the form y=x

(a): {y= 12/7- mx/7}

(b): {y= 1- 7x/m}

2: To get the constants, equations substitute x=0. (solve({equation},y)|x=0)

(a):{y=12/7}

(b):{y=1}

3: Used GetRight() to remove the "y="

(a): {12/7}

(b): {1}

4: Used Sum() command, as because there's only 1 item in each list it essentially just removes the brackets

(a):12/7

(b):1

5: combined both values into another solve function to find the values which give an equal constant.

Solve(12/7=1,m)-> No solution

(which is what is meant to happen, but the issue is what happens after, which i'll explain again later)

From here, we calculate the gradient, which is similar yet a little more complex.

6: Again, it solves both Equations in terms of y, but it also subtracts those solutions from when x=0.

(this removes 'c' from the form "y=mx+c")

(a):(Solve(a,y)-Solve(a,y)|x=0))->y=-mx/7

(b):(Solve(b,y)-solve(b,y)|x=0))->y=-7x/m

7: GetRight() is used again to get:

(a):{-mx/7}

(b):{-7x/m)

8: However, before it removes the brackets with the Sum() function, I divided both by x and then simplified them. This was so only the variable 'm' remains.

(a)Simplify ({-mx/7}/x)->{-m/7}

(b)Simplify({-7x/m}/x)->{-7/m}

9: Used Sum()

(a):-m/7

(b):-7/m

10: put both values into a solve function to get values of m.

Solve (a=b,m)->{m=-7,m=7}

With all these steps done the function would output it as {"M=",(solutions),"C=",(Solutions)}

These calculations work fine separately and give the output desired. The issue i'm having is that when i put them both together, instead of getting:

{{"M=",{m=-7,m=7},"C=",No Solution}

I only get

No solution

If needed, i can try and write (or attach an image maybe idk) the code word for word, but it's all the steps i said before combined into one so it's very long and easy to confuse yourself with.

Finally, yes am working with an fx-CP 400.

Again, sorry if you've gotten confused or lost. I've tried to explain it as easy as possible but I'm not sure if i did a very good job communicating it.

(a): mx+7y=12

(b): 7x+my=m

1: Solves both functions in terms of y to get the form y=x

(a): {y= 12/7- mx/7}

(b): {y= 1- 7x/m}

2: To get the constants, equations substitute x=0. (solve({equation},y)|x=0)

(a):{y=12/7}

(b):{y=1}

3: Used GetRight() to remove the "y="

(a): {12/7}

(b): {1}

4: Used Sum() command, as because there's only 1 item in each list it essentially just removes the brackets

(a):12/7

(b):1

5: combined both values into another solve function to find the values which give an equal constant.

Solve(12/7=1,m)-> No solution

(which is what is meant to happen, but the issue is what happens after, which i'll explain again later)

From here, we calculate the gradient, which is similar yet a little more complex.

6: Again, it solves both Equations in terms of y, but it also subtracts those solutions from when x=0.

(this removes 'c' from the form "y=mx+c")

(a):(Solve(a,y)-Solve(a,y)|x=0))->y=-mx/7

(b):(Solve(b,y)-solve(b,y)|x=0))->y=-7x/m

7: GetRight() is used again to get:

(a):{-mx/7}

(b):{-7x/m)

8: However, before it removes the brackets with the Sum() function, I divided both by x and then simplified them. This was so only the variable 'm' remains.

(a)Simplify ({-mx/7}/x)->{-m/7}

(b)Simplify({-7x/m}/x)->{-7/m}

9: Used Sum()

(a):-m/7

(b):-7/m

10: put both values into a solve function to get values of m.

Solve (a=b,m)->{m=-7,m=7}

With all these steps done the function would output it as {"M=",(solutions),"C=",(Solutions)}

These calculations work fine separately and give the output desired. The issue i'm having is that when i put them both together, instead of getting:

{{"M=",{m=-7,m=7},"C=",No Solution}

I only get

No solution

If needed, i can try and write (or attach an image maybe idk) the code word for word, but it's all the steps i said before combined into one so it's very long and easy to confuse yourself with.

Finally, yes am working with an fx-CP 400.

Again, sorry if you've gotten confused or lost. I've tried to explain it as easy as possible but I'm not sure if i did a very good job communicating it.

- lephe
- Member
**Posts:**40**Joined:**Fri Aug 21, 2015 11:54 am**Location:**France**Calculators:**Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860 GII, Casio fx-CG 50

### Re: Issues with Equations that have "No Solution"

The math process is clear. When you say "put them both together", do you mean solving both the constant and the gradient in the same program, or finding both at the same time?

It may be a silly suggestion, but if you combine naively, the calculator might try to generate all valid combinations of M and C (like {"(M,C)=",{(m,c)=(-7,0)}}), and currently there are none.

If you just do the calculations one after the other, I don't see how it could go wrong because there is no obvious global state, ie. no way for the first calculation to influence the other.

It may be a silly suggestion, but if you combine naively, the calculator might try to generate all valid combinations of M and C (like {"(M,C)=",{(m,c)=(-7,0)}}), and currently there are none.

If you just do the calculations one after the other, I don't see how it could go wrong because there is no obvious global state, ie. no way for the first calculation to influence the other.

- matthewmwps
- Junior Member
**Posts:**5**Joined:**Thu Oct 11, 2018 2:48 am**Calculators:**Casio Classpad fx-cp400

### Re: Issues with Equations that have "No Solution"

lephe wrote:The math process is clear. When you say "put them both together", do you mean solving both the constant and the gradient in the same program, or finding both at the same time?

It may be a silly suggestion, but if you combine naively, the calculator might try to generate all valid combinations of M and C (like {"(M,C)=",{(m,c)=(-7,0)}}), and currently there are none.

If you just do the calculations one after the other, I don't see how it could go wrong because there is no obvious global state, ie. no way for the first calculation to influence the other.

By "put them both together" I mean I solve them both separately within the same function, then display them both as separate values

So for example, when I define the function, it'll be:

Define <Function_Name>(<Variables>)={"M=",(Solve function Gradient),"C=",(Solve function Constant)}.

It's possible they're trying to combine the solutions as you say, which would mean I need some other method of displaying this.

The strange thing about that though is when I try the same display idea but using different equations such as:

{"M=",Solve(x^2=4,x),"C=",Solve(2x=4)}, i get an output of {"M=",{x=2,x=-2},"C=",{x=2}}, which is what i want. It only seems to have an issue whenever one of those two solve functions has "no solution".

Regardless, at least i know it's just the display process that i need to fix, not the process itself. Worse comes to worse I'll just make two separate functions. Though I'm kind of hoping i can find some way around this so I can keep them all as one big function. (that way i don't need to input my equations twice.)

- lephe
- Member
**Posts:**40**Joined:**Fri Aug 21, 2015 11:54 am**Location:**France**Calculators:**Casio fx-9750 G II, Casio fx-9750 G II (SH4), Casio fx-9860 GII, Casio fx-CG 50

### Re: Issues with Equations that have "No Solution"

If this is just about display, you might try varied combinations of solving one, displaying it, then solving the other; or putting them in two functions and calling both functions when displaying... it shouldn't work with any reasonable language but well, Casio Basic has proven to be weird in many ways, so I'm not really sure whether the hypothesis is sane or not.

9 posts
• Page

**1**of**1**Return to Casio Basic Development

### Who is online

Users browsing this forum: No registered users and 3 guests