Post Reply 
Math problem where graphing calculator may slow you down - part II.
09-12-2014, 12:43 PM (This post was last modified: 09-12-2014 12:43 PM by CR Haeger.)
Post: #1
Math problem where graphing calculator may slow you down - part II.
Hello - here is a problem that should be fairly easily solvable by hand and with a trig table:

Assume f(x) = max(sin(x), cos(x)) using radians. If the area under the curve f(x) = 4.0 and the lower limit of x = 0.0, what is the upper limit of integration?

What do your machines and/or brains come up with?

Note - I got this to work on the HP Prime using the AREA() function in Function APP, but had problems using solve() or fsolve() properly. Num-Solv on a TI36x had to think about this a looong time.
Find all posts by this user
Quote this message in a reply
09-12-2014, 04:33 PM (This post was last modified: 09-12-2014 04:54 PM by Marcus von Cube.)
Post: #2
RE: Math problem where graphing calculator may slow you down - part II.
(09-12-2014 12:43 PM)CR Haeger Wrote:  If the area under the curve f(x) = 4.0
Is the area positive if the function is negative? Or are we just talking about the definite integral?

EDIT: If the area is always positive, the answer 2π. I split the interval at π/4, π, π+π/4, π+π/2, 2π. All the square roots cancel each other.

Marcus von Cube
Wehrheim, Germany
http://www.mvcsys.de
http://wp34s.sf.net
http://mvcsys.de/doc/basic-compare.html
Find all posts by this user
Quote this message in a reply
09-12-2014, 05:22 PM
Post: #3
RE: Math problem where graphing calculator may slow you down - part II.
(09-12-2014 04:33 PM)Marcus von Cube Wrote:  
(09-12-2014 12:43 PM)CR Haeger Wrote:  If the area under the curve f(x) = 4.0
Is the area positive if the function is negative? Or are we just talking about the definite integral?

EDIT: If the area is always positive, the answer 2π. I split the interval at π/4, π, π+π/4, π+π/2, 2π. All the square roots cancel each other.

Hi Marcus, I should have stated that its a definite integral where area is negative when f(x) is negative. Your solution and abs(f(x)) are interesting too - thanks!
Find all posts by this user
Quote this message in a reply
09-13-2014, 04:54 AM
Post: #4
RE: Math problem where graphing calculator may slow you down - part II.
My solution by hand: \(2\pi+\arccos(3\sqrt{2}-4)\)
This is about: 7.6089
I used the HP-15C with this program to calculate the function:
Code:
LBL A
1
->R
x<y
x<>y
RTN
And then another program to calculate the integral which I finally used with the solver.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
09-13-2014, 09:12 PM
Post: #5
RE: Math problem where graphing calculator may slow you down - part II.
By hand and a bit of brain....
f(x) is periodic with a 2pi period.
from 0 to pi/4 f(x)=cos(x)
from pi/4 to 5pi/4 f(x)=sin(x)
from 5pi/4 to 2pi f(x)=cos(x)

Integrating is straightforward and gives 4/sqrt(2) over 0 to 2pi
going up to 9pi/4 gives 5/sqrt(2).
Then the value searched for is between 9pi/4 and 9pi/4+pi, in other words on the second interval of the definition of f(x).
This equivalent to search for X with: sum from pi/4 to X of sin(x) dx=4-5/sqrt(2).
Integrating analytically and solving lead to: X=acos(6/sqrt(2)-4)
The solution is then 9pi/4+X-pi/4~7.6089

Nothing more necessary than any standard scientific calculator...
BTW, I'm cheating slightly, I checked the value of the integral with my own python software ;-)
which uses a HP like algorithm....
Find all posts by this user
Quote this message in a reply
09-14-2014, 02:18 PM
Post: #6
RE: Math problem where graphing calculator may slow you down - part II.
(09-13-2014 09:12 PM)Bunuel66 Wrote:  Integrating is straightforward and gives 4/sqrt(2) over 0 to 2pi

We should make sure that the integral is always < 4. Thus we calculate it up to the first zero of the function \(f(x)\) which occurs at \(x=\pi\):
\[
\int_{0}^{\pi}\max(\sin(x),\cos(x))dx=1+\sqrt{2}\approx 2.41421
\]

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
09-14-2014, 07:22 PM
Post: #7
RE: Math problem where graphing calculator may slow you down - part II.
Actually I made the check for the first maximum, I wanted just not to be too long with the explanations, just giving the general idea.

Regards
Find all posts by this user
Quote this message in a reply
11-14-2014, 10:01 PM (This post was last modified: 11-14-2014 10:40 PM by Gilles.)
Post: #8
RE: Math problem where graphing calculator may slow you down - part II.
I used the numeric solver of the 50G in FIX 4

[Image: 953908eq50.png]

FIX 6 takes more time and returns
X: 7.608894

This help to get the exact answer with the 50G CAS :
'X=2*PI+ACOS(3*SQRT(2)-4)'
Find all posts by this user
Quote this message in a reply
11-16-2014, 04:06 PM (This post was last modified: 11-16-2014 04:21 PM by CR Haeger.)
Post: #9
RE: Math problem where graphing calculator may slow you down - part II.
Thanks Giles,

Has anyone tried solving this using the HP Prime CAS, Home or Function APP? It seems to me there are only a couple of ways to find a numeric solution. I have not found any exact solution using the device either.

Screenshot with CAS settings Exact, Complex and Use i unchecked.
   

Graphically, it worked out pretty well, once I figured out AREA() syntax. Note that using integral from template did not work for me.
   
   
Find all posts by this user
Quote this message in a reply
11-16-2014, 08:40 PM (This post was last modified: 11-16-2014 08:45 PM by Gilles.)
Post: #10
RE: Math problem where graphing calculator may slow you down - part II.
Hi CR Haeger, I tried with the Prime both in CAS and with the SOLVE APPS without success.

I agree with you about the plotter of the Prime : just fabulous !
I like very much to zoom instantly with 2 fingers Big Grin
Find all posts by this user
Quote this message in a reply
11-28-2014, 06:17 PM
Post: #11
RE: Math problem where graphing calculator may slow you down - part II.
I'm amazed at the TI 36 Pro. It took 30+ minutes (in numsolve), but it came up with the result!
Find all posts by this user
Quote this message in a reply
11-29-2014, 12:49 AM
Post: #12
RE: Math problem where graphing calculator may slow you down - part II.
I sped things up to under 15 minutes by doing a couple of experimental integrations to get an idea of where the integral would be ~4, then a quick table to zoom in on an appropriate guess, and then enter a good guess into numsolve.
Find all posts by this user
Quote this message in a reply
11-29-2014, 03:31 AM
Post: #13
RE: Math problem where graphing calculator may slow you down - part II.
...which leads me to...how to accomplish this on the WP-34S? How do I solve for an integral ?
Find all posts by this user
Quote this message in a reply
11-29-2014, 09:30 AM
Post: #14
RE: Math problem where graphing calculator may slow you down - part II.
(11-29-2014 03:31 AM)lrdheat Wrote:  how to accomplish this on the WP-34S?

It's similar to what you do using the HP-15C:
Code:
LBL'FX'
1
->REC
MAX
RTN

Code:
LBL'IGR'
0
x<>y
∫'FX'
4
-
RTN

RAD
FIX 4
7.6
7.61
SLV'IGR'

7.6089

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
11-29-2014, 01:52 PM (This post was last modified: 11-29-2014 01:54 PM by CR Haeger.)
Post: #15
RE: Math problem where graphing calculator may slow you down - part II.
(11-29-2014 12:49 AM)lrdheat Wrote:  I sped things up to under 15 minutes by doing a couple of experimental integrations to get an idea of where the integral would be ~4, then a quick table to zoom in on an appropriate guess, and then enter a good guess into numsolve.


Try turning off pretty print mode and setting the integrals resolution to say 0.1. May speed things up.

I agree - the TI36x is pretty straightforward and capable for these type if solver problems.
Find all posts by this user
Quote this message in a reply
11-30-2014, 01:33 AM
Post: #16
RE: Math problem where graphing calculator may slow you down - part II.
Thanks Thomas,

It works...couldn't remember how to have an integral in solve. Rather slow on this sort of problem!
Find all posts by this user
Quote this message in a reply
11-30-2014, 12:16 PM
Post: #17
RE: Math problem where graphing calculator may slow you down - part II.
(11-30-2014 01:33 AM)lrdheat Wrote:  Rather slow on this sort of problem!

For this specific problem the derivative is trivial:

\[
\begin{align}
F(x)&=\int_{0}^{x}f(t)dt-4 \\
F'(x)&=f(x) \\
\end{align}
\]

Thus we can use Newton's method:
\[
\begin{align}
x'&=x-\frac{F(x)}{F'(x)} \\
&=x-\frac{\int_{0}^{x}f(t)dt-4}{f(x)} \\
&=x+\frac{\int_{x}^{0}f(t)dt+4}{f(x)} \\
\end{align}
\]

Instead of starting the integration from \(0\) over and over again we can reuse the result of \(F(x)\) from the previous loop:
\[
F(x')=F(x)+\int_{x}^{x'}f(t)dt
\]
This value is saved in register 01.

Code:
LBL'FX'
# 001
→REC
MAX
RTN

Code:
LBL'NWT'
# 004
STO 01
CLx
STO 00
R↓
LBL 00
ENTER↑
x<> 00
∫'FX'
RCL+ 01
STO 01
RCL 00
XEQ'FX'
/
x≈0?
SKIP 002
RCL+ 00
GTO 00
RCL 00
END

This will speed up the calculation.

Cheers
Thomas
Find all posts by this user
Quote this message in a reply
11-30-2014, 07:04 PM
Post: #18
RE: Math problem where graphing calculator may slow you down - part II.
Excellent, clear, concise as usual.
Find all posts by this user
Quote this message in a reply
Post Reply 




User(s) browsing this thread: 5 Guest(s)