HP Forums

Full Version: possibly serious bug....need someone from HP...
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
This is a repost of a different problem, and while trying out various versions of this, I managed to reboot the calculator and another time crashed the calculator where I had to push the reset button hole in the back.

I was trying to find the intersection (algebraicly) between the functions:
y = atan(cot(pi*x))/pi + x -1/2 (staircase function)
and
y = (25-x^2)^(1/2) (circle of radius 5)

It has a solution for x=4. I can plot them and see the intersection.

So, I typed the following:

[attachment=5349]

The result is a blank matrix, []. Why didn't it solve it?

Then I tried the following, using f(x):= instead of f:=....as in here...

[attachment=5350]

Again with solve(f(x)=g(x),x) gives [] again...

So, first, I want to know why it doesn't solve it.

Next, without changing anything, I tried solve(f=g,x) instead of solve(f(x)=g(x),x), and got that it just hangs forever and I have to reset the calculator. The animated hourglass is going in the upper right.
After I reset it and try it again, it reboots the calculator.
On the virtual calculator it hangs for a bit and then reboots.

Let me know what you find out.
I also notice that when I use the f:=, g:= format (instead of f(x):=, g(x):=) method of defining the functions, and try solve(f(x)=g(x),x), I get a strange message where it's trying to evaluate pi(x) instead of pi*x. Then it gives an error message because of this.
You are confused: there is a difference between a function f and an expression g. A function has arguments unlike an expression. If f is a function, you can compute f(2) or f(x) and get an expression, while g(2) or g(x) does not mean anything.
Regarding solve, it solves polynomial-like equations, i.e. equations that can be rewritten like a polynomial equation, your equation can not be rewritten like that. For more general equations, there is no method for exact solving, you must switch to approx solving (fsolve). You can solve an expression=another expression with respect to a variable, but solving a function=another function does not mean anything : with respect to what would you solve?. I will add a check to avoid the calc reboot in this situation.
Just tried on virtual calculator (13012) BETA. Yes, it hung the virtual calculator.
Maybe there is problem, because cot(pi*x) does not exist, if x is integer.
Works fine for me with fsolve:

fsolve(g(x)-f(x),x=3.1 .. 4.5) returns [4.]

and also if you do not even use starting values (which you normally should):

fsolve(g(x)-f(x),x) returns [4.]

solve is the wrong command to use in this example (f(x) is not a polynomial). But if I use solve, i.e., solve(g(x)-f(x),x) my physical Prime does not hang, just returns empty brackets.
(11-21-2017 08:44 PM)Helge Gabert Wrote: [ -> ]Works fine for me with fsolve:

fsolve(g(x)-f(x),x=3.1 .. 4.5) returns [4.]

and also if you do not even use starting values (which you normally should):

fsolve(g(x)-f(x),x) returns [4.]

solve is the wrong command to use in this example (f(x) is not a polynomial). But if I use solve, i.e., solve(g(x)-f(x),x) my physical Prime does not hang, just returns empty brackets.
nearly the same as I answered in the related thread.
Great minds think alike!

Did you also notice that in the function app, the intersection point cannot be found, regardless how closely you position the cursor to the solution at x=4?
(11-21-2017 07:35 PM)parisse Wrote: [ -> ]You are confused: there is a difference between a function f and an expression g. A function has arguments unlike an expression. If f is a function, you can compute f(2) or f(x) and get an expression, while g(2) or g(x) does not mean anything.
Regarding solve, it solves polynomial-like equations, i.e. equations that can be rewritten like a polynomial equation, your equation can not be rewritten like that. For more general equations, there is no method for exact solving, you must switch to approx solving (fsolve). You can solve an expression=another expression with respect to a variable, but solving a function=another function does not mean anything : with respect to what would you solve?. I will add a check to avoid the calc reboot in this situation.
Yes, I was confused. I thought I saw f:=.... and you could then replace x by typing f(x)....but it's not so (just tested it). Thats what happens when you don't have a CAS manual.
However, I could type f=g, as that would create an equation. I missed the line in the help where it says it has to be a polynomial.

So, I tried fsolve, and it worked!

Now, what I'm really trying to do is this.

I'm trying to solve the intersection between the following 2 functions:

f(x):=atan(cot(pi*x))/pi + x -1/2
g(x):=(z^n-x^n)^1/n

The problem specified above was this with z set to 5 and n set to 2.

What I was trying to do was find the x value at the intersection between f(x) and g(x) in terms of z and n.

I can't do this with fsolve, but with csolve(f(x)=g(x),x), I got:

(z^n-e^(i*n*pi))^(1/n)

however, when I evaluate this with z=5, n=2, I get 2*(6)^(1/2), and not 4 (which is the correct answer).

First question is why do I get an incorrect answer and secondly, is there a way to solve this?
Thx
(11-21-2017 09:26 PM)webmasterpdx Wrote: [ -> ]4 (which is the correct answer).
4 is not the correct answer. For your function
f(x):=atan(cot(pi*x))/pi + x -1/2
no solution, if x=4 (or if x is any integer).
fsolve(f(x)=g(x),x) gives me 4 as the answer.
Also, when I plot f(x) and g(x) in the advanced plot and I select intersection, it goes to 4,3 on both curves, and I can visually see that this is where they intersect.

I know that at any integer point for x, the curve moves asymptotically, but right before, but infinitely close to x=n, y is an integer and y goes to y+1 immediately after x=n.

I'm trying to simulate a staircase function using f(x).

I have a problem where I'm trying to mix discrete math and analog math, using the staircase function. If I can do this, it would prove very very useful to me.

However, 2 root 6 is out in left field....
(11-21-2017 10:28 PM)webmasterpdx Wrote: [ -> ]gives me 4 as the answer.
approximation
yes, and that's fine.
However, I need to understand where 2 root 6 comes from...
OK, so to avoid the discontinuous part of f(x), I subtracted a small value from x....and tried:

csolve(f(x-0.001)=g(x),x)

and I get (z^n-e^(pi*i*n))^(1/n)

...when I put n:=2, this becomes...

sqrt(z^2-(1-2.15E-14*i))

The imag term is so small I can ignore it, so it becomes:

sqrt(z^2-1)

...when z:=5, this becomes...

sqrt(5^2-1) = sqrt(25-1) = sqrt(24) = 2*sqrt(6)

The real answer is z-1, not sqrt(z^2-1).

So, I'm wondering how it arrives at that...
Another thing that you should keep in mind when running solve or fsolve is that they expect the expressions inside to be continuous, otherwise you can't do much, solve won't work because polynomial-like equations are continuous, fsolve won't work because you can't apply iterative methods, think for example about bisection. There is no magic, before trying some bizarre input to solve, you should ask yourself could I do it by hand if I could compute very quickly? That's why you must learn the corresponding math before.
in fact, what I was doing to keep the calculation in the continuous part of the curve was to use x-deltaX, where deltaX I varied from 0.001 to 0.5.....seems to work as long as I use a value in that range.

However, I still don't know how it achieved it's result as stated in my previous post....and it doesn't make much sense.
Did you notice that csolve gives you an informational message

csolve(g(x)-f(x)=0,x)

"Simplification assuming n near 0"
"Simplification assuming z near 0"

Since neither z nor n are near zero, here is your answer.
That's kind of annoying...

z near 0 means?
...could mean is a small integer.
...could mean is infinitely close to zero as in .0000001

It also doesn't say:

Answer will be completely wrong if z isn't infinitely closer to zero.

Also, I don't want it to simplify it.

Hmmm....I'll have to try it with assume(z > 4) and see what happens...when I get a chance.
Reference URL's
• HP Forums: https://www.hpmuseum.org/forum/index.php
• :