HP Forums

Full Version: Math problem where graphing calculator may slow you down - part II.
You're currently viewing a stripped down version of our content. View the full version with proper formatting.
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.
(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.
(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!
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
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....
(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
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
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)'
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.
[attachment=1213]

Graphically, it worked out pretty well, once I figured out AREA() syntax. Note that using integral from template did not work for me.
[attachment=1214]
[attachment=1215]
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
I'm amazed at the TI 36 Pro. It took 30+ minutes (in numsolve), but it came up with the result!
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.
...which leads me to...how to accomplish this on the WP-34S? How do I solve for an integral ?
(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
(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.
Thanks Thomas,

It works...couldn't remember how to have an integral in solve. Rather slow on this sort of problem!
(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
Excellent, clear, concise as usual.
Reference URL's